Skip to main content
NeVibe · guide · 2026-10-24

How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more

You add an MCP server with one CLI command or one entry in the agent's JSON or TOML config. Most agents share the mcpServers key. VS Code, Codex and Zed do not, so a config copied blindly from Cursor will silently do nothing there.

What an MCP server is

An MCP server is a program that exposes tools to an agent over the Model Context Protocol: query a database, open a page in a browser, file a GitHub issue. The agent decides when to call a tool; the client (Claude Code, Cursor and so on) asks you for permission.

There are two kinds you will meet. A stdio server runs locally as a process, so the config holds a command and arguments. An HTTP (streamable HTTP) server lives at a URL, so the config holds the URL and auth headers. The third transport, SSE, is marked deprecated in the Claude Code docs.

Ready-made servers are in the MCP servers section and the best MCP servers list.

Commands and config files by agent

Checked against official docs on 2026-10-24.

AgentCommandFileKeyClaude Codeclaude mcp add.mcp.json (project), ~/.claude.json (local and user)mcpServersCodexcodex mcp add~/.codex/config.toml, .codex/config.toml (trusted projects only)[mcp_servers.name] in TOMLCursornone, edit the file.cursor/mcp.json, ~/.cursor/mcp.jsonmcpServersVS Code (Copilot)none, edit the file.vscode/mcp.json or the profile mcp.jsonserversCopilot CLI—~/.copilot/mcp-config.jsonmcpServersGemini CLIgemini mcp add~/.gemini/settings.json, .gemini/settings.jsonmcpServersWindsurf (Devin Desktop)none, edit the file~/.config/devin/mcp_config.jsonmcpServers, URL in serverUrlKironone, edit the file.kiro/settings/mcp.json, ~/.kiro/settings/mcp.jsonmcpServersZedSettings → AI → MCP Servers → Add ServerZed settings.jsoncontext_servers

Sources: Claude Code, Codex, Cursor, VS Code, Gemini CLI, Devin Desktop, Kiro, Zed.

How to add an MCP server to Claude Code

A local stdio server. Everything after -- is the launch command:

claude mcp add --scope project --env API_KEY=... my-server -- npx -y <server-package>

A remote HTTP server:

claude mcp add --transport http my-remote https://example.com/mcp --header "Authorization: Bearer ..."

--scope decides who sees it. The default, local, keeps the server private to you in this project and writes to ~/.claude.json. user enables it in every project. project writes .mcp.json at the repo root; commit that file and the whole team gets the server. If you already have a JSON entry, pass it as is with claude mcp add-json.

Claude Code warns when a tool returns more than 10,000 tokens and caps output at 25,000 by default (MAX_MCP_OUTPUT_TOKENS).

Example mcpServers JSON

A .mcp.json with one local and one remote server. Names and the package are placeholders; treat it as a template:

{
  "mcpServers": {
    "my-server": {
      "command": "npx",
      "args": ["-y", "<server-package>"],
      "env": { "API_KEY": "${API_KEY}" }
    },
    "my-remote": {
      "type": "http",
      "url": "https://example.com/mcp",
      "headers": { "Authorization": "Bearer ${MCP_TOKEN}" }
    }
  }
}

In Claude Code an entry with url but no type is an error, because it gets read as stdio. ${VAR} and ${VAR:-default} expand in command, args, env, url and headers, which keeps tokens out of the repo.

Why an MCP config does not port between agents

  • VS Code expects servers, not mcpServers. It will ignore a file copied from Cursor. A portable .mcp.json at the workspace root only works behind the experimental chat.mcp.workspaceRootConfig.enabled setting.
  • Codex uses TOML: [mcp_servers.name] with command and args, or url and bearer_token_env_var. Startup timeout defaults to 10 seconds, tool calls to 60.
  • Gemini CLI treats url as SSE; streamable HTTP goes in httpUrl. Claude Code uses type: http plus url instead.
  • Devin Desktop reads remote addresses from serverUrl and allows 100 tools in total across all servers.
  • Cursor interpolates with ${env:NAME}, ${userHome} and ${workspaceFolder}, not the Claude Code ${VAR} form.
  • Zed keeps servers under context_servers in its own settings.

If you run two or more agents, generate the configs from one source. rulesync, ruler and block/ai-rules all write MCP entries into each agent's native file. More in the config formats guide.

Security checks before you connect a server

An MCP server runs code on your machine or calls your accounts with your token. So:

  • Claude Code asks for approval before starting project servers from .mcp.json in an interactive session; leave that on;
  • Cursor asks before each tool call by default;
  • in Gemini CLI, trust: true turns confirmations off entirely, so reserve it for servers you wrote;
  • keep tokens in environment variables, never in a file that goes to git.

An open-source server with an active repo is easier to reason about than a closed binary. Every card in the catalog shows license, stars and last update in its trust passport.

FAQ

How do I add an MCP server to Claude Code?

Run claude mcp add name -- launch-command for a local server, or claude mcp add --transport http name URL for a remote one. Add --scope project to write it into .mcp.json so the whole team gets it.

How do I install an MCP server in VS Code?

Add an entry to .vscode/mcp.json. The top-level key there is servers, not mcpServers, so a config from Cursor or Claude Code needs renaming first.

Where is the MCP config in Cursor?

In .cursor/mcp.json for one project and ~/.cursor/mcp.json for all projects. It uses the mcpServers key like Claude Code, but variables are written as ${env:NAME}.

What is the difference between a stdio and an HTTP MCP server?

A stdio server runs locally as a process and the config holds the command. An HTTP server lives at a URL and the config holds the URL and auth headers. Claude Code marks the older SSE transport as deprecated.

Can I reuse one MCP config across agents?

Partly. Claude Code, Cursor, Kiro, Windsurf and Gemini CLI read mcpServers, with differences in the URL field. VS Code, Codex and Zed need conversion, which rulesync, ruler and block/ai-rules handle.

NeVibe catalog

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor