Connect MCP servers to Cursor by creating a .cursor/mcp.json file in your project root (or ~/.cursor/mcp.json globally) with a mcpServers object mapping server names to their command configurations. Restart Cursor after saving, then verify the connection in Cursor Settings under the MCP tab. Cursor supports both stdio and Streamable HTTP transports.
Set Up MCP Servers in Cursor
Cursor has native MCP support that lets AI assistants (Cmd+L chat and Composer agent mode) call tools from any MCP server. Configuration is done through a JSON file that maps server names to their startup commands. Cursor automatically launches the server processes, performs the MCP handshake, and makes tools available to the AI. This tutorial covers both project-level configuration (shared with your team via git) and global configuration (personal servers available across all projects).
Prerequisites
- Cursor installed (version 0.45 or later)
- An MCP server to connect (npm package, local TypeScript/Python server, or Docker image)
- Basic understanding of JSON configuration files
Step-by-step guide
Create the .cursor/mcp.json configuration file
Create the .cursor/mcp.json configuration file
Create a .cursor directory in your project root and add an mcp.json file. This is the project-level configuration — it only applies to this project and can be committed to git so your team shares the same MCP setup. The top-level key is mcpServers, and each entry maps a server name to its command configuration.
1// .cursor/mcp.json2{3 "mcpServers": {4 "filesystem": {5 "command": "npx",6 "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/directory"]7 }8 }9}Expected result: A .cursor/mcp.json file exists in your project with at least one server configured.
Add multiple servers to the configuration
Add multiple servers to the configuration
You can configure multiple MCP servers in a single file. Each server gets a unique name as its key. Cursor launches all configured servers when it opens the project. Common servers include filesystem for file access, GitHub for repository management, and custom servers for your project's specific needs.
1// .cursor/mcp.json with multiple servers2{3 "mcpServers": {4 "filesystem": {5 "command": "npx",6 "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/projects"]7 },8 "github": {9 "command": "docker",10 "args": ["run", "-i", "--rm",11 "-e", "GITHUB_PERSONAL_ACCESS_TOKEN",12 "ghcr.io/github/github-mcp-server"],13 "env": {14 "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"15 }16 },17 "my-custom-server": {18 "command": "npx",19 "args": ["-y", "tsx", "/path/to/my-server/src/index.ts"]20 }21 }22}Expected result: Multiple servers are configured and will all launch when Cursor opens the project.
Pass environment variables to servers
Pass environment variables to servers
Use the env field to pass environment variables (API keys, database URLs, configuration values) to MCP servers. These variables are set in the server's process environment when Cursor launches it. Never hardcode secrets in the args array — always use env.
1{2 "mcpServers": {3 "database": {4 "command": "npx",5 "args": ["-y", "@modelcontextprotocol/server-postgres"],6 "env": {7 "POSTGRES_CONNECTION_STRING": "postgresql://user:pass@localhost:5432/mydb"8 }9 }10 }11}Expected result: The MCP server receives the environment variables and can use them for authentication or configuration.
Set up global MCP configuration
Set up global MCP configuration
For servers you want available across all projects (like filesystem or GitHub), create a global configuration file at ~/.cursor/mcp.json. Global servers are merged with project-level servers. If both files define the same server name, the project-level configuration takes precedence.
1// ~/.cursor/mcp.json (global — available in all projects)2{3 "mcpServers": {4 "filesystem": {5 "command": "npx",6 "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you"]7 },8 "brave-search": {9 "command": "npx",10 "args": ["-y", "@modelcontextprotocol/server-brave-search"],11 "env": {12 "BRAVE_API_KEY": "your-brave-api-key"13 }14 }15 }16}Expected result: Global servers are available in every Cursor project without per-project configuration.
Restart Cursor and verify the connection
Restart Cursor and verify the connection
After creating or editing the MCP configuration, fully restart Cursor (Cmd+Q then reopen, or use the Developer: Reload Window command). Then verify the connection: open Cursor Settings (Cmd+,), navigate to the MCP tab, and check that your servers show a green 'Connected' status. If a server shows red or disconnected, click on it to see error details.
Expected result: Cursor Settings > MCP tab shows all configured servers with green Connected status.
Test MCP tools in Cursor chat
Test MCP tools in Cursor chat
Open a new Cursor chat (Cmd+L) or Composer (Cmd+I) and ask a question that requires an MCP tool. For example, if you connected the filesystem server, ask 'List the files in /path/to/directory'. Cursor will show when it is using an MCP tool and display the tool's response. In Composer agent mode, Cursor can chain multiple MCP tool calls autonomously.
1// Example prompts to test MCP tools in Cursor:2// With filesystem server: "List all TypeScript files in /Users/you/project/src"3// With GitHub server: "Show me the open issues on my-org/my-repo"4// With custom server: "Get the weather in Tokyo"Expected result: Cursor uses MCP tools to answer your question, showing the tool call and response in the chat.
Complete working example
1{2 "mcpServers": {3 "filesystem": {4 "command": "npx",5 "args": [6 "-y",7 "@modelcontextprotocol/server-filesystem",8 "/Users/you/projects"9 ]10 },11 "github": {12 "command": "docker",13 "args": [14 "run", "-i", "--rm",15 "-e", "GITHUB_PERSONAL_ACCESS_TOKEN",16 "ghcr.io/github/github-mcp-server"17 ],18 "env": {19 "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"20 }21 },22 "postgres": {23 "command": "npx",24 "args": [25 "-y",26 "@modelcontextprotocol/server-postgres"27 ],28 "env": {29 "POSTGRES_CONNECTION_STRING": "postgresql://user:pass@localhost:5432/mydb"30 }31 },32 "brave-search": {33 "command": "npx",34 "args": [35 "-y",36 "@modelcontextprotocol/server-brave-search"37 ],38 "env": {39 "BRAVE_API_KEY": "your-brave-api-key"40 }41 },42 "memory": {43 "command": "npx",44 "args": [45 "-y",46 "@modelcontextprotocol/server-memory"47 ]48 },49 "custom-server": {50 "command": "npx",51 "args": [52 "-y",53 "tsx",54 "/absolute/path/to/your/server/src/index.ts"55 ],56 "env": {57 "API_KEY": "your-api-key"58 }59 }60 }61}Common mistakes when connecting MCP servers to Cursor
Why it's a problem: Using 'servers' instead of 'mcpServers' as the config key
How to avoid: Cursor uses 'mcpServers' (camelCase). The 'servers' key is for VS Code's MCP configuration. Using the wrong key means Cursor ignores your config silently.
Why it's a problem: Not restarting Cursor after config changes
How to avoid: Cursor reads the MCP config at startup. After editing .cursor/mcp.json, fully restart Cursor or use Developer: Reload Window (Cmd+Shift+P). Just opening a new chat is not enough.
Why it's a problem: Using relative paths for server commands or arguments
How to avoid: Always use absolute paths: /Users/you/project/src/index.ts, not ./src/index.ts. The working directory when Cursor launches the server may not be your project root.
Why it's a problem: Forgetting the -y flag in npx commands
How to avoid: Without -y, npx prompts for package installation confirmation. Cursor cannot respond to interactive prompts, so the server hangs. Always use npx -y.
Best practices
- Use project-level .cursor/mcp.json for project-specific servers and commit it to git for team sharing
- Use global ~/.cursor/mcp.json for personal servers you want in every project
- Always use absolute paths for server commands and directory arguments
- Pass API keys via the env field, never as command-line arguments visible in process listings
- Always include -y in npx commands to prevent interactive prompts from hanging
- Check Cursor Settings > MCP tab after restart to verify all servers connected successfully
- Start with one server, verify it works, then add more — debugging multiple new servers at once is harder
- Use the MCP Inspector to test servers independently before adding them to Cursor
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
Show me how to configure MCP servers in Cursor. I want to connect the filesystem server, the GitHub MCP server (using Docker), and a custom TypeScript server. Show the complete .cursor/mcp.json file with environment variables for API keys.
Help me set up MCP servers in Cursor. I want to add the filesystem server for my project directory and the Brave Search server. Show me the .cursor/mcp.json configuration and how to verify the connection works.
Frequently asked questions
Where is the .cursor/mcp.json file located?
For project-level config, create it at your-project/.cursor/mcp.json. For global config available across all projects, create it at ~/.cursor/mcp.json. Project-level takes precedence over global.
Can I use the Cursor Settings UI to configure MCP servers?
Cursor Settings has an MCP tab that shows connected servers and their status, but configuration is done by editing the JSON file directly. The settings UI is for monitoring, not configuration.
Do MCP servers work with Cursor's free plan?
Yes. MCP servers work with all Cursor plans. However, Composer agent mode (which chains multiple MCP tool calls autonomously) requires Cursor Pro or higher.
How do I use the GitHub MCP server with Cursor?
The GitHub MCP server uses Docker. Configure it with command: 'docker' and the ghcr.io/github/github-mcp-server image. Pass your GitHub Personal Access Token via the env field. The npm package for the GitHub MCP server was deprecated in April 2025.
Can RapidDev set up MCP for our development team?
Yes. RapidDev helps teams configure shared MCP setups including custom servers, proper secret management, and team-wide .cursor/mcp.json configurations committed to version control.
Why is my MCP server showing as disconnected in Cursor?
Common causes: (1) the command path is wrong, (2) the server crashes on startup (check terminal for errors), (3) missing environment variables, (4) the server writes to stdout instead of stderr for logging. Test the server with MCP Inspector first to isolate the issue.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation