How to add an MCP server to Claude Desktop and Cursor
Both Claude Desktop and Cursor read MCP servers from a JSON file with an mcpServers object. Here's where the files are and what goes in them.
Claude Desktop#
The config file is claude_desktop_config.json:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
A local server started with npx, adapted from the MCP docs' filesystem server example:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/username/Desktop"]
}
}
}Fully quit and restart Claude Desktop after editing the file. If a server doesn't show up, the MCP logs are in ~/Library/Logs/Claude/mcp*.log on macOS.
Cursor#
- Project only:
.cursor/mcp.jsonin the project folder - All projects:
~/.cursor/mcp.json
{
"mcpServers": {
"my-api": {
"command": "node",
"args": ["${workspaceFolder}/mcp-server/index.js"],
"env": { "MY_API_KEY": "${env:MY_API_KEY}" }
}
}
}Cursor resolves variables such as ${env:NAME}, ${userHome} and ${workspaceFolder} in command, args, env, url and headers. Remote servers use a url instead of a command.
Keep keys out of the file#
A project .cursor/mcp.json is often committed to git. Reference environment variables (as above) rather than pasting API keys, and add any local-only config to .gitignore. The same applies to tool arguments: credentials belong in the server's environment, not in parameters the model fills in. The linter flags credential-looking parameters.
Only run servers you trust#
A local MCP server is a program running with your permissions. The spec's security guidance warns about malicious startup commands in client configs and malicious server packages. Check where a server comes from before adding it, and see MCP security best practices.