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.
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:
- Project-level — a
.cursor/mcp.jsonfile committed to your repo - 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:
| Field | Purpose |
|---|---|
command | The executable to launch (e.g. npx, docker, or a local binary) |
args | Arguments passed to the command |
env | Environment 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:
- Open Cursor Settings → MCP
- Click Add New Server
- Choose an option: an npm package, a local path, a Docker container, or an HTTP endpoint
- 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:
- Open the Agent view (or invoke Agent mode)
- Check the MCP servers panel — your servers should show as connected
- 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.jsonthat'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
- MCP Servers directory — pick servers that match your tools
- MCP Setup in VS Code — the same MCP concepts in VS Code
- MCP Setup in Claude Code — CLI-based MCP configuration
- Cursor Configuration & Rules — .cursorrules and .cursor/rules/
Related Articles & Guides
How to Set Up MCP Servers in GitHub Copilot (Step-by-Step)
Connect GitHub Copilot to external tools with MCP servers. Complete Copilot MCP setup guide covering VS Code mcp.json, Copilot CLI, configuration examples, and troubleshooting.
How to Set Up MCP Servers in Jcode (Step-by-Step)
Connect Jcode to external tools with MCP servers. Complete Jcode MCP setup guide with ~/.jcode/mcp.json and .jcode/mcp.json configuration, importing Claude Code servers, and troubleshooting.
How to Set Up MCP Servers in Antigravity CLI (Step-by-Step)
Connect Antigravity CLI to external tools with MCP servers. Complete setup guide covering agy mcp add/list/remove commands, settings.json configuration, verification, and troubleshooting.