Connect an MCP server to clients
All file-based clients share the mcpServers shape. What differs is the file location, the type field, the variable syntax, and a few Windows quirks. Ready-made configs for Cursor, Claude Code, and Claude Desktop are on the templates page.
Paths: use absolute paths to your server, written with forward slashes (
C:/Projects/notes-server/build/index.js). In JSON, backslashes must be doubled (C:\\Projects\\...), so forward slashes avoid mistakes.
Cursor
Section titled “Cursor”Files: .cursor/mcp.json (project, commit it for the team) or ~/.cursor/mcp.json (global). If the same server name appears in both, the project file is expected to win, but this isn’t in Cursor’s docs, so avoid duplicate names.
{ "mcpServers": { "notes": { "type": "stdio", "command": "node", "args": ["C:/Projects/notes-server/build/index.js"], "env": { "NOTES_FILE": "${userHome}/.notes-mcp.json" } }, "internal-api": { "type": "stdio", "command": "npx", "args": ["-y", "@acme/internal-mcp"], "envFile": "${workspaceFolder}/.env" }, "remote-example": { "url": "https://mcp.example.com/mcp", "headers": { "Authorization": "Bearer ${env:EXAMPLE_TOKEN}" } } }}"type": "stdio": Cursor’s docs mark it as required for local (stdio) servers. Remote servers useurlinstead.- Variables:
${env:NAME},${userHome},${workspaceFolder},${workspaceFolderBasename}, and${pathSeparator}. This syntax is Cursor-only; Claude Code uses${NAME}(see below). envFileworks for stdio servers only.- OAuth: remote servers that support OAuth prompt you to sign in. For static OAuth, add an
authobject withCLIENT_ID,CLIENT_SECRET, andscopes. - Manage: at the time of writing, servers are listed under Customize → MCPs, where you can toggle them and see their tools, and individual tools can be toggled from the chat tools list. These menus aren’t in Cursor’s docs, so check there if they’ve moved.
- Logs: Output panel (Ctrl+Shift+U on Windows and Linux, Cmd+Shift+U on macOS) → “MCP Logs”.
- Verify: The server shows a green dot and lists its tools. Asking a question that needs a tool triggers an approval prompt, or runs it directly if the tool is allowlisted.
Claude Code
Section titled “Claude Code”Add from the CLI, the recommended way:
# local stdio server (scope: local = just you, this project — the default)claude mcp add notes -- node C:/Projects/notes-server/build/index.js
# with env varsclaude mcp add notes -e NOTES_FILE=C:/Users/me/.notes-mcp.json -- node C:/Projects/notes-server/build/index.js
# remote HTTP serverclaude mcp add --transport http example https://mcp.example.com/mcp
# share with the team via .mcp.json in the repo rootclaude mcp add --scope project notes -- node ./tools/notes-server/build/index.js
# available in all your projectsclaude mcp add --scope user notes -- node C:/Projects/notes-server/build/index.js
claude mcp list # check statusclaude mcp get notes # detailsclaude mcp remove notes.mcp.json (project scope, committed):
{ "mcpServers": { "notes": { "command": "node", "args": ["./tools/notes-server/build/index.js"], "env": { "NOTES_FILE": "${NOTES_FILE:-./notes.json}" } }, "remote-example": { "type": "http", "url": "https://mcp.example.com/mcp", "headers": { "Authorization": "Bearer ${EXAMPLE_TOKEN}" } } }}- Remote entries need
"type": "http"in.mcp.json, next tourl. SSE ("type": "sse") is deprecated in favour of HTTP. - Variables in
.mcp.json:${NAME}and${NAME:-default}. Cursor’s${env:NAME}syntax doesn’t work here. - Windows (native, not WSL): older Claude Code docs said
npx-based servers need a wrapper:claude mcp add my-server -- cmd /c npx -y some-package. It’s no longer in the docs, so try without it first and add it if you get “Connection closed”. - Inside a session:
/mcpshows status (“✔ Connected”) and handles OAuth sign-in.claude mcp listshows the same status from the terminal. - Debug:
claude --debug=mcp. The old--mcp-debugflag has been removed.
Claude Desktop
Section titled “Claude Desktop”Config file: open it from Settings → Developer → Edit Config.
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{ "mcpServers": { "notes": { "command": "node", "args": ["C:/Projects/notes-server/build/index.js"], "env": { "NOTES_FILE": "C:/Users/me/.notes-mcp.json" } } }}- Fully quit and restart Claude Desktop after editing (on Windows, quit it from the system tray).
- Write values literally. Variable interpolation isn’t documented for this file, so don’t rely on
${...}. - One-click install: a
.mcpbbundle can be opened directly (see Security & production). - Logs:
%APPDATA%\Claude\logs\mcp*.log(Windows),~/Library/Logs/Claude/mcp*.log(macOS).
claude.ai (web and mobile)
Section titled “claude.ai (web and mobile)”- claude.ai accepts remote servers only (Streamable HTTP over HTTPS; SSE is legacy). Local stdio servers, like the one built in this guide, can’t be used until you deploy them remotely.
- Customize → Connectors → Add custom connector → enter the server URL. OAuth is supported (see the callback URLs your server must accept).
- On Team and Enterprise plans, only Owners can add custom connectors, under Organization settings.
SDK agents
Section titled “SDK agents”- Claude Agent SDK: pass
mcpServers: { notes: { command, args, env } }inoptions. WhensettingSourcesis omitted, the SDK also loads the project’s.mcp.json(with user, project, and local settings, as the CLI does); passsettingSources: []for reproducible CI and configure servers inline. Either way, allow the MCP tools, for exampleallowedTools: ["mcp__notes__*"]. Without it, the agent sees the tools but can’t call them. - Cursor SDK: pass MCP servers inline on
Agent.create/agent.send, or opt in to.cursor/mcp.jsonvialocal.settingSources. Inline servers aren’t persisted when you resume an agent, so pass them again.
Common connection failures
Section titled “Common connection failures”| Symptom | Cause | Fix |
|---|---|---|
| Red dot / “failed to start” | Wrong path, or node / uv not on PATH for GUI apps |
Use absolute paths, including the absolute path to node.exe if needed |
| Connects then drops immediately | Something writes to stdout | Log to stderr only |
“Connection closed” on Windows with npx |
The Windows shell wrapper may be missing | Claude Code: try cmd /c npx … |
| Tools don’t appear | Server not restarted after a change; build not re-run | Rebuild; toggle the server off and on; restart the host |
| Remote server doesn’t connect in Claude Code | .mcp.json entry has no "type": "http" |
Add "type": "http" |
| Env var not set | Wrong interpolation syntax for that client | Cursor: ${env:NAME}. Claude Code: ${NAME} or ${NAME:-default} |
| OAuth loop | Redirect URI not registered | Register the client’s callback URL on your authorisation server (see Security & production) |
| SDK agent sees tools but never calls them | MCP tools not allowed | Add allowedTools: ["mcp__notes__*"] |
| Too many tools / wrong tool picked | Several servers with overlapping tools | Disable unused servers and tools |