MCP Servers
Bridge MCP tool ecosystems into TheRouter.ai traffic
MCP is stateful and powerful for tool access. TheRouter.ai can power the model side while your MCP client orchestrates tool sessions.
Overview
This page mirrors the OpenRouter workflow and adapts it for TheRouter.ai. Use TheRouter.ai as your OpenAI-compatible endpoint and keep model IDs in `provider/model` format.
Installation
Install the required SDKs and keep your TheRouter.ai key in environment variables.
install.sh
pip install mcp openai python-dotenvConfiguration
Set TheRouter.ai base URL overrides and pass your API key. Add attribution headers when your app should appear in rankings.
TypeScript
const openai = new OpenAI({ baseURL: "https://api.therouter.ai/v1", apiKey: process.env.THEROUTER_API_KEY });Caveats
Integration note
MCP servers require session lifecycle management. Handle reconnects, retries, and tool timeouts explicitly.
For production rollouts, pin SDK versions and validate model compatibility in staging before broad rollout.