Pular para o conteúdo
Começar
RoteamentoModelosRecursosDocsApps Entrar Começar

MCP Integration

Este conteúdo não está disponível em sua língua ainda.

GreatRouter exposes a remote Model Context Protocol (MCP) server so AI assistants can classify prompts, suggest models, run auto-routing, and browse the catalog using your API key.

Endpoint

https://mcp.greatrouterai.com/mcp

Health check: GET https://mcp.greatrouterai.com/health

Authentication

Every MCP request must include your GreatRouter API key:

Authorization: Bearer pk_live_...

Test keys (pk_test_...) work the same way. Get a key from the dashboard.

Cursor configuration

Add this to your Cursor MCP settings (~/.cursor/mcp.json or project .cursor/mcp.json):

{
"mcpServers": {
"greatrouter": {
"url": "https://mcp.greatrouterai.com/mcp",
"headers": {
"Authorization": "Bearer pk_live_YOUR_KEY_HERE"
}
}
}
}

Replace pk_live_YOUR_KEY_HERE with your API key from the dashboard.

Available tools

ToolDescriptionBills wallet
suggest_modelsClassify a prompt and return ranked model suggestionsNo
auto_routeClassify, route, and run inference on the best modelYes (wallet); optional x402 USDC per call when enabled
list_modelsSearch or list catalog modelsNo
get_modelFetch a single model by provider/nameNo
price_comparisonCompare estimated costs across modelsNo
catalog_familiesBrowse catalog taxonomy model linesNo
get_preferencesRead org routing preferencesNo
submit_feedbackSubmit classification feedbackNo

Example: suggest models

Ask your assistant to call suggest_models with a prompt:

{
"prompt": "Generate a cinematic sunset landscape image",
"optimization": "balanced",
"limit": 5
}

The tool returns classification metadata and ranked suggestions — no inference is run.

Example: auto route

auto_route runs full routing plus inference. Use budget_dollars to cap spend:

{
"prompt": "Write a TypeScript function to debounce API calls",
"optimization": "price-optimized",
"budget_dollars": 0.05
}

Billing and rate limits

MCP tools use the same wallet, usage records, and rate limits as the REST API. auto_route deducts usage on successful inference; suggest/list/catalog tools are free aside from any underlying API costs where applicable.

Agentic payments (x402, optional)

When the MCP Worker has X402_RECIPIENT configured, auto_route is also exposed as an x402 paidTool (default $0.01 USDC per call on Base). API key auth remains required — x402 is additive for autonomous agent clients using withX402Client from agents/x402.

VariableDefaultPurpose
X402_NETWORKbase-sepoliabase (prod) or base-sepolia (dev)
X402_RECIPIENTUSDC recipient wallet (0x…)
X402_FACILITATOR_URLhttps://x402.org/facilitatorSettlement facilitator
X402_AUTO_ROUTE_PRICE_USD0.01Per-call price

See greatrouter/apps/mcp/.env.example for local wrangler dev setup.

Troubleshooting

SymptomFix
401 UnauthorizedCheck Authorization: Bearer pk_live_... header
402 / insufficient creditsTop up wallet in dashboard (or pay x402 USDC when enabled)
429 Rate limitedReduce request frequency or upgrade limits
Tool list empty in clientRestart MCP connection after updating mcp.json