How to set up MCP servers on Cursor
Setting up MCP servers on Cursor involves configuring the MCP settings in your Cursor preferences and connecting to your desired server endpoints. This enables enhanced AI capabilities and custom integrations within your development environment.
Prerequisites
- Cursor IDE installed
- Basic knowledge of JSON configuration
- Node.js or Python installed
- Understanding of server concepts
Step-by-Step Instructions
Open Cursor Settings
Ctrl+, (Windows/Linux) or Cmd+, (Mac). In the settings search bar, type MCP to filter MCP-related options.Configure MCP Server Settings
{
"mcp.servers": {
"your-server-name": {
"command": "node",
"args": ["path/to/your/server.js"],
"env": {}
}
}
}Install Required MCP Dependencies
Ctrl+` or going to View > Terminal. Install the MCP SDK and any required packages:npm install @modelcontextprotocol/sdkFor Python-based servers, use:
pip install mcpCreate or Configure Your MCP Server
mcp-server.js) or configure an existing one. Ensure your server implements the MCP protocol correctly with proper request handlers and response formatting. Update the file path in your settings.json to point to this server file.Set Environment Variables
"env": {
"API_KEY": "your-api-key",
"SERVER_PORT": "3000",
"DEBUG": "true"
}These variables will be available to your MCP server process.
Enable and Start MCP Server
Ctrl+Shift+P) and search for MCP: Start Server. Select your configured server from the list to start it.Test MCP Server Connection
Configure Server Permissions
Common Issues & Troubleshooting
MCP server fails to start
Check the Output panel for error messages. Verify that the server file path in settings.json is correct and the file exists. Ensure all dependencies are properly installed.
Connection timeout errors
Increase the connection timeout in MCP settings. Check if your server is listening on the correct port and that no firewall is blocking the connection. Verify environment variables are set correctly.
Permission denied errors
Review and update MCP server permissions in Cursor Settings > MCP > Permissions. Ensure your server has the necessary file system or network access permissions enabled.
Server configuration not loading
Validate your settings.json syntax using a JSON validator. Restart Cursor completely after making configuration changes. Check that the MCP server name doesn't contain special characters or spaces.