Skip to main content
Glama

カーソルMCP(モデルコンテキストプロトコル)

Cursor MCPは、ClaudeのデスクトップアプリケーションとCursorエディタをつなぐ橋渡しとなり、AIを活用したシームレスな自動化とマルチインスタンス管理を実現します。より広範なModel Context Protocol(MCP)エコシステムの一部であり、標準化されたインターフェースを通じてCursorが様々なAIモデルやサービスと連携することを可能にします。

概要

🤖 AI統合

  • Claudeのデスクトップアプリケーションとの直接統合

  • 他のMCP互換AIサービスを活用する能力

  • AIとエディター間のリアルタイムコンテキスト共有

  • AIを活用した自動化とコード生成

🔌 MCP プロトコルのサポート

  • AIモデルとの標準化された通信

  • 追加のMCP用の拡張可能なプラグインシステム

  • コンテキスト認識コマンド実行

  • 安全なトークンベースの認証

🖥️ クロスプラットフォームのウィンドウ管理

  • 複数のオペレーティングシステム間でカーソルエディタウィンドウをシームレスに管理します

  • プログラムでウィンドウをフォーカス、最小化、復元、整列する

  • ウィンドウの状態の変化と位置を追跡する

  • 複数のカーソルインスタンスを同時に処理する

⌨️ 入力自動化

  • 以下をサポートする AI 駆動型キーボード入力:

    • コード生成と挿入

    • リファクタリング操作

    • コンテキスト認識補完

    • マルチカーソル編集

  • 以下を含むインテリジェントなマウス自動化:

    • スマートな選択

    • コンテキストメニュー操作

    • AIガイドナビゲーション

🔄プロセス管理

  • AIオーケストレーションによるインスタンス管理

  • スマートなワークスペースの整理

  • 自動コンテキスト保存

  • インテリジェントなセッション回復

Related MCP server: Portkey MCP Server

MCP統合

クロードデスクトップ統合

import { ClaudeMCP } from 'cursor-mcp/claude'

// Connect to Claude's desktop app
const claude = await ClaudeMCP.connect()

// Execute AI-powered operations
await claude.generateCode({
    prompt: 'Create a React component',
    context: currentFileContent,
    language: 'typescript'
})

// Get AI suggestions
const suggestions = await claude.getSuggestions({
    code: selectedText,
    type: 'refactor'
})

複数のMCPの使用

import { MCPRegistry } from 'cursor-mcp/registry'

// Register available MCPs
MCPRegistry.register('claude', ClaudeMCP)
MCPRegistry.register('github-copilot', CopilotMCP)

// Use different AI services
const claude = await MCPRegistry.get('claude')
const copilot = await MCPRegistry.get('github-copilot')

// Compare suggestions
const claudeSuggestions = await claude.getSuggestions(context)
const copilotSuggestions = await copilot.getSuggestions(context)

カスタムMCP統合

import { BaseMCP, MCPProvider } from 'cursor-mcp/core'

class CustomMCP extends BaseMCP implements MCPProvider {
    async connect() {
        // Custom connection logic
    }

    async generateSuggestions(context: CodeContext) {
        // Custom AI integration
    }
}

// Register custom MCP
MCPRegistry.register('custom-ai', CustomMCP)

構成

このツールは、環境変数または次の設定ファイルを通じて設定できます。

  • Windows: %LOCALAPPDATA%\cursor-mcp\config\config.json

  • macOS: ~/Library/Application Support/cursor-mcp/config/config.json

  • Linux: ~/.config/cursor-mcp/config.json

構成例:

{
    "mcp": {
        "claude": {
            "enabled": true,
            "apiKey": "${CLAUDE_API_KEY}",
            "contextWindow": 100000
        },
        "providers": {
            "github-copilot": {
                "enabled": true,
                "auth": "${GITHUB_TOKEN}"
            }
        }
    },
    "autoStart": true,
    "maxInstances": 4,
    "windowArrangement": "grid",
    "logging": {
        "level": "info",
        "file": "cursor-mcp.log"
    }
}

インストール

ウィンドウズ

# Run as Administrator
Invoke-WebRequest -Uri "https://github.com/your-org/cursor-mcp/releases/latest/download/cursor-mcp-windows.zip" -OutFile "cursor-mcp.zip"
Expand-Archive -Path "cursor-mcp.zip" -DestinationPath "."
.\windows.ps1

macOS

# Run with sudo
curl -L "https://github.com/your-org/cursor-mcp/releases/latest/download/cursor-mcp-macos.zip" -o "cursor-mcp.zip"
unzip cursor-mcp.zip
sudo ./macos.sh

リナックス

# Run with sudo
curl -L "https://github.com/your-org/cursor-mcp/releases/latest/download/cursor-mcp-linux.zip" -o "cursor-mcp.zip"
unzip cursor-mcp.zip
sudo ./linux.sh

使用法

基本的な使い方

import { CursorInstanceManager } from 'cursor-mcp'

// Get the instance manager
const manager = CursorInstanceManager.getInstance()

// Start a new Cursor instance
await manager.startNewInstance()

// Get all running instances
const instances = await manager.getRunningInstances()

// Focus a specific instance
await manager.focusInstance(instances[0])

// Close all instances
await manager.closeAllInstances()

ウィンドウ管理

import { WindowManager } from 'cursor-mcp'

const windowManager = WindowManager.getInstance()

// Find all Cursor windows
const windows = await windowManager.findCursorWindows()

// Focus a window
await windowManager.focusWindow(windows[0])

// Arrange windows side by side
await windowManager.arrangeWindows(windows, 'sideBySide')

// Minimize all windows
for (const window of windows) {
    await windowManager.minimizeWindow(window)
}

入力自動化

import { InputAutomationService } from 'cursor-mcp'

const inputService = InputAutomationService.getInstance()

// Type text
await inputService.typeText('Hello, World!')

// Send keyboard shortcuts
if (process.platform === 'darwin') {
    await inputService.sendKeys(['command', 'c'])
} else {
    await inputService.sendKeys(['control', 'c'])
}

// Mouse operations
await inputService.moveMouse(100, 100)
await inputService.mouseClick('left')
await inputService.mouseDrag(100, 100, 200, 200)

仕組み

橋梁建築

このツールは、カーソルと MCP サーバー間のミドルウェア層として機能します。

  1. カーソル統合:

    • カーソルのファイルシステムイベントを監視します

    • エディターの状態とコンテキストをキャプチャします

    • 応答をエディターに挿入します

    • ウィンドウとプロセスの自動化を管理します

  2. MCPプロトコル翻訳:

    • カーソルの内部イベントをMCPプロトコルメッセージに変換します

    • MCP応答をカーソル互換のアクションに変換します

    • セッション状態とコンテキストを維持する

    • 認証とセキュリティを処理する

  3. サーバー通信:

    • クロードのデスクトップアプリMCPサーバーに接続します

    • 適切なAIプロバイダーにリクエストをルーティングします

    • 複数のMCPへの同時接続を管理します

    • フォールバックとエラー回復を処理する

graph LR
    A[Cursor Editor] <--> B[Cursor MCP Bridge]
    B <--> C[Claude Desktop MCP]
    B <--> D[GitHub Copilot MCP]
    B <--> E[Custom AI MCPs]

ワークフローの例

  1. コード補完リクエスト:

    // 1. Cursor Event (File Change)
    // When user types in Cursor:
    function calculateTotal(items) {
      // Calculate the total price of items|  <-- cursor position
    
    // 2. Bridge Translation
    const event = {
      type: 'completion_request',
      context: {
        file: 'shopping-cart.ts',
        line: 2,
        prefix: '// Calculate the total price of items',
        language: 'typescript',
        cursor_position: 43
      }
    }
    
    // 3. MCP Protocol Message
    await mcpServer.call('generate_completion', {
      prompt: event.context,
      max_tokens: 150,
      temperature: 0.7
    })
    
    // 4. Response Translation
    // Bridge converts MCP response:
    const response = `return items.reduce((total, item) => {
      return total + (item.price * item.quantity);
    }, 0);`
    
    // 5. Cursor Integration
    // Bridge injects the code at cursor position
  2. コードリファクタリング:

    // 1. Cursor Event (Command)
    // User selects code and triggers refactor command
    const oldCode = `
      if (user.age >= 18) {
        if (user.hasLicense) {
          if (car.isAvailable) {
            rentCar(user, car);
          }
        }
      }
    `
    
    // 2. Bridge Translation
    const event = {
      type: 'refactor_request',
      context: {
        selection: oldCode,
        command: 'simplify_nesting'
      }
    }
    
    // 3. MCP Protocol Message
    await mcpServer.call('refactor_code', {
      code: event.context.selection,
      style: 'simplified',
      maintain_logic: true
    })
    
    // 4. Response Translation
    const response = `
      const canRentCar = user.age >= 18 
        && user.hasLicense 
        && car.isAvailable;
      
      if (canRentCar) {
        rentCar(user, car);
      }
    `
    
    // 5. Cursor Integration
    // Bridge replaces selected code
  3. 複数ファイルのコンテキスト:

    // 1. Cursor Event (File Dependencies)
    // When user requests help with a component
    
    // 2. Bridge Translation
    const event = {
      type: 'context_request',
      files: {
        'UserProfile.tsx': '...',
        'types.ts': '...',
        'api.ts': '...'
      },
      focus_file: 'UserProfile.tsx'
    }
    
    // 3. MCP Protocol Message
    await mcpServer.call('analyze_context', {
      files: event.files,
      primary_file: event.focus_file,
      analysis_type: 'component_dependencies'
    })
    
    // 4. Response Processing
    // Bridge maintains context across requests

統合方法

  1. ファイルシステム監視:

    import { FileSystemWatcher } from 'cursor-mcp/watcher'
    
    const watcher = new FileSystemWatcher({
      paths: ['/path/to/cursor/workspace'],
      events: ['change', 'create', 'delete']
    })
    
    watcher.on('change', async (event) => {
      const mcpMessage = await bridge.translateEvent(event)
      await mcpServer.send(mcpMessage)
    })
  2. ウィンドウ統合:

    import { CursorWindow } from 'cursor-mcp/window'
    
    const window = new CursorWindow()
    
    // Inject AI responses
    await window.injectCode({
      position: cursorPosition,
      code: mcpResponse.code,
      animate: true  // Smooth typing animation
    })
    
    // Handle user interactions
    window.onCommand('refactor', async (selection) => {
      const mcpMessage = await bridge.createRefactorRequest(selection)
      const response = await mcpServer.send(mcpMessage)
      await window.applyRefactoring(response)
    })
  3. コンテキスト管理:

    import { ContextManager } from 'cursor-mcp/context'
    
    const context = new ContextManager()
    
    // Track file dependencies
    await context.addFile('component.tsx')
    await context.trackDependencies()
    
    // Maintain conversation history
    context.addMessage({
      role: 'user',
      content: 'Refactor this component'
    })
    
    // Send to MCP server
    const response = await mcpServer.send({
      type: 'refactor',
      context: context.getFullContext()
    })

安全

  • AIサービス向けの安全なトークンベースの認証

  • 暗号化された通信チャネル

  • サンドボックス化された実行環境

  • きめ細かな権限制御

要件

ウィンドウズ

  • Windows 10以降

  • Node.js 18以降

  • インストールのための管理者権限

macOS

  • macOS 10.15 (Catalina) 以降

  • Node.js 18以降

  • Xcode コマンドラインツール

  • ターミナルのアクセシビリティ権限

リナックス

  • X11ディスプレイサーバー

  • Node.js 18以降

  • xdotool

  • libxtst-dev

  • libpng++-dev

  • ビルド必須

発達

設定

# Clone the repository
git clone https://github.com/your-org/cursor-mcp.git
cd cursor-mcp

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test

テストの実行

# Run all tests
npm test

# Run specific test suite
npm test -- window-management

# Run with coverage
npm run test:coverage

貢献

貢献を歓迎します!詳細については貢献ガイドをご覧ください。

ライセンス

このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細についてはLICENSEファイルを参照してください。

サポート

謝辞

-
security - not tested
A
license - permissive license
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/johnneerdael/multiplatform-cursor-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server