How to set up MCP servers in Claude Code, Claude Desktop and Cursor
An MCP server is a small program that gives your AI assistant a new ability, such as reading files, looking up documentation, or driving a browser. Each app needs to be told which servers to run. This guide shows where that setting lives in each app and how to check it worked.
Short on time? Use the free config builder. Tick the servers you want and it writes the JSON for you. Not sure which to pick? See the servers worth installing first.
What the config looks like
All three apps use the same shape: a list of named servers, each with a command to run and its arguments.
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"]
}
}
}
Many servers need Node.js installed, because npx comes with it. Some use uvx, which comes with uv.
Claude Code
You can add a server with one command:
claude mcp add context7 -- npx -y @upstash/context7-mcp
Everything after the -- is the command that starts the server. To pass a secret such as an API key, use --env KEY=value, and put another option such as --transport stdio between it and the server name.
Where it gets saved
- Local (the default): only in the current project, private to you.
- Project: a
.mcp.jsonfile in your project root, which you can commit so your team shares it. Claude Code asks you to approve it the first time. - User: available in all your projects.
Check it worked
claude mcp list
This shows each server and whether it connected.
Claude Desktop
- Open the Claude menu, choose Settings, then the Developer tab, then Edit Config.
- Add your servers under
mcpServers. The file is%APPDATA%\Claude\claude_desktop_config.jsonon Windows and~/Library/Application Support/Claude/claude_desktop_config.jsonon macOS. - Fully quit and restart Claude Desktop. Closing the window isn't enough.
Use absolute paths for any folders you give a server, not relative ones. If a server doesn't show up, the logs are in %APPDATA%\Claude\logs (Windows) or ~/Library/Logs/Claude (macOS).
Cursor
- For one project: create
.cursor/mcp.jsonin the project. - For every project: create
~/.cursor/mcp.jsonin your home directory.
If a server won't start
- Run the command yourself in a terminal (for example
npx -y @upstash/context7-mcp). If it prints an error, that's your answer. - Check Node.js is installed:
node --version. - "Connection closed" usually means the server process exited right after starting. The terminal test above shows why. Full troubleshooting guide.
- Windows: we tested plain
npxwith Claude Code 2.1.278 on native Windows and it connected fine. Some older setups have reported needing"command": "cmd"with"/c", "npx", ...at the start of the arguments. Try that only if the steps above don't help.
Stay safe
MCP servers run on your computer with your user's permissions. Only install servers from authors you trust, give file servers access to specific folders rather than your whole drive, and be careful with servers that fetch content from the web, since that content can try to steer the AI.