This guide shows you how to integrate your custom MCP server with Cursor editor for enhanced AI assistance.
npm run build# Test with the example Cursor-optimized server
node dist/cli.js start --config examples/cursor-config.jsonAdd this to your Cursor MCP configuration file:
{
"mcpServers": {
"cursor-dev-server": {
"command": "node",
"args": [
"/absolute/path/to/your/mcp-server/examples/cursor-mcp-server.js"
],
"env": {
"NODE_ENV": "production"
}
}
}
}{
"mcpServers": {
"cursor-dev-server": {
"command": "node",
"args": [
"/absolute/path/to/your/mcp-server/dist/cli.js",
"start",
"--config",
"/absolute/path/to/your/mcp-server/examples/cursor-config.json"
]
}
}
}Once configured, you'll have access to these tools in Cursor:
read_file: Read file contentswrite_file: Write content to fileslist_directory: Browse directory contents
run_command: Execute shell commandssearch_files: Search text within filesgit_status: Check git repository status
You: "Read the package.json file"
AI: Uses read_file tool to show package.json contents
You: "List all TypeScript files in the src directory"
AI: Uses list_directory and search_files tools
You: "Run npm test"
AI: Uses run_command tool to execute tests
You: "What's the git status?"
AI: Uses git_status tool to show repository state
%APPDATA%\Cursor\User\globalStorage\cursor.mcp\mcp_servers.json
~/Library/Application Support/Cursor/User/globalStorage/cursor.mcp/mcp_servers.json
~/.config/Cursor/User/globalStorage/cursor.mcp/mcp_servers.json
- Extend the example server:
import { MCPServer, ToolDefinition } from 'mcp-server-dev';
const myCustomTool: ToolDefinition = {
name: 'my_tool',
description: 'My custom tool for Cursor',
inputSchema: {
type: 'object',
properties: {
input: { type: 'string' }
},
required: ['input']
},
handler: async (args) => {
// Your tool logic here
return {
content: [{
type: 'text',
text: `Processed: ${args.input}`
}]
};
}
};
server.getToolRegistry().registerTool(myCustomTool);- Add project-specific resources:
server.getResourceManager().registerResource({
uri: 'project://config',
name: 'Project Configuration',
description: 'Current project settings',
provider: async () => {
// Return project-specific data
}
});- Check the absolute paths in your configuration
- Ensure the server builds successfully:
npm run build - Test manually:
node dist/cli.js start --config examples/cursor-config.json
- Restart Cursor after configuration changes
- Check Cursor's MCP logs for connection errors
- Verify the configuration file syntax
- Ensure the MCP server has necessary file system permissions
- For shell commands, verify the user has appropriate access
{
"mcpServers": {
"cursor-dev-server": {
"command": "node",
"args": [
"/path/to/dist/cli.js",
"start",
"--debug",
"--config",
"/path/to/cursor-config.json"
]
}
}
}# Test connection manually
node dist/cli.js test-connection --config examples/cursor-config.jsonIf you want to use HTTP mode (not typical for Cursor):
{
"mcpServers": {
"cursor-http-server": {
"url": "http://localhost:3000/mcp",
"headers": {
"x-api-key": "your-api-key"
}
}
}
}The server includes code review prompts that Cursor can use:
You: "Review this file for security issues"
AI: Uses the code_review prompt with security focus
- Keep tools focused: Each tool should do one thing well
- Validate inputs: Always validate tool parameters
- Handle errors gracefully: Return meaningful error messages
- Use appropriate timeouts: Prevent long-running operations from hanging
- Log appropriately: Use structured logging for debugging
- Customize the example server for your specific needs
- Add project-specific tools and resources
- Create custom prompts for your workflow
- Share your configuration with your team
For more advanced usage, see the main README.md and API documentation.