OpenRouter MCP

by codechap

Not rated
GitHub

About

MCP server for OpenRouter — chat with any model through one API key

Details

Author
codechap
Categories
Developer Tools, AI, API

Setup

Install OpenRouter MCP in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/codechap/mcp-server-open-router

Follow the installation instructions in the repository README, then restart your MCP client.

An MCP (Model Context Protocol) server forOpenRouter— one API key, 300+ models from every major lab. Built in Rust, it exposes chat, vision, web-search, model listing, and credit-balance tools over stdio soanyMCP client can use them.

Default model:moonshotai/kimi-k3— 1M context, $3/$15 per M input/output, vision-capable. Communicates via stdio using JSON-RPC 2.0. Structurally it mirrorsmcp-server-fablewith the OpenAI-compatible request layer ofmcp-server-grok-chat.

- Actual-cost accounting— every chat request sendsusage:{"include":true}; the response footer shows OpenRouter's reported USD ([cost: $0.008901]), never an estimate from pricing constants.
- Error-in-200 handling— OpenRouter can return HTTP 200 with a top-level{"error":...}body (nochoices). The server treats that as a tool error, not a panic or empty success. Per-choice provider errors render inline.
- Unified reasoning— request fieldreasoningwith effort / exclude / enabled; optional[reasoning]…[/reasoning]block whenshow_reasoning=true.
- Web plugin + Sourceschat_with_searchusesplugins:[{"id":"web"}]; cited pages become aSources:list fromurl_citationannotations.
- Unsupported params are silently dropped— e.g. kimi-k3 does not supporttemperature; sending it is always safe.
- Attribution headers— optionalapp_nameX-Title,site_urlHTTP-Referer.

- Rust (edition 2024)
- An OpenRouter API key fromopenrouter.ai/settings/keyswith credits

The server expects a config file at~/.config/mcp-server-open-router/config.tomlcontaining at minimum yourapi_key. Seeconfig.toml.example.

api_key = "sk-or-..." # Optional overrides: # base_url = "https://openrouter.ai/api/v1" # default_model = "moonshotai/kimi-k3" # default_max_tokens = 8192 # app_name = "mcp-server-open-router" # site_url = "https://example.com"

The server fails fast at startup if the config is missing orapi_keyis empty.

cargo build --release # produces target/release/open-router cargo build # debug build cargo run # run in dev mode RUST_LOG=debug cargo run cargo test # unit tests (Display formatter, builders, mockito round-trips)
cargo build --release # The binary will be at: target/release/open-router

Use thefull absolute pathtotarget/release/open-routerin all configuration below.

2. AI-assisted installation (recommended modern method)

Copy the block below and paste it directly to your AI coding assistant (Claude Code, Cursor, Grok, etc.). The AI will handle cloning (if needed), building, path resolution, and registration for you.

Add the mcp-server-open-router MCP server for me. Repository: https://github.com/<your-username>/mcp-server-open-router (update this URL if you have a fork) Steps to perform: 1. If the repo isn't cloned locally yet, clone it and cd into it. 2. Build the release binary: cargo build --release 3. Determine the absolute path to the built binary (target/release/open-router). 4. Set up the config directory and file: mkdir -p ~/.config/mcp-server-open-router cp config.toml.example ~/.config/mcp-server-open-router/config.toml Then edit the config and add your OpenRouter API key (api_key = "sk-or-..."). 5. Register it as an MCP server named "open-router". For Claude Code, run: claude mcp add open-router -- <ABSOLUTE_PATH_TO>/target/release/open-router For Claude Desktop or other MCP clients, add this under the "mcpServers" key (use the real absolute path): { "open-router": { "command": "<ABSOLUTE_PATH_TO>/target/release/open-router" } } After setup, test that the chat and credits tools are available and working.

Claude Desktop or any MCP client (~/.config/Claude/claude_desktop_config.jsonor equivalent):

{ "mcpServers": { "open-router": { "command": "/media/codechap/4TB/develop/mcps/mcp-server-open-router/target/release/open-router" } } }
claude mcp add open-router -- /media/codechap/4TB/develop/mcps/mcp-server-open-router/target/release/open-router

Replace the path with your actual absolute path to the release binary.

Once registered, an MCP client calls the tools by name.

Use the open-routerchattool. prompt: "Reply with exactly OK". max_tokens: 10

{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{ "name":"chat", "arguments":{ "prompt":"Reply with exactly OK", "max_tokens":10 }}}

Every successful chat response ends with token-usage and actual-cost footers:

OK [finish_reason: stop] [model: moonshotai/kimi-k3 via Moonshot AI] [tokens: 812 prompt + 431 completion = 1243 total; 640 cached; 210 reasoning] [cost: $0.008901]

The cost line is OpenRouter-reported USD (because every request opts intousage.include), not an estimate from pricing constants.

src/ main.rs - entry point, config loading, stdio transport setup server.rs - MCP tools (chat, chat_with_vision, chat_with_search, list_models, credits) + helpers api.rs - OpenRouter HTTP client, request/response types, Display formatter params.rs - tool parameter types with serde + JSON Schema derives config.rs - TOML config loading

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

Access 30+ AI models in Claude Code with zero API keys. One wallet, pay-per-request.

Remote Streamable HTTP MCP gateway for GPT-5.5 chat plus 92 text, web, JSON, and x402 discovery tools with Base USDC pay-per-call.

Deploy and serve Haystack pipelines as REST APIs, MCP Tools, and OpenAI-compatible chat completion backends.

JCode Harness Cloud is a paid remote MCP endpoint for OpenAI Codex harness MCP. It exposes structured JSON tools, a public server card, token-based access, usage receipts, and audit-ready wo

Provides educational content, model information, and read-only API interactions for Lerian developers.

A command-line interface wrapper for the Google Gemini API, enabling interaction with Gemini's Search and Chat tools.

A backend service providing tools, resources, and prompts for AI models using the Model Context Protocol (MCP).

A bridge API service connecting Ollama with Model Context Protocol (MCP) servers.

An MCP client for Cursor that uses OpenRouter.ai to access multiple AI models. Requires an OpenRouter API key.

Browse 160+ LLM models with live pricing (no API key needed) and route chat completions through the OrcaRouter gateway.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.