Skip to content

feat(cli): add Cursor IDE integration to init command #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

datYori
Copy link
Contributor

@datYori datYori commented Jun 25, 2025

🎯 Add Cursor Integration Support to MXCP CLI

This PR adds comprehensive Cursor support to the mxcp init command, providing feature parity with the existing Claude Desktop integration. Users can now automatically configure MXCP servers for use with Cursor IDE through the same streamlined setup process.

✨ Features

  • 🔍 Automatic Detection: Detects Cursor installation across Windows, macOS, and Linux platforms
  • ⚙️ Flexible Configuration: Supports both project-specific (.cursor/mcp.json) and global (~/.cursor/mcp.json) installation
  • 🔗 One-Click Installation: Generates deeplinks using correct cursor://anysphere.cursor-deeplink/mcp/install protocol for easy team sharing
  • 🔄 Config Merging: Safely merges with existing Cursor MCP configurations
  • 🤝 Seamless Integration: Same user experience and prompts as Claude Desktop setup

📋 Implementation Details

Core Functions Added (src/mxcp/cli/init.py):

  • detect_cursor_installation() - Cross-platform Cursor detection with PATH and config directory discovery
  • generate_cursor_config() - Reuses Claude Desktop config format (both use MCP protocol)
  • generate_cursor_deeplink() - Creates installation deeplinks with proper base64 encoding
  • install_cursor_config() - Handles installation with existing config merging
  • Updated init flow with Cursor prompts alongside Claude Desktop options

Configuration Format:

  • Uses same MCP server configuration as Claude Desktop
  • Supports both global and project-specific installations
  • Generates deeplinks with correct cursor://anysphere.cursor-deeplink/mcp/install?config=<base64> format

🧪 Testing

  • ✅ Unit Tests: Comprehensive test coverage in tests/test_cli_init.py
    • Cursor config generation with mocked detection
    • Project-specific vs global installation scenarios
    • Manual setup flow when Cursor not detected
    • Combined Claude + Cursor configuration
    • Deeplink generation with correct format
    • Config merging functionality
  • ✅ Real-World Testing: Verified with Python 3.11 environment and actual Cursor installations
  • ✅ Cross-Platform: Tested configuration paths for Windows, macOS, and Linux

📚 Documentation

  • 📖 Integration Guide (docs/guides/integrations.md): Added complete Cursor section with automatic/manual setup instructions
  • 📄 README: Added Cursor IDE to supported LLM integrations list
  • 📝 Examples: Updated earthquakes and COVID example READMEs with Cursor setup instructions

🔧 Example Usage

# Initialize new project with Cursor support
mxcp init my-project
# → Prompts for both Claude Desktop and Cursor IDE setup

# Add Cursor to existing project
mxcp init .
# → Detects existing configuration and offers Cursor integration

Generated Deeplink Example:

cursor://anysphere.cursor-deeplink/mcp/install?name=$NAME&config=$BASE64_ENCODED_CONFIG

💡 Design Decisions

  1. Reused Claude Desktop Config Format: Since both use MCP protocol, avoided code duplication
  2. Deeplink Protocol: Implemented proper cursor://anysphere.cursor-deeplink/mcp/install format based on Cursor documentation
  3. Feature Parity: Maintained same user experience between Claude Desktop and Cursor setup
  4. Safe Config Merging: Preserves existing Cursor configurations when adding new servers

🔄 Backwards Compatibility

  • ✅ No breaking changes to existing Claude Desktop functionality
  • ✅ All existing tests continue to pass
  • ✅ Existing mxcp init behavior unchanged when users don't select Cursor option

📦 Files Changed

  • src/mxcp/cli/init.py - Core implementation
  • tests/test_cli_init.py - Comprehensive test coverage
  • docs/guides/integrations.md - Documentation
  • README.md - Updated integration list
  • examples/*/README.md - Example integration instructions

Add Cursor IDE support to `mxcp init` with auto-detection, config generation,
one-click deeplinks, and feature parity with Claude Desktop integration.

- Cross-platform Cursor detection and configuration
- Project-specific and global MCP setup options
- Correct cursor://anysphere.cursor-deeplink/mcp/install deeplink format
- Safe config merging with existing Cursor configurations
- Complete documentation and test coverage

Closes #41
@datYori datYori marked this pull request as ready for review June 25, 2025 15:34
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@datYori datYori requested review from torcato and Dimitris-Mil June 26, 2025 07:04
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ BugBot reviewed your changes and found no bugs!


Was this report helpful? Give feedback by reacting with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant