Build
Use MCP servers with your coding tools
MCP servers run in your coding tool, not on the gateway. How to add one in Claude Code, Codex CLI, OpenCode, Cline, Cursor, Kilo Code and Zed, and the cost.
On this page
The Model Context Protocol (MCP) lets a coding tool connect to extra tools and data: a file system, a database, an issue tracker, a browser. MCP servers run inside your coding tool, on your machine or at a URL you choose. Relaykit does not run or host MCP servers. The gateway only sees the model requests your tool sends, so any MCP server that works in your tool works the same way when the model runs through Relaykit.
How it fits together
- Your coding tool starts or connects to the MCP servers in its config and reads the list of tools they offer.
- With each model request, the tool sends those tool definitions along with your conversation, through the gateway, to the model.
- When the model asks to call a tool, your coding tool runs it through the MCP server and sends the result back in the next request.
To the gateway, this is ordinary tool calling. Two things follow from that:
- The model must support tool calling. Pick a model with the Tools capability on the models page.
- Tool definitions and tool results are input tokens. They are billed at the model’s input rate on every request, and they reach the model’s provider like the rest of the conversation. A server with dozens of tools adds thousands of tokens to each turn. Prompt caching lowers the cost of the repeated part.
The examples below add the reference filesystem server, which needs Node.js for npx. Replace /path/to/project with the folder it may read and write. https://example.com/mcp stands for any remote server you use. Set up the tool for Relaykit first with its guide.
Claude Code
Set up: Claude Code guide. Add servers with claude mcp add. They are saved for you in the current project by default; add --scope project to write a shared .mcp.json in the project, or --scope user to use the server in every project.
# A local server (stdio): everything after -- is the command that starts it
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/project
# A remote server (Streamable HTTP)
claude mcp add --transport http docs https://example.com/mcp
# Check what is configured
claude mcp list{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"],
"env": {}
}
}
}Inside Claude Code, /mcp shows each server’s status. On native Windows (not WSL), wrap npx servers as cmd /c npx ....
Claude Code warns when one tool result exceeds 10,000 tokens and cuts it at 25,000 by default (MAX_MCP_OUTPUT_TOKENS). Official docs: Claude Code MCP.
Codex CLI
Set up: Codex CLI guide. Add a server from the terminal, or write it into ~/.codex/config.toml next to your provider settings.
codex mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/project
codex mcp list# A local server (stdio)
[mcp_servers.filesystem]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"]
# A remote server; the token is read from an environment variable
[mcp_servers.docs]
url = "https://example.com/mcp"
bearer_token_env_var = "DOCS_MCP_TOKEN"In the Codex interface, /mcp lists the connected servers. Official docs: Codex MCP.
OpenCode
Set up: OpenCode guide. Add an mcp block to the same opencode.json that holds your provider. {env:NAME} reads an environment variable.
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"filesystem": {
"type": "local",
"command": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"],
"enabled": true
},
"docs": {
"type": "remote",
"url": "https://example.com/mcp",
"headers": { "Authorization": "Bearer {env:DOCS_MCP_TOKEN}" }
}
}
}Check with opencode mcp list. Official docs: OpenCode MCP servers.
Cline
Set up: Cline guide. In the Cline panel, open the MCP Servers icon, then Configure and Configure MCP Servers. This opens cline_mcp_settings.json. Remote servers need "type": "streamableHttp"; without it Cline uses the older SSE transport.
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"],
"disabled": false,
"autoApprove": []
},
"docs": {
"type": "streamableHttp",
"url": "https://example.com/mcp"
}
}
}autoApprove lists tools Cline may run without asking. Leave it empty until you trust a server. Official docs: Cline MCP overview.
Cursor
Set up: Cursor guide. Put servers in .cursor/mcp.json in a project, or in ~/.cursor/mcp.json for every project. ${env:NAME} reads an environment variable.
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"]
},
"docs": {
"url": "https://example.com/mcp",
"headers": { "Authorization": "Bearer ${env:DOCS_MCP_TOKEN}" }
}
}
}MCP tools are used in Agent chats. Requests use your Relaykit key only with the models you added under your own key; the Cursor guide explains which Cursor features use Cursor’s own infrastructure instead. Official docs: Cursor MCP.
Kilo Code
Set up: Kilo Code guide. In VS Code, open Kilo Code’s Settings, then MCP and Add Server. The CLI reads ~/.config/kilo/kilo.jsonc, or kilo.jsonc in a project. Remote servers use the same type: "remote" form as OpenCode.
{
"mcp": {
"filesystem": {
"type": "local",
"command": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"],
"enabled": true
}
}
}Official docs: Kilo Code MCP.
Zed
Set up: Zed guide. Add servers under context_servers in Zed’s settings.json. Remote servers take url and optional headers instead of command.
{
"context_servers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"],
"env": {}
}
}
}Under Settings, AI, MCP Servers, a green dot means the server is running. Official docs: Zed MCP.
Aider
Aider has no built-in MCP support. It is an open feature request. Use one of the tools above if you need MCP.
Troubleshooting
- The server does not start. Run its command in a terminal yourself. Most failures are a missing Node.js or Python, a wrong path, or a missing environment variable. The gateway is not involved at this stage.
- The tools are listed but the model never uses them. Check that the model has the Tools capability on the models page, and ask for the tool by name once to test.
- Requests got expensive. Every connected tool’s definition is sent with each request. Disconnect servers you are not using and check the input tokens per request on the usage page.
400about context length. Long tool results build up in the conversation. Start a new session, or ask for smaller results (one file, not a folder).401or403. These come from your key or model list, not from MCP. See Errors.
Related
- Tool calling: the request format behind every MCP tool call.
- Coding tools overview: set up each tool for Relaykit.
- Cost control: spend limits for keys used by agents.