Skip to content

AnyRouter MCP with Claude Code

Add the AnyRouter MCP server to Claude Code (CLI) with one command or by editing .mcp.json.

Claude Code (the CLI) registers MCP servers with claude mcp add — a single command — or by editing an .mcp.json config file directly.

  1. Add the server with one command:

    claude mcp add --transport http anyrouter https://anyrouter.dev/api/v1/mcp
    

    What the arguments mean:

    • --transport http — AnyRouter is a remote HTTP MCP server (not stdio).
    • anyrouter — the local name; pick anything memorable.
    • https://anyrouter.dev/api/v1/mcp — the endpoint URL.

    To scope it to a single project, add --scope project (writes .mcp.json in the project instead of the user-level config).

  2. Approve the OAuth consent. The next tool invocation opens your browser at anyrouter.dev/oauth/consent. Pick a permission level (Read-only is the default and safest) and click Allow. Claude Code receives the authorization code through its local callback and stores the token.

  1. Open (or create) .mcp.json in your project root (or the user-level config for a global entry).

  2. Add the AnyRouter server:

    {
      "mcpServers": {
        "anyrouter": {
          "type": "http",
          "url": "https://anyrouter.dev/api/v1/mcp"
        }
      }
    }
    
  3. Restart Claude Code. The next tool call opens anyrouter.dev/oauth/consent — pick a permission level and click Allow.

Permission level reference: MCP API reference → Scopes and consent bundles.

Verify

claude mcp list

You should see anyrouter — Connected (or similar). Trigger the connection inline:

claude "list my AnyRouter models that support vision"

Revoke

claude mcp remove anyrouter

This deletes only the local registration. To revoke the OAuth token server-side, use the MCP dashboard — after that, any later tool call returns 401 Unauthorized until you reconnect.

Troubleshooting

localhost:NNNNN refused to connect after consent

The local OAuth callback listener was no longer running when the browser redirected back. Most often the mcp-remote (or Claude Code) child process exited between opening the consent page and clicking Allow. Retry in one continuous flow — open the prompt and complete consent quickly. If that doesn't help, clear stale auth state:

rm -rf ~/.mcp-auth

then re-run claude mcp add and trigger the next tool call.

anyrouter not appearing in claude mcp list

You probably added it with --scope project in a different directory. Check cat .mcp.json in the project and the user-level config.

Related