Skip to navigation
DocsMCP servers

Build

Use MCP servers with your coding tools

In short: MCP servers are programs your coding tool runs, not the gateway; this page shows how to add one in seven tools and what tool definitions cost in tokens.

Updated View .md
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. One AI API Key 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 One AI API Key.

Can I run MCP servers through this gateway?

Yes, optionally: the gateway can proxy a remote MCP server so that its credential stays on the gateway. To keep the MCP credential on the gateway and limit which keys may call which tools, add the server under Settings → MCP servers: a name, a public https:// address, the tool names to allow, and the API keys allowed to use it. Each server gets one endpoint:

POST https://api.oneaiapikey.com/mcp/<server id> with Authorization: Bearer <key> and the JSON-RPC body.

  • Only the listed tools are forwarded; a tools/call for any other name is refused before the server is contacted.
  • initialize, tools/list and later protocol methods pass through. Only POST (Streamable HTTP) is proxied; a server-initiated GET/SSE stream is not.
  • The address must be public HTTPS and redirects are refused. Requests time out after 30 seconds; bodies are capped at 1 MB and replies at 2 MB. An account can register five servers, each with up to 50 tools and 50 keys.

Point your tool at that endpoint instead of the server’s own URL.

How does MCP fit together with the gateway?

MCP works with the gateway through your coding tool, which runs the servers and sends the model their tool definitions and results:

  1. Your coding tool starts or connects to the MCP servers in its config and reads the list of tools they offer.
  2. With each model request, the tool sends those tool definitions along with your conversation, through the gateway, to the model.
  3. 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 One AI API Key first with its guide.

How do I add an MCP server in Claude Code?

You add an MCP server in Claude Code with claude mcp add. Set up: Claude Code guide. Servers 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.

Terminal
# 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
.mcp.json (project scope)
{
  "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.

How do I add an MCP server in Codex CLI?

You add an MCP server in Codex CLI from the terminal with codex mcp add, or by writing it into ~/.codex/config.toml next to your provider settings. Set up: Codex CLI guide.

Terminal
codex mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/project
codex mcp list
~/.codex/config.toml
# 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.

How do I add an MCP server in OpenCode?

You add an MCP server in OpenCode with an mcp block in opencode.json. Set up: OpenCode guide. Add the block to the same opencode.json that holds your provider. {env:NAME} reads an environment variable.

opencode.json
{
  "$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.

How do I add an MCP server in Cline?

You add an MCP server in Cline by editing cline_mcp_settings.json from the MCP Servers panel. 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.

cline_mcp_settings.json
{
  "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 configuration.

How do I add an MCP server in Cursor?

You add an MCP server in Cursor by listing it in an mcp.json file. 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.

.cursor/mcp.json
{
  "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 One AI API Key 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.

How do I add an MCP server in Kilo Code?

You add an MCP server in Kilo Code from its MCP settings in VS Code, or in kilo.jsonc for the CLI. 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.

kilo.jsonc
{
  "mcp": {
    "filesystem": {
      "type": "local",
      "command": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"],
      "enabled": true
    }
  }
}

Official docs: Kilo Code MCP.

How do I add an MCP server in Zed?

You add an MCP server in Zed under context_servers in settings.json. Set up: Zed guide. Add servers under context_servers in Zed’s settings.json. Remote servers take url and optional headers instead of command.

settings.json
{
  "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.

Does Aider support MCP?

No. Aider has no built-in MCP support. It is an open feature request. Use one of the tools above if you need MCP.

What if an MCP server does not work?

Most MCP problems start in the server or in your tool’s config, not in the gateway. These are the common causes:

  • 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.
  • 400 about context length. Long tool results build up in the conversation. Start a new session, or ask for smaller results (one file, not a folder).
  • 401 or 403. These come from your key or model list, not from MCP. See Errors.

↑ ↓ moveEnter openEsc close
New accounts$10 credit on sign-up
Claim $10 credit →