MCP API Reference
JSON-RPC tool catalog, scopes, error shapes, and manual authentication for the AnyRouter MCP server.
AnyRouter runs a Model Context Protocol server that exposes your workspace — models, keys, presets, credits, and status — as JSON-RPC tools. This page is the protocol reference: tools, arguments, scopes, errors, and the manual auth path for clients that can't run OAuth.
/api/v1/mcpAuthenticate with an OAuth 2.1 bearer token, an LLM key (sk-ar-v1-…, grants list_models only), or a Management key (ak_…) carrying the scopes the tools you call require. See Manual authentication.
For step-by-step client setup (Claude Desktop, Claude Code, Cursor, OpenCode, …), see MCP Server. The MCP server does not expose a chat tool — clients call the Chat Completions, Messages, or Responses endpoints directly.
Request
- Endpoint:
POST https://anyrouter.dev/api/v1/mcp - Protocol: JSON-RPC 2.0 over HTTPS (Streamable HTTP transport)
- Content type:
application/json - Authentication: OAuth 2.1 bearer token, or a static API key (see below)
Tools
| Tool | Purpose | Arguments | Scope |
|---|---|---|---|
list_models | Search models your key can call. | provider, capability, min_context, include_unavailable, limit (default 100) | None |
list_okf_concepts | Browse the AnyRouter knowledge base (Open Knowledge Format). | type, search, limit (default 200) | None |
get_okf_concept | Read one knowledge-base concept in full. | id | None |
get_credits | Workspace balance and lifetime usage totals. | None | read:credits |
list_keys | List workspace LLM API keys. | include_disabled (default false) | read:llm-keys |
create_key | Create a new LLM API key. | name, label (optional), rate_limit (optional) | write:llm-keys |
revoke_key | Disable an LLM API key. | key_id | write:llm-keys |
list_presets | List workspace presets. | None | read:presets |
list_conversations | Search workspace conversations. | starred, limit (default 50), search | read:llm-keys |
publish_prompt | Publish a prompt to the community prompt library (starts as pending review). | title, description, body, category, plus optional tags, platforms, recommended_agents, recommended_model | write:hub |
star_prompt | Save a community prompt to your personal collection. | prompt_id | write:hub |
fork_prompt | Fork a community prompt into your own copy (private by default). | prompt_id, plus optional title, body, visibility | write:hub |
publish_skill | Sync a single SKILL.md to a hub so your machines and agents can install it. | body, plus optional name, slug, tags, hub | write:hub |
list_hubs | List the Skills & Knowledge hubs your workspace owns. | None | read:hub |
get_hub | Get one hub (by slug) with its items. | slug | read:hub |
search_public_hubs | Search public hubs you can subscribe to. | search (optional), limit (default 20) | read:hub |
create_hub | Create a new hub. | name, plus optional slug, description, visibility (default workspace) | write:hub |
hub_add_item | Add an item (skill, prompt, knowledge doc, or plugin) to a hub. | hub, body, plus optional kind (default kb), name, slug, tags | write:hub |
hub_import_skill | Import a skill from skills.sh / GitHub into a hub. | hub, source_ref | write:hub |
get_system_status | AnyRouter health snapshot: overall status plus per-component breakdowns (API, providers, smoke tests). | None | None |
The list_hubs … hub_import_skill tools manage the Skills & Knowledge Hub from inside your agent.
Admin tools
Accounts registered as AnyRouter administrators see additional tools (hidden from tools/list for everyone else). They work with either an LLM key (sk-ar-v1-*) or a management key (ak_*).
| Tool | Purpose | Arguments |
|---|---|---|
admin_list_endpoints | List every admin API endpoint callable via admin_request. | method (optional), search (optional) |
admin_request | Call any admin API endpoint. | method, path, query (optional), body (optional), confirm |
admin_overview | Platform overview: users, requests, cost, revenue, DAU/MAU, top models. | None |
admin_usage_summary | Cost / revenue / token / request totals by provider and model. | days (default 30) |
admin_north_star | North-star growth metrics: activation rate and weekly-active CLI users. | days (default 30) |
admin_list_users | List users with balance, plan, and activity. | limit, offset, include_stale |
admin_get_user | Rich detail for one user. | user_id |
admin_errors_overview | Error overview and timeline. | days (default 1) |
admin_smoke_test | Latest smoke-test snapshot. | None |
admin_upstream_health | Live per-upstream health (healthy / deprioritized / excluded). | None |
admin_grant_credits | Grant credits to a user. | user_id, amount, description (optional), confirm (required) |
admin_request is the general gateway; admin_list_endpoints returns the full live catalog. Endpoints flagged dangerous (destructive or costly) require confirm: true.
Scopes and consent bundles
When a client requests authorization, the user picks one bundle on the AnyRouter consent screen. Users can downgrade from what a client requests; a tool needing a scope outside the granted bundle returns permission denied.
| Bundle | Includes | Use when |
|---|---|---|
| Read-only (default) | read:llm-keys, read:presets, read:credits, read:hub, read:connections, inference | The client observes and browses without making changes. |
| Standard | Read-only + write:llm-keys, write:presets, write:hub, write:connections | The client creates/revokes keys, edits presets, or manages hub items. |
read:hub / write:hub gate the Skills & Knowledge Hub tools. read:credits gates get_credits; list_models, get_system_status, and the knowledge-base tools need no scope. Tools that always work (like list_models) require no bundle at all.
Manual authentication
Clients that cannot run OAuth authenticate with a static bearer token: an LLM API key (sk-ar-v1-*, grants list_models only) or a Management API key (ak_*) with the scopes you need.
curl https://anyrouter.dev/api/v1/mcp \
-H "Authorization: Bearer ak_your_management_key" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":1}'
Response
A tool call returns a normal JSON-RPC success envelope. The tool's output lives in result.content — an array of content blocks. AnyRouter tools return a single text block whose text is a JSON payload:
{
"jsonrpc": "2.0",
"result": {
"content": [{ "type": "text", "text": "{ \"total\": 3, \"data\": [ ... ] }" }]
},
"id": 1
}
Tool failures
When a tool fails (an invalid argument, an unknown id, an upstream error), the call still returns a successful JSON-RPC envelope. Per the MCP spec, the failure is reported in-band on the result with isError: true and the message in result.content[0].text — there is no top-level error object:
{
"jsonrpc": "2.0",
"result": {
"content": [{ "type": "text", "text": "Key key_123 not found in this workspace." }],
"isError": true
},
"id": 1
}
Detect a failed tool call by checking result.isError — not response.error. A top-level error object is reserved for protocol/transport failures, not tool failures. For example, an unauthenticated request returns HTTP 401 with:
{
"jsonrpc": "2.0",
"error": { "code": -32001, "message": "Unauthorized" },
"id": null
}
Errors
| Case | Meaning | Fix |
|---|---|---|
| No workspace bound | The credential isn't associated with a workspace. | Create a key from the dashboard first. |
| Unauthorized | The credential is invalid, revoked, or expired. | Check /dashboard/keys or /dashboard/management-keys. |
| Permission denied | The credential lacks the tool's scope. | Pick a higher consent bundle or upgrade the management key's scopes. |
Rate limits
The MCP endpoint is rate limited to protect your workspace and keep the service responsive:
- Per credential — up to 120 tool calls per minute for each API key or token.
- Per IP — up to 300 requests per minute from a single IP address (applied before authentication, so it also covers failed sign-ins).
Crossing a limit returns HTTP 429 with a Retry-After header and a JSON-RPC error body:
{
"jsonrpc": "2.0",
"error": { "code": -32000, "message": "Rate limit exceeded — retry after 60s." },
"id": null
}
These limits are on the management tier and are separate from the inference rate limits that apply to Chat Completions, Messages, and Responses.
Revoking access
To revoke an MCP client's access, open /dashboard/mcp, find the client under Connected clients, and click Revoke. The token is deleted immediately; subsequent tool calls return 401 Unauthorized. Revoking does not uninstall the client config — the next tool invocation simply re-runs OAuth.
Access tokens are bearer tokens — treat them like passwords. All connections use HTTPS; the endpoint refuses unencrypted HTTP. If you lose a device or suspect a leak, revoke the client on /dashboard/mcp immediately. Starting a new consent flow mints a new token; old tokens stay valid until explicitly revoked.
Related
- MCP Server — step-by-step client setup
- Management API Keys — the
ak_…keys and scopes used here - Credits API — what
get_creditsreturns