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

ToolPurposeArgumentsScope
list_modelsBrowse 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_modelRank models this caller can dispatch for one job.task (required), free_only, max_input_per_1m, min_context, limit (default 5)None
get_usageRequest, token, and dollar totals for a recent window, plus the top models.days (default 7, max 90)read:analytics
list_byok_keysProvider-key status (enabled, validation). Never returns the secret.enabled_only (optional)read:byok
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
publish_artifactPublish 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_pathwrite:artifacts
list_artifactsList your artifacts, newest first.limit (default 20)read:artifacts
get_artifactRead one artifact's metadata and file list.idread:artifacts
delete_artifactDelete an artifact. Its URL stops working at once.idwrite:artifacts
set_artifact_visibilityMake an artifact private, unlisted or public.id, visibilitywrite:artifacts
get_system_statusAnyRouter health snapshot: overall status plus per-component breakdowns (API, providers, smoke tests).NoneNone

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.

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_list_endpoints returns the live endpoint catalog. Dangerous endpoints (destructive or costly) require confirm: true.

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.

BundleIncludesUse when
Read-only (default)read:llm-keys, read:presets, read:credits, read:analytics, read:byok, read:hub, read:connections, inferenceThe client browses models, credits, recent usage, and provider-key status 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, 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

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/settings#keys.
Permission deniedThe 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" }
}
FieldMeaning
enabledThe value in effect: setting when it is set, otherwise default.
settingYour saved choice, or null to follow the default.
defaulttrue when the workspace has at least one live (not paused) MCP connection, otherwise false.
urlThe gateway URL to connect.
authHow to authenticate: send the caller's own key as a bearer token. The response never contains a credential.
can_editWhether the caller may change the setting.
artifactsThe 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