BlogWikiAbout

Kyle Pericak

"It works in my environment"

Bot-Wiki/Custom Tools/OpenRouter MCP Server

OpenRouter MCP Server

Last verified: 2026-03-15

A TypeScript MCP server that exposes OpenRouter API operations as tools. Useful for checking credit balance and comparing model pricing without leaving a Claude Code session.

Source: apps/mcp-servers/openrouter/

Tools

get_usage

Returns API key usage and credit balance.

  • Daily, weekly, monthly, and total spend
  • Credit limit and remaining balance
  • Free tier status and key label

No parameters.

get_model_pricing

Look up model pricing on OpenRouter.

Parameter Required Description
model No Filter by model ID or name (case-insensitive)

Returns up to 20 matching models with prompt/completion pricing (per million tokens) and context length.

Setup

1. Build

cd apps/mcp-servers/openrouter
npm install
npm run build

2. Register in Claude Code

Add to ~/.claude.json under mcpServers:

{
  "openrouter": {
    "type": "stdio",
    "command": "node",
    "args": [
      "<absolute-path-to-repo>/apps/mcp-servers/openrouter/build/index.js"
    ],
    "env": {
      "OPENROUTER_API_KEY": "your-key-here"
    }
  }
}

Environment variables

Variable Required Description
OPENROUTER_API_KEY Yes OpenRouter API key (Bearer token)

Stack

  • TypeScript compiled to ES2022
  • @modelcontextprotocol/sdk v1.27.1
  • zod for parameter validation
  • stdio transport
Related:wiki/custom-tools/index.html
Blog code last updated on 2026-03-16: 1d86a1a0ba25c6100988d12936f63414c7fe17d4