Skip to content

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.

POST/api/v1/mcp

Authenticate 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

ToolPurposeArgumentsScope
list_modelsSearch models your key can call.provider, capability, min_context, include_unavailable, limit (default 100)None
list_okf_conceptsBrowse the AnyRouter knowledge base (Open Knowledge Format).type, search, limit (default 200)None
get_okf_conceptRead one knowledge-base concept in full.idNone
get_creditsWorkspace balance and lifetime usage totals.Noneread:credits
list_keysList workspace LLM API keys.include_disabled (default false)read:llm-keys
create_keyCreate a new LLM API key.name, label (optional), rate_limit (optional)write:llm-keys
revoke_keyDisable an LLM API key.key_idwrite:llm-keys
list_presetsList workspace presets.Noneread:presets
list_conversationsSearch workspace conversations.starred, limit (default 50), searchread:llm-keys
publish_promptPublish a prompt to the community prompt library (starts as pending review).title, description, body, category, plus optional tags, platforms, recommended_agents, recommended_modelwrite:hub
star_promptSave a community prompt to your personal collection.prompt_idwrite:hub
fork_promptFork a community prompt into your own copy (private by default).prompt_id, plus optional title, body, visibilitywrite:hub
publish_skillSync a single SKILL.md to a hub so your machines and agents can install it.body, plus optional name, slug, tags, hubwrite:hub
list_hubsList the Skills & Knowledge hubs your workspace owns.Noneread:hub
get_hubGet one hub (by slug) with its items.slugread:hub
search_public_hubsSearch public hubs you can subscribe to.search (optional), limit (default 20)read:hub
create_hubCreate a new hub.name, plus optional slug, description, visibility (default workspace)write:hub
hub_add_itemAdd an item (skill, prompt, knowledge doc, or plugin) to a hub.hub, body, plus optional kind (default kb), name, slug, tagswrite:hub
hub_import_skillImport a skill from skills.sh / GitHub into a hub.hub, source_refwrite:hub
get_system_statusAnyRouter health snapshot: overall status plus per-component breakdowns (API, providers, smoke tests).NoneNone

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_*).

ToolPurposeArguments
admin_list_endpointsList every admin API endpoint callable via admin_request.method (optional), search (optional)
admin_requestCall any admin API endpoint.method, path, query (optional), body (optional), confirm
admin_overviewPlatform overview: users, requests, cost, revenue, DAU/MAU, top models.None
admin_usage_summaryCost / revenue / token / request totals by provider and model.days (default 30)
admin_north_starNorth-star growth metrics: activation rate and weekly-active CLI users.days (default 30)
admin_list_usersList users with balance, plan, and activity.limit, offset, include_stale
admin_get_userRich detail for one user.user_id
admin_errors_overviewError overview and timeline.days (default 1)
admin_smoke_testLatest smoke-test snapshot.None
admin_upstream_healthLive per-upstream health (healthy / deprioritized / excluded).None
admin_grant_creditsGrant 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.

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.

BundleIncludesUse when
Read-only (default)read:llm-keys, read:presets, read:credits, read:hub, read:connections, inferenceThe client observes and browses without making changes.
StandardRead-only + write:llm-keys, write:presets, write:hub, write:connectionsThe 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

CaseMeaningFix
No workspace boundThe credential isn't associated with a workspace.Create a key from the dashboard first.
UnauthorizedThe credential is invalid, revoked, or expired.Check /dashboard/keys or /dashboard/management-keys.
Permission deniedThe 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.