A specialized MCP (Model Context Protocol) server designed specifically for Cursor IDE that automatically creates and manages .cursor/rules
directories for your projects, with automatic file watching for rule changes.
Note: This server is specifically designed for Cursor IDE and uses the
.cursor/rules
directory structure. While the MCP protocol could be adapted for other IDEs in the future, this implementation is optimized for Cursor IDE's specific requirements and file structure.
- No network connectivity: This server operates entirely locally without any network capabilities
- File-based communication: Uses stdio (standard input/output) for communication with Cursor IDE
- Zero network exposure: No ports, no HTTP servers, no external connections
- Process isolation: Runs as a separate process with no network access
- No attack surface: No network ports or HTTP endpoints to exploit
- Data privacy: All rule files and data remain on your local machine
- No telemetry: Zero data collection or external communication
- Process boundaries: Clear separation between Cursor IDE and the MCP server
- stdio only: Communication via standard input/output streams
- No TCP/UDP: No network sockets or protocols
- No HTTP: No web server or API endpoints
- Direct process communication: Direct parent-child process communication
Security Note: This server is designed with security in mind. It has no network capabilities, runs entirely locally, and communicates only through stdio with Cursor IDE. This eliminates potential security vulnerabilities associated with network services.
- Cursor-specific paths: Uses
.cursor/rules
directory structure - Automatic rule management: Creates
.cursor/rules
directory when Cursor IDE connects - File watching: Optimized for Cursor IDE's file monitoring requirements
- MCP validation: Ensures compatibility with Cursor IDE's MCP implementation
- Self-contained: All rule files are included in the project itself
- GitHub-based: Rules are distributed via GitHub, no external dependencies
- Complete rule set: Copies ALL
.mdc
files from the cursor-mcp-server project - Project customization: Automatically replaces project names in rule content
- No overwrites: Preserves existing rule files in target projects
- Creates
.cursor/rules
directory when Cursor IDE connects - Copies all rule files from the cursor-mcp-server project
- Customizes rule content with project-specific names
- Generates comprehensive rule templates for new projects
- Validates MCP file format compliance
- Watches for changes to
.mdc
files in real-time - Detects new files automatically
- Logs file changes with timestamps and file sizes
- Graceful shutdown handling
- Validates YAML frontmatter structure
- Checks for required fields (
description
,globs
) - Provides helpful warnings for missing metadata
- Ensures proper MCP file format
# Clone the repository
git clone https://github.com/ltsch/cursor-mcp-server.git
cd cursor-mcp-server
# Run the automated installation script
./install.sh
If you prefer to install manually:
# Install Node.js dependencies
npm install
# Install Node.js dependencies
npm install
# Start the server in your project directory
node cursor_mcp_server.js
- Node.js 18+ installed
- Cursor IDE configured for MCP
The installation script will:
- โ Install Node.js in user space (if not already installed)
The easiest way to set up the MCP server in any project:
# Navigate to your project
cd ~/your-project
# Generate MCP configuration (one command!)
node ~/cursor-ide-mcp-server-stdio/generate-config.js
The generator will show you the exact paths to use, but you need to update them to point to where you actually cloned the repository.
This will:
- โ Show you the MCP server configuration to add
- โ Use absolute paths to the MCP server
- โ Set up proper Node.js environment
- โ Verify all dependencies are available
โ ๏ธ Require you to update paths for your environment
- Detects your project location - Automatically finds where you are
- Finds the MCP server - Locates the cursor-ide-mcp-server-stdio installation
- Generates correct paths - Creates absolute paths for reliability
- Creates
.cursor/mcp.json
- Sets up the MCP configuration - Verifies setup - Checks that all files and dependencies exist
๐ Cursor IDE MCP Server Configuration Generator
================================================
๐ You are in a different project directory
๐ Current directory: /home/user/my-project
๐ MCP Server location: /home/user/cursor-ide-mcp-server-stdio
๐ง MCP Server Configuration:
============================
๐ Add this to your Cursor IDE MCP configuration:
1. Open Cursor IDE Settings
2. Go to "MCP & Integrations"
3. Add a new MCP server with these settings:
**Server Name:** cursor-mcp-server
**Command:** node
**Arguments:** /home/user/cursor-ide-mcp-server-stdio/cursor_mcp_server.js
**Environment Variables:**
NODE_PATH = /home/user/cursor-ide-mcp-server-stdio/node_modules
โ ๏ธ IMPORTANT: Update the paths above to match your environment!
Current paths are based on: /home/user/cursor-ide-mcp-server-stdio
Make sure these paths point to where you cloned the repository
๐ Or add this to your .cursor/mcp.json file:
{
"mcpServers": {
"cursor-mcp-server": {
"command": "node",
"args": ["/home/user/cursor-ide-mcp-server-stdio/cursor_mcp_server.js"],
"env": {
"NODE_PATH": "/home/user/cursor-ide-mcp-server-stdio/node_modules"
}
}
}
}
โ ๏ธ IMPORTANT: Update the paths in the JSON above to match your environment!
Current paths are based on: /home/user/cursor-ide-mcp-server-stdio
Make sure these paths point to where you cloned the repository
๐ก Next steps:
1. Add the MCP server configuration to Cursor IDE
2. Restart Cursor IDE to load the MCP server
3. Check MCP & Integrations settings to verify connection
4. The server will automatically set up rule files
### **Path Customization**
**The generated configuration uses absolute paths based on where the generator is run from. You MUST update these paths to match your environment:**
#### **Example Path Updates:**
**If you cloned to a different location:**
```bash
# Instead of: /home/user/cursor-ide-mcp-server-stdio/cursor_mcp_server.js
# Use: /opt/my-mcp-server/cursor_mcp_server.js
If you're on Windows:
# Instead of: /home/user/cursor-ide-mcp-server-stdio/cursor_mcp_server.js
# Use: C:\Users\YourName\cursor-ide-mcp-server-stdio\cursor_mcp_server.js
If you're on macOS:
# Instead of: /home/user/cursor-ide-mcp-server-stdio/cursor_mcp_server.js
# Use: /Users/YourName/cursor-ide-mcp-server-stdio/cursor_mcp_server.js
# Navigate to where you cloned the repository
cd ~/your-clone-location
# Get the absolute path
pwd
# Output: /home/yourname/your-clone-location
# The full path to the MCP server will be:
# /home/yourname/your-clone-location/cursor_mcp_server.js
- โ Install all Node.js dependencies
- โ Verify the installation
- โ Create an activation script
The installation script automatically creates the MCP configuration file .cursor/mcp.json
in the project directory. Cursor IDE will automatically detect this configuration.
Manual Configuration (if needed):
- Create
.cursor/mcp.json
in your project root:
{
"mcpServers": {
"cursor-mcp-server": {
"command": "node",
"args": ["cursor_mcp_server.js"],
"env": {
"NODE_PATH": "node_modules"
}
}
}
}
- Restart Cursor IDE to load the MCP server
Important: The server communicates with Cursor IDE via stdio only. No network configuration is required or possible.
# Activate the environment (if using install.sh)
source ./activate_env.sh
# Start the MCP server
node cursor_mcp_server.js
- No network required: The server operates entirely offline
- File system access only: Reads and writes to local
.cursor/rules
directory - Process communication: Communicates with Cursor IDE via stdio
- No external dependencies: All operations are local file system operations
- Edit any
.mdc
file in.cursor/rules/
- Save the file - changes are detected immediately
- Restart Cursor IDE to reload the rules
- Check server console for change notifications
# Run the test script to create a test rule file
node test_mcp_reload.js
When you edit any .mdc
file in .cursor/rules/
:
-
File watcher detects the change immediately
-
Server logs the change with details:
๐ Rule file changed: general-best-practices.mdc (change) ๐ File size: 15420 bytes, Last modified: 2024-01-15T10:30:45.123Z ๐ก Restart Cursor IDE to reload the updated rules
-
Cursor IDE needs restart to pick up the changes
- The MCP server detects changes instantly
- But Cursor IDE caches rules and needs restart to reload them
- โ
File creation - New
.mdc
files - โ File modification - Editing existing files
- โ File deletion - Removing rule files
- โ File renaming - Changing file names
.cursor/
โโโ rules/
โโโ general-best-practices.mdc # Comprehensive development guidelines
โโโ project-specific-rules.mdc # Project-specific guidelines
โโโ coding-standards.mdc # Coding standards
โโโ testing-guidelines.mdc # Testing guidelines
Each .mdc
file should have proper YAML frontmatter:
---
description: Description of the rule file
globs: ["**/*.py", "**/*.js", "**/*.ts"]
alwaysApply: true
priority: critical
tags: ["best-practices", "security"]
---
# Rule Content
Your rule content goes here...
The server validates each .mdc
file for:
- โ YAML frontmatter presence
- โ
Required fields (
description
,globs
) - โ Proper YAML syntax
- โ File format compliance
- File change events with timestamps
- File size and modification time
- Error handling and graceful degradation
- Validation warnings and suggestions
- Graceful shutdown on SIGINT/SIGTERM
- File watcher error handling
- MCP server error recovery
- Validation error reporting
- Cause: Not in a project directory under your home folder
- Solution: Navigate to a project directory first
- Cause: Rules directory is empty
- Solution: The server will create template files automatically
- Cause: File system permissions or inotify limits
- Solution: Check file permissions and inotify limits
- Cause: Missing YAML frontmatter or required fields
- Solution: Add proper YAML frontmatter to rule files
- Cause: Running from wrong directory
- Solution: Make sure you're running from within the cursor-mcp-server project
# Ensure proper permissions
ls -la .cursor/rules/
chmod 644 .cursor/rules/*.mdc
# Watch for file changes manually
inotifywait -m -r .cursor/rules/
# Verify Node.js dependencies are installed
npm list @modelcontextprotocol/sdk
# Verify MCP SDK is working
node -e "import('@modelcontextprotocol/sdk')"
# If you encounter issues, reinstall everything
./install.sh
- Use descriptive names for rule files
- Include proper YAML frontmatter with all required fields
- Organize rules logically by category or concern
- Keep rules focused on specific areas (security, testing, etc.)
- Edit rules in your preferred editor
- Save files - changes are detected automatically
- Restart Cursor IDE to reload rules
- Verify changes by asking the AI about the rules
- Use the test script to create test files
- Edit files to test change detection
- Monitor server logs for change notifications
- Restart Cursor IDE to verify rule updates
You can modify the file watching behavior in cursor_mcp_server.js
:
// Watch for specific file types
const watcher = fs.watch(rulesPath, { recursive: true }, (eventType, filename) => {
if (filename && filename.endsWith('.mdc')) {
// Handle .mdc file changes
}
});
Add custom validation rules:
// Add custom validation checks
if (!yamlContent.includes('priority:')) {
validationErrors.push(`${filename}: Missing priority field`);
}
- File watching uses minimal system resources
- Validation runs only on startup and file changes
- Logging is lightweight and non-blocking
- Graceful shutdown ensures clean resource cleanup
- Monitor file change frequency
- Check for validation errors
- Review server logs for performance issues
- Ensure proper error handling
- Hot reloading without Cursor IDE restart
- Rule file templates for common patterns
- Rule conflict resolution for overlapping globs
- Performance metrics and monitoring
- Rule file backup and versioning
- WebSocket notifications for real-time updates
- Rule file synchronization across projects
- Advanced validation with custom schemas
- Rule file import/export functionality
- Multi-IDE support (future expansion)
Security Note: All future enhancements will maintain the local-only, stdio-based architecture. No network capabilities will be added to preserve the security model.
cursor-mcp-server/
โโโ install.sh # Automated installation script
โโโ activate_env.sh # Environment activation script
โโโ cursor_mcp_server.js # Enhanced Node.js server
โโโ package.json # Node.js dependencies
โโโ package-lock.json # Node.js lock file
โโโ .gitignore # Git ignore rules
โโโ README.md # This file
โโโ node_modules/ # Node.js dependencies (not in git)
โโโ .cursor/
โโโ rules/ # Rule files (in git)
โโโ general-best-practices.mdc
โโโ project-specific-rules.mdc
โโโ coding-standards.mdc
โโโ testing-guidelines.mdc
โ
Cursor IDE optimized with .cursor/rules
integration
โ
Local-only operation with zero network connectivity
โ
Secure stdio communication with Cursor IDE
โ
Portable rule distribution via GitHub
โ
Complete rule set with all MDC files included
โ
Automatic rule management with file watching
โ
Real-time change detection for .mdc
files
โ
MCP file validation and compliance checking
โ
Comprehensive logging and error handling
โ
Graceful shutdown and resource cleanup
โ
Easy testing and debugging capabilities
โ
One-command installation with ./install.sh
- Node.js - Runtime environment for the MCP server
- @modelcontextprotocol/sdk - Official MCP SDK for Node.js
- zod - Schema validation for MCP tools
.cursor/rules
directory structure - Optimized for Cursor IDE- MCP protocol compliance - Designed for Cursor IDE's MCP implementation
- File watching integration - Works seamlessly with Cursor IDE's file monitoring
- Rule validation - Ensures compatibility with Cursor IDE's rule system
- AI-Powered Rule Generation - Generate new rules using LLM integration
- Rule Analysis & Suggestions - AI-powered analysis of existing rules
- Text Summarization - Summarize any text using the connected AI model
- Project Validation - Comprehensive project health checks
- Resource Templates - Structured project and configuration information
- No network connectivity - Operates entirely locally
- stdio communication only - No HTTP, TCP, or network protocols
- File system access only - Reads and writes to local directories
- Process isolation - Clear boundaries between Cursor IDE and server
- Zero telemetry - No data collection or external communication
- Self-contained - All rule files included in the project
- GitHub distribution - Rules distributed via version control
- Complete rule set - All MDC files copied to new projects
- Project customization - Automatic name replacement in rule content
- No external dependencies - Rules come from the project itself
Remember: While the server detects changes instantly, you still need to restart Cursor IDE to reload the updated rules in the AI assistant.
Star this repository if you find it helpful! โญ