ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Workflows
  3. MCP Routing Decision Workflow
Workflow

MCP Routing Decision Workflow

Agent routing workflow using MCP: check provider status and pricing before each API call, route to cheapest available.

Start FreeAPI Docs

Overview

Before each search API call, the agent checks provider availability and pricing via MCP tools, then routes to the cheapest available provider. Reduces cost and avoids calls to degraded services.

Trigger

Before each agent search request

Schedule

On-demand (per request)

Workflow Steps

1

Check provider status

Query status MCP for each search provider availability.

2

Get current pricing

Fetch per-query costs from pricing MCP.

3

Filter available providers

Remove providers with degraded or down status.

4

Route to cheapest

Select the cheapest available provider and execute search.

Python Implementation

Python
import requests, os

PROVIDERS = {
    "scavio": {"url": "https://api.scavio.dev/api/v1/search", "header": "x-api-key", "key_env": "SCAVIO_API_KEY", "cost": 0.005},
    "serper": {"url": "https://google.serper.dev/search", "header": "X-API-KEY", "key_env": "SERPER_KEY", "cost": 0.001},
}

def search_with_routing(query, platform="google"):
    available = []
    for name, cfg in PROVIDERS.items():
        try:
            key = os.environ.get(cfg["key_env"])
            if not key:
                continue
            available.append((name, cfg))
        except Exception:
            continue
    available.sort(key=lambda x: x[1]["cost"])
    for name, cfg in available:
        try:
            r = requests.post(cfg["url"],
                headers={cfg["header"]: os.environ[cfg["key_env"]], "Content-Type": "application/json"},
                json={"platform": platform, "query": query} if name == "scavio" else {"q": query},
                timeout=5)
            if r.ok:
                return {"provider": name, "cost": cfg["cost"], "data": r.json()}
        except Exception:
            continue
    return None

JavaScript Implementation

JavaScript
const providers = [
  {name: "scavio", url: "https://api.scavio.dev/api/v1/search", cost: 0.005,
   headers: {"x-api-key": process.env.SCAVIO_API_KEY, "Content-Type": "application/json"},
   body: (q) => JSON.stringify({platform: "google", query: q})},
];
for (const p of providers.sort((a, b) => a.cost - b.cost)) {
  try {
    const r = await fetch(p.url, {method: "POST", headers: p.headers, body: p.body(query)});
    if (r.ok) return {provider: p.name, data: await r.json()};
  } catch {}
}

Platforms Used

Google

Web search with knowledge graph, PAA, and AI overviews

Frequently Asked Questions

Before each search API call, the agent checks provider availability and pricing via MCP tools, then routes to the cheapest available provider. Reduces cost and avoids calls to degraded services.

This workflow uses a before each agent search request. On-demand (per request).

This workflow uses the following Scavio platforms: google. Each platform is called via the same unified API endpoint.

Yes. Scavio's free tier includes 50 credits on signup with no credit card required. That is enough to test and validate this workflow before scaling it.

MCP Routing Decision Workflow

Agent routing workflow using MCP: check provider status and pricing before each API call, route to cheapest available.

Get Your API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy