How to install

How to add and use MCP servers in Cursor

Where Cursor's mcp.json lives, the JSON for local and hosted servers, how to keep API keys out of the file, and where to turn servers on and off.

2 min read · Updated

Cursor MCP setup takes one file. Once a server is in it, you use it by asking Cursor's agent for the job in plain words. Cursor reads MCP servers from a file called mcp.json. There are two places it can live:

  • .cursor/mcp.json inside your project, for servers that project needs
  • ~/.cursor/mcp.json in your home folder, for servers you want in every project

Both use the same format. If the file is not there yet, create it.

Add a server that runs on your machine

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@playwright/mcp@latest"]
    }
  }
}

The key, playwright here, is the name Cursor shows for the server. command is the program that starts it, and args holds the rest of the command, one item per word.

To add a second server, add another entry inside mcpServers. Put a comma between entries. One missing comma breaks the whole file, and then none of your servers load.

Add a hosted server

A hosted server needs a url and nothing else:

{
  "mcpServers": {
    "sentry": {
      "url": "https://mcp.sentry.dev/mcp"
    }
  }
}

Cursor supports sign-in for hosted servers, so most of them open a browser login the first time. If a server wants a token instead, add it under headers.

Keep API keys out of the file

Cursor replaces ${env:NAME} with the value of the environment variable NAME. Use it for every key:

{
  "mcpServers": {
    "firecrawl": {
      "command": "npx",
      "args": ["-y", "firecrawl-mcp"],
      "env": {
        "FIRECRAWL_API_KEY": "${env:FIRECRAWL_API_KEY}"
      }
    }
  }
}

Now the file holds no secrets and is safe to commit. Headers work the same way: "Authorization": "Bearer ${env:MY_TOKEN}".

Servers that run on your machine can also read keys from a .env file. Add "envFile": "${workspaceFolder}/.env" next to command, and keep .env out of Git.

Turn servers on and off

Open Customize in Cursor's sidebar to see your servers. Each one has a toggle, so you can switch off a server you are not using without deleting its config.

If a server fails to start, open the Output panel and pick MCP Logs from the dropdown. The error there usually names the problem, like a missing key or a command that is not installed.

Approving tool calls

By default Cursor asks before the agent uses an MCP tool. Read the request before you approve it, especially for tools that change things, like a database tool that runs SQL or a GitHub tool that opens pull requests. Cursor's run modes can let tools you have allowlisted run without asking. Keep that list to tools that only read.

Servers worth adding

Each of these has a Cursor tab on its page with the JSON ready to paste: