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 models, keys, presets, credits and status as JSON-RPC tools.
Authenticate with an OAuth 2.1 bearer token, an LLM key (sk-ar-v1-…, grants the unscoped tools such as list_models and recommend_model, plus the artifact tools), or a Management key (ak_…) carrying the scopes the tools you call require. See Manual authentication.
Client setup is in MCP Server. There is no chat tool: call Chat Completions, Messages or Responses 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 | Browse every listed model, each with access, can_route and (when false) can_route_reason. | provider, capability (catalog tag), task (translation, coding, reasoning, vision, cheap), free_only, min_context, sort (price, context), include_unavailable (ignored), limit (default 100) | None |
recommend_model | Rank models this caller can dispatch for one job. | task (required), free_only, max_input_per_1m, min_context, limit (default 5) | None |
get_usage | Request, token, and dollar totals for a recent window, plus the top models. | days (default 7, max 90) | read:analytics |
list_byok_keys | Provider-key status (enabled, validation). Never returns the secret. | enabled_only (optional) | read:byok |
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 |
publish_artifact | Publish a page, diagram, image or source file (text files, up to 1 MB) and get its URL. The entry can be .html, .md, .svg, .mmd or a source file. Private by default; pass id and base_version for a new version. | files, plus optional title, visibility, id, base_version, label, entry_path | write:artifacts |
list_artifacts | List your artifacts, newest first. | limit (default 20) | read:artifacts |
get_artifact | Read one artifact's metadata and file list. | id | read:artifacts |
delete_artifact | Delete an artifact. Its URL stops working at once. | id | write:artifacts |
set_artifact_visibility | Make an artifact private, unlisted or public. | id, visibility | write:artifacts |
get_system_status | AnyRouter health snapshot: overall status plus per-component breakdowns (API, providers, smoke tests). | None | None |
list_hubs … hub_import_skill manage the Skills & Knowledge Hub. The artifact tools are described in the Artifacts API.
Admin tools
Administrator accounts see extra tools (hidden from tools/list for everyone else), usable with an LLM key or a management key.
| 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_list_endpoints returns the live endpoint catalog. Dangerous endpoints (destructive or costly) require confirm: true.
Scopes and consent bundles
The user picks one bundle on the consent screen and can downgrade what a client requests. A tool outside the granted bundle returns permission denied.
| Bundle | Includes | Use when |
|---|---|---|
| Read-only (default) | read:llm-keys, read:presets, read:credits, read:analytics, read:byok, read:hub, read:connections, inference | The client browses models, credits, recent usage, and provider-key status 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, read:analytics gates get_usage, read:byok gates list_byok_keys. list_models, recommend_model, get_system_status and the knowledge-base tools need no scope. An LLM key (sk-ar-v1-*) can call those and the artifact tools, and nothing else; a key whose endpoint allow-list leaves out Artifacts does not see the artifact tools.
Manual authentication
Clients that cannot run OAuth send a static bearer token: an LLM API key (sk-ar-v1-*) 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 JSON-RPC success envelope. Output is in result.content: 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
A failed tool call (invalid argument, unknown id, upstream error) still returns a success envelope. The failure is in-band: isError: true with the message in result.content[0].text, and no top-level error:
{
"jsonrpc": "2.0",
"result": {
"content": [{ "type": "text", "text": "Key key_123 not found in this workspace." }],
"isError": true
},
"id": 1
}Check result.isError, not response.error. A top-level error is only for protocol/transport failures, for example an unauthenticated request (HTTP 401):
{
"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/settings#keys. |
| Permission denied | The credential lacks the tool's scope. | Pick a higher consent bundle or upgrade the management key's scopes. |
Rate limits
- Per credential: up to 120 tool calls per minute for each API key or token.
- Per IP: up to 300 requests per minute (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 are management-tier limits, separate from the inference rate limits.
Artifact tools only
Add ?tools=artifacts to the gateway URL to get only the five artifact tools: no other tools, resources or connected servers.
claude mcp add --transport http anyrouter-artifacts \
"https://anyrouter.dev/api/v1/mcp?tools=artifacts" \
--header "Authorization: Bearer $ANYROUTER_API_KEY"Scopes still apply: a management key needs read:artifacts / write:artifacts. An unknown tools value returns 400.
Auto-connect config
The anyr CLI reads one workspace setting to decide whether to connect this gateway in the agents it launches (anyr claude, anyr codex, anyr opencode, anyr grok).
curl https://anyrouter.dev/api/v1/mcp/config \
-H "Authorization: Bearer $ANYROUTER_API_KEY"{
"workspace_id": "ws_123",
"enabled": true,
"setting": null,
"default": true,
"url": "https://anyrouter.dev/api/v1/mcp",
"auth": { "header": "Authorization", "scheme": "Bearer", "credential": "caller_key" },
"can_edit": true,
"artifacts": { "enabled": true, "url": "https://anyrouter.dev/api/v1/mcp?tools=artifacts" }
}| Field | Meaning |
|---|---|
enabled | The value in effect: setting when it is set, otherwise default. |
setting | Your saved choice, or null to follow the default. |
default | true when the workspace has at least one live (not paused) MCP connection, otherwise false. |
url | The gateway URL to connect. |
auth | How to authenticate: send the caller's own key as a bearer token. The response never contains a credential. |
can_edit | Whether the caller may change the setting. |
artifacts | The artifact tools alone. enabled is true unless setting is false or the caller's key may not use Artifacts. A client connects url when enabled is true, otherwise artifacts.url when artifacts.enabled is true. |
GET accepts an inference key (sk-ar-v1-…) or a signed-in session. A management key (ak_…) is not accepted here. A key whose endpoint allow-list leaves out MCP gets 403.
To change it, PATCH from a dashboard session as the workspace owner with { "enabled": true }, { "enabled": false }, or { "enabled": null } for the default. The response has the same shape as GET.
To opt out on one machine instead, pass --no-mcp on a launch or run anyr mcp auto off.
Revoking access
Open /dashboard/mcp, find the client under Connected clients and click Revoke. The token is deleted at once and later calls return 401 Unauthorized. The client config stays; its next call re-runs OAuth.
Access tokens are bearer tokens: treat them like passwords. The endpoint refuses plain HTTP. If a device is lost or a token leaks, revoke the client on /dashboard/mcp. A new consent flow mints a new token; old tokens stay valid until revoked.
AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer