In short.
Using MCP Servers with OpenRouter is a practical guide for developers connecting AI agents to tools, but its full example requires Python and careful handling of a stateful MCP session. The client launches a local filesystem server, discovers its tools, converts their definitions for the Responses API and returns tool results to the model. TypeScript and Go snippets cover setup and conversion only. Dependency versions, monetary costs and reuse permissions are unspecified, and runtime compatibility is unassessed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete captured page at [https://openrouter.ai/docs/cookbook/coding-agents/mcp-servers.md]: its documentation-index notice, TypeScript package recommendation, session-management warning, language-specific snippets, Python client and sample transcript. Linked documentation, repositories and packages are excluded. No code was executed, dependencies installed or API requests made. Runtime compatibility, actual filesystem behavior, costs and redistribution permissions remain unassessed or unknown.
The overview
Identity
Using MCP Servers with OpenRouter is an OpenRouter documentation guide at [https://openrouter.ai/docs/cookbook/coding-agents/mcp-servers.md]. It teaches an integration pattern using the MCP Python client SDK, the OpenAI Python SDK pointed at OpenRouter, and a local filesystem MCP server.
The resource is a tutorial with embedded code and a sample conversation. Its main implementation is a Python command-line client; the TypeScript and Go examples cover only setup and tool-definition conversion.
Assessment
The guide's main value is making the integration visible: it shows server initialization, tool discovery, schema conversion, model requests and tool-result handling in one client. This helps developers understand which responsibilities belong to their application.
The example leaves substantial application engineering to the developer, including dependency compatibility, approval for filesystem changes and more complete output handling. Successful execution, reliability and production suitability are unassessed.
Users
The guide suits developers who understand Python, asynchronous code, environment variables and command-line programs. Beginners can follow the overall tool-use cycle, but the page does not explain these prerequisites in depth.
Experienced developers can use the implementation to inspect the boundary between MCP sessions and model function calls. TypeScript and Go developers will need additional material to build a complete client in those languages.
Capabilities
The Python code is designed to start a local MCP server over standard input and output, initialize its session, discover available tools and expose those tools to an OpenRouter-backed model. It keeps conversation history across queries and handles multiple function calls returned in one model response.
The filesystem configuration grants access to /Applications/. The sample tool listing includes reading and writing functions, while the illustrated task searches for Microsoft applications. Other MCP servers would require configuration changes; compatibility with them is not demonstrated.
Using it
Requirements
The example requires Python and libraries providing the mcp, openai and dotenv imports. It also requires npx to launch @modelcontextprotocol/server-filesystem, an OpenRouter API credential available as OPENAI_API_KEY, and an existing /Applications directory with suitable access.
The model identifier is ~anthropic/claude-sonnet-latest, and the API base address is [https://openrouter.ai/api/v1]. Required runtime versions, package versions and supported compatibility ranges are not specified.
Mechanism
MCP provides a session through which the application discovers and invokes tools. The converter turns each discovered tool into a Responses API function definition using its name, description, input properties and required fields.
The client sends those definitions and conversation history to OpenRouter. For each returned function_call, it parses the arguments, invokes session.call_tool and appends a function_call_output with the matching call_id. This gives the next model request the result of each requested action.
The loop returns text when no function calls remain and raises an error after ten iterations. Each model request sets max_output_tokens to 1000. AsyncExitStack manages cleanup of the MCP session and transport.
Setup
The documented setup is to install the required Python packages, create a .env file containing OPENAI_API_KEY, assemble the Python snippets into mcp-client.py and launch it with python mcp-client.py. The page does not provide a pinned dependency list.
SERVER_CONFIG launches npx with -y, @modelcontextprotocol/server-filesystem and /Applications/. Developers using another directory must adjust that configuration. The API credential uses the environment-variable name expected by the OpenAI SDK even though the configured endpoint is OpenRouter.
Example
The sample conversation asks whether Microsoft Office is installed. The transcript depicts checking allowed directories and searching /Applications for Microsoft, then reports Excel, PowerPoint, Word and OneDrive application bundles. These are illustrative documentation results, not findings about the reader's computer.
The transcript includes user messages saying continue between steps, while the displayed implementation contains an automatic tool-call loop. The page does not explain this difference, so the transcript should not be treated as an exact execution trace of the displayed code.
Assessment & evidence
Limitations
The schema converter preserves properties and required fields but omits other top-level input-schema fields. Tools depending on omitted constraints or schema definitions may need a more complete converter; their compatibility is unassessed.
Tool results are reduced to text content. Images and other non-text content are not forwarded by this implementation. Exceptions from tool invocation produce a generic failure message, and the code does not explicitly inspect MCP error flags.
Model-requested tools are invoked without a confirmation step, although the filesystem tool listing includes write_file. Query history and returned tool text become input to the remote model. The displayed chat loop also advertises quit without implementing a condition that exits on that command.
Reasoning
The useful design idea is the bridge between two interfaces: MCP handles tool discovery and execution, while OpenRouter receives function definitions and corresponding results. Keeping that bridge explicit makes the guide useful for learning and adapting a small local agent.
The hard-coded filesystem configuration, partial schema conversion and direct execution of model requests make further engineering necessary before using the pattern with valuable files or unattended workloads. This assessment follows from the displayed code; it does not establish runtime behavior.
Alternatives
For TypeScript agents, the page points to @openrouter/mcp at [https://openrouter.ai/docs/agent-sdk/call-model/mcp-tools]. It describes the package as connecting to a remote MCP server, authenticating and returning tools for callModel. Its detailed requirements, limitations and costs are not established by this page.
The page also identifies OpenAI-compatible tool calling as another route to providing model tools. It supplies no comparative performance or reliability evidence for choosing between that approach and an MCP integration.
Evidence
The evidence consists of the complete documentation page at [https://openrouter.ai/docs/cookbook/coding-agents/mcp-servers.md], captured on 2026-11-24 at 17:24:25.227 UTC. Its source revision is sha256:9fbfe23bba113f54c5684d0dcb7de453b6dcd79d2bb050d3ff2c1e5265007a32.
The page supplies setup snippets, three language variants of the converter, a Python client and an illustrative terminal transcript. These support inspection of the documented design. They do not establish installation success, measured performance or independently reproduced results.
Access & freshness
Costs
The page provides no model prices, free allowances, per-task estimates or other monetary charges. The cost of reproducing the example is unknown.
The 1000-output-token setting applies to each model request, and the ten-iteration ceiling limits the loop. Neither establishes a monetary budget. The code also retains conversation history and sends it with subsequent requests.
Rights
The supplied page contains no licence statement or explicit redistribution permission for its prose or code. Reuse and redistribution permissions are therefore unknown from this evidence.
Licences for the referenced SDKs and filesystem server, and terms governing API use, are not included on this page.
Freshness
The capture date establishes when this page snapshot was obtained, not when its examples were last updated. No publication date, update date or compatibility matrix appears in the supplied text.
The model uses a latest alias, the filesystem server command specifies no package version, and SDK versions are absent. The example therefore does not identify a fixed combination of dependencies. Current compatibility and maintenance status are unknown.
Actions
Before attempting the example, confirm dependency compatibility, model availability and API pricing. Replace the hard-coded directory deliberately and begin with disposable files, since the client can execute filesystem tools and send their text results to a remote model.
For an application, preserve the schema features its tools require, handle needed non-text results, add confirmation for file changes and implement the advertised quit behavior. Set explicit limits for conversation history and spending. TypeScript developers can investigate the linked @openrouter/mcp documentation for its separate transport and authentication requirements.
