Skip to content

loocor/deeplinker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cursor DeepLink Handler

A macOS application for managing cursor:// URL protocol handling with SwiftUI interface.

Overview

This application provides reliable control over which application responds to cursor:// URL schemes on macOS. It features a modern SwiftUI interface for monitoring protocol status, switching handlers, and managing URL history.

Features

  • Protocol Control: One-click take/release control of cursor:// protocol
  • Real-time Monitoring: Live status updates of current protocol handler
  • URL History: Track and manage received URL calls with detailed information
  • MCP Server Support: Handle MCP (Model Context Protocol) installation requests
  • Modern Interface: Native SwiftUI design with intuitive controls
  • Menu Integration: Full macOS menu bar integration with keyboard shortcuts

Technical Implementation

LaunchServices Integration

The application uses macOS LaunchServices framework to manage URL protocol handlers:

  • Handler Detection: Uses modern NSWorkspace.urlForApplication(toOpen:) API
  • Protocol Registration: Implements LSSetDefaultHandlerForURLScheme for control
  • Status Monitoring: Real-time updates with automatic refresh

URL Scheme Handling

Supports multiple URL patterns:

  • Basic cursor:// URLs
  • MCP installation: cursor://anysphere.cursor-deeplink/mcp/install?name=<name>&config=<base64>
  • Custom protocols with parameters

Architecture

Sources/
├── DeepLinkApp.swift          # Main application entry point
├── Models/
│   ├── URLSchemeManager.swift # Protocol management
│   ├── DeepLinkStore.swift    # State management
│   └── URLRecord.swift        # URL data models
├── Views/
│   ├── ContentView.swift      # Main interface
│   ├── StatusCardView.swift   # Status display
│   ├── ControlPanelView.swift # Control buttons
│   └── URLHistoryView.swift   # History management
└── Utils/
    └── MenuCommands.swift     # Menu bar integration

Installation & Usage

Building from Source

  1. Prerequisites:

    • macOS 12.0 or later
    • Xcode with Swift 5.7+
  2. Build:

    ./build.sh
  3. Launch:

    open DeepLink.app

Testing

Use the included test script to verify functionality:

./test_urls.sh

Test options include:

  • Basic URL protocol tests
  • MCP server installation simulations
  • Continuous testing scenarios

Configuration

Info.plist Setup

The application declares cursor:// protocol support:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>cursor</string>
        </array>
    </dict>
</array>

LaunchServices Database

Protocol handlers are managed through macOS LaunchServices:

Method Use Case Modifies plist
User manual selection GUI-based selection
Command-line tools (duti) Batch deployment
Programmatic API Application control

Command-Line Tools Integration

Using duti

# Install duti
brew install duti

# Set handler
duti -s com.loocor.deeplink cursor all

# Verify
duti -x cursor

Using Swift API

import CoreServices

// Take control
LSSetDefaultHandlerForURLScheme("cursor" as CFString, "com.loocor.deeplink" as CFString)

// Check current handler
let handler = NSWorkspace.shared.urlForApplication(toOpen: URL(string: "cursor://test")!)

MCP Server Integration

The application supports Model Context Protocol server installation through URL schemes:

URL Format

cursor://anysphere.cursor-deeplink/mcp/install?name=<name>&config=<base64-config>

Configuration Format

{
  "command": "npm exec @modelcontextprotocol/server-filesystem",
  "env": {
    "HOME": "/Users/username"
  }
}

Example URLs

Filesystem MCP:

CONFIG='{"command":"npm exec @modelcontextprotocol/server-filesystem","env":{"HOME":"/Users/username"}}'
CONFIG_B64=$(echo "$CONFIG" | base64)
open "cursor://anysphere.cursor-deeplink/mcp/install?name=filesystem&config=$CONFIG_B64"

Troubleshooting

Common Issues

  1. Permission Denied: Ensure application has necessary permissions
  2. Handler Not Found: Verify target applications are installed
  3. Protocol Conflicts: Check for competing protocol handlers

Debug Commands

# Check current handler
defaults read ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers | grep -A5 -B5 "cursor"

# Reset LaunchServices (if needed)
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -seed

# Re-register application
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f DeepLink.app

System Integration

  • Security: No sandbox restrictions for protocol handling
  • Permissions: Standard application permissions required
  • Compatibility: Works with macOS 12.0+ systems
  • Signing: Compatible with both signed and unsigned builds

Development

Modern API Usage

The application uses current macOS APIs:

  • NSWorkspace.urlForApplication(toOpen:) for handler detection
  • ✅ SwiftUI for modern interface design
  • ✅ Combine for reactive state management

Building

Requirements:

  • Swift 5.7+
  • macOS deployment target: 12.0
  • SwiftUI framework

Build configuration automatically handles:

  • Application bundle creation
  • Info.plist integration
  • Executable permissions
  • Resource management

License

This project demonstrates modern macOS URL protocol handling techniques and SwiftUI application development patterns.

Technical Notes

  • Bundle ID: com.loocor.deeplink
  • Supported Schemes: cursor://
  • Target Systems: macOS 12.0+
  • Framework: SwiftUI + AppKit integration

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors