How to Set Up MCP Servers in Cursor (Step-by-Step)

Connect Cursor to external tools with MCP servers. Complete Cursor MCP setup guide with .cursor/mcp.json configuration, the MCP UI, troubleshooting, and security best practices.

August 10, 2026
implementationguidesetupCursorMCPmcp.json

Prerequisites

  • Cursor IDE (any recent version)
  • Node.js 18+ or Docker (for npx- and Docker-based servers)
  • Basic familiarity with JSON configuration

What is MCP?

MCP (Model Context Protocol) lets Cursor's AI connect to external tools, databases, and services through a standard interface. An MCP server exposes tools — like "search the filesystem" or "query Postgres" — that Cursor's Agent can call on demand.

Enabling MCP in Cursor

MCP support is enabled by default in Cursor. You add servers two ways:

  1. Project-level — a .cursor/mcp.json file committed to your repo
  2. Global — via the Cursor MCP UI (Settings → MCP), applied across all projects

Method 1: Project Configuration (.cursor/mcp.json)

Create .cursor/mcp.json at your project root:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "./"],
      "env": {}
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_TOKEN": "${GITHUB_TOKEN}"
      }
    },
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost:5432/mydb"],
      "env": {}
    }
  }
}

Each server entry has three fields:

FieldPurpose
commandThe executable to launch (e.g. npx, docker, or a local binary)
argsArguments passed to the command
envEnvironment variables, including API keys

Using "${VAR_NAME}" in env makes Cursor resolve the value from your shell environment — keep secrets out of the committed file.

Method 2: Global Configuration (MCP UI)

For servers you want in every project:

  1. Open Cursor Settings → MCP
  2. Click Add New Server
  3. Choose an option: an npm package, a local path, a Docker container, or an HTTP endpoint
  4. Cursor fills in the command for common picks; adjust and save

Servers added here appear in every project and are shown as connected when running.

Verifying Your Servers

After adding a server:

  1. Open the Agent view (or invoke Agent mode)
  2. Check the MCP servers panel — your servers should show as connected
  3. Ask the Agent to use a tool from the server, e.g. "search the filesystem for README files" or "run a GitHub search"

If a server fails to connect, it will be flagged in the MCP panel with the error. See Troubleshooting below.

Using MCP Tools in Cursor

Once connected, Cursor's Agent can call the server's tools like any built-in tool:

You: "Query the postgres server and list the last 10 orders."

Agent: [calls mcp__postgres with a SQL query, prints results]

Server tools are namespaced by server name (mcp__<server>__<tool>), which keeps collisions between servers from breaking each other.

Security Considerations

  • Least privilege — only give servers the credentials they need. A read-only server should not hold write credentials.
  • Keep secrets out of git — use ${VAR_NAME} environment interpolation or a .cursor/mcp.json that's gitignored for private keys.
  • Review before you trust — MCP servers run arbitrary commands on your machine. Only add servers from sources you trust, and review what tools they expose.
  • Scoped servers — prefer project-level config over global when a server is only relevant to one codebase.

Troubleshooting

Further Resources