Swift Developer MCP Server について
Swift Developer MCP Serverは、macOSとLinuxでSwiftプロジェクトを扱う開発者やAIアシスタント向けに、ビルド、テスト、デバッグ、プロジェクト管理機能を提供します。Swiftlyのツールチェーン管理に加え、リソースやプロンプトからプロジェクト情報も利用できます。
主な機能
- 01プロジェクトのビルドとテスト実行
- 02デバッグ開始と変数の調査
- 03パッケージ情報と依存関係のAPI表示
- 04Swiftツールチェーンの導入と切り替え
- 05プロジェクト、ビルド、デバッグ情報の参照
活用シーン
- 01Swiftパッケージのビルドと絞り込みテスト
- 02ブレークポイント設定とターゲットのステップ実行
- 03プロジェクトで使うSwiftバージョンの切り替え
MCP 対応
MCPサーバーとして、Swiftのビルド、テスト、デバッグ、ツールチェーン管理ツールをAIクライアントに提供します。プロジェクトやビルド状態、デバッグセッションのリソースとガイド用プロンプトも公開します。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
Swift Developer MCP Server
macOS および Linux 環境向けに、Swift 開発ツール、デバッグ機能、プロジェクト管理機能を提供する、包括的な Model Context Protocol(MCP)サーバーです。このサーバーにより、AI アシスタントは Swift プロジェクト、ビルドシステム、開発ツールを操作できます。
機能
🔨 ビルドとテストのツール
swift_build- 設定オプション(デバッグ/リリース、特定のターゲット、詳細な出力)を指定して Swift プロジェクトをビルドしますswift_test- フィルタリング、並列実行の制御、詳細な出力を指定して Swift テストを実行しますrun_target- カスタム引数を指定して、特定の Swift ターゲットを実行します
🐛 デバッグツール
debug_start- Swift ターゲットのデバッグセッションを開始しますdebug_set_breakpoint- オプションで条件を指定してブレークポイントを設定しますdebug_step- コードをステップ実行します(オーバー、イン、アウト)debug_continue- 次のブレークポイントまで実行を続けますdebug_inspect_variable- 変数を調査し、式を評価します
📦 Swift パッケージ管理
get_package_info- Swift パッケージと依存関係に関する包括的な情報を取得しますprint_dependency_public_api- 任意の依存関係の公開 API を抽出して表示します
🔧 Swiftly ツールチェーン管理
swiftly_install- 異なるチャンネルから Swift ツールチェーンをインストールしますswiftly_list- インストール済みの Swift ツールチェーンを一覧表示しますswiftly_list_available- インストール可能な Swift バージョンを一覧表示しますswiftly_use- Swift のバージョンをグローバルまたはプロジェクト単位で切り替えますswiftly_run- 指定した Swift バージョンでコマンドを実行しますswiftly_uninstall- Swift ツールチェーンを削除します
📊 リソース
swift://project/info- 現在のプロジェクト情報と構成swift://build/status- ビルドのステータスと履歴swift://debug/sessions- アクティブなデバッグセッションとブレークポイント
💡 プロンプト
swift_debug_session- ターゲットに応じた推奨事項を含む、ガイド付きデバッグセッションのセットアップswift_build_analysis- ビルドエラーのインテリジェントな分析と解決策の提案
インストール
前提条件
- Swift:Swift 5.9+ をインストールするか、バージョン管理に Swiftly を使用してください
- macOS または Linux:このサーバーは macOS と Linux の両方の環境をサポートしています
- Make:便利なビルドターゲットを使用するために必要です
クイックセットアップ
-
リポジトリをクローンします:
git clone https://github.com/edgeengineer/swift-developer-mcp-server.git cd swift-developer-mcp-server -
ビルドしてパスを取得(クリップボードに自動的にコピーされます):
make pathこれにより、以下が実行されます:
- ✅ サーバーをリリースモードでビルドします
- ✅ 実行ファイルのパスを表示します
- ✅ パスをクリップボードにコピーします
- ✅ 人気の AI クライアント向けの設定例を表示します
その他の Make ターゲット
make build # Build the server in release mode
make clean # Clean build artifacts
make install # Install to /usr/local/bin
make help # Show all available targets
AI クライアントの設定
Cursor
Cursor の設定(.cursor-settings/settings.json)に追加します:
{
"mcp": {
"servers": {
"swift-developer": {
"command": "PASTE_PATH_FROM_CLIPBOARD_HERE",
"args": [],
"env": {}
}
}
}
}
Windsurf
Windsurf の設定(.windsurf/mcp_servers.json)に追加します:
{
"servers": {
"swift-developer": {
"command": "PASTE_PATH_FROM_CLIPBOARD_HERE",
"args": [],
"env": {}
}
}
}
Claude Desktop
Claude Desktop の設定に追加します:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/claude/claude_desktop_config.json
{
"mcpServers": {
"swift-developer": {
"command": "PASTE_PATH_FROM_CLIPBOARD_HERE",
"args": [],
"env": {}
}
}
}
Claude Code(ターミナルアプリケーション)
Claude Code の設定(ターミナルアプリケーション内)に追加します:
claude mcp add swift-developer PASTE_PATH_FROM_CLIPBOARD_HERE
Claude Code(VS Code 拡張機能)
VS Code の設定(.vscode/settings.json)に追加します:
{
"claude-dev.mcpServers": {
"swift-developer": {
"command": "PASTE_PATH_FROM_CLIPBOARD_HERE",
"args": [],
"env": {}
}
}
}
💡 ヒント:
make pathを実行すると、各クライアント向けのコピーしてすぐに使える設定例を取得できます!
使用例
Swift プロジェクトのビルド
Use the swift_build tool to build the current project in release mode with verbose output.
テストの実行
Use the swift_test tool to run all tests in parallel with verbose output.
デバッグセッションの開始
Use the swift_debug_session prompt to set up debugging for the "MyApp" target, focusing on the "ViewController.swift" file.
Swift バージョンの管理
Use swiftly_list to see installed Swift versions, then swiftly_use to switch to Swift 5.9.
依存関係の API の抽出
Use print_dependency_public_api with dependency_name "Alamofire" to see the public API of the Alamofire dependency.
プロジェクト情報の取得
Access the swift://project/info resource to see the current project structure and Package.swift contents.
開発
プロジェクト構成
swift-developer-mcp-server/
├── Package.swift # Swift Package Manager configuration
├── Makefile # Build automation and convenience targets
├── Sources/
│ ├── main.swift # Server entry point and MCP handler setup
│ ├── Utilities.swift # Common types and helper functions
│ ├── BuildTestTools.swift # Swift build and test tools
│ ├── DebugTools.swift # Debug session management and tools
│ ├── PackageInfoTools.swift # Swift package information tools
│ ├── SwiftlyTools.swift # Swiftly toolchain management
│ ├── Resources.swift # MCP resources (project info, build status, etc.)
│ └── Prompts.swift # MCP prompts (debug session, build analysis)
└── README.md # This file
新しいツールの追加
- 適切なモジュールファイルでツールの構造体を定義します。
- ビルドおよびテスト機能の場合は
BuildTestTools.swift - デバッグ機能の場合は
DebugTools.swift - パッケージ管理の場合は
PackageInfoTools.swift - ツールチェーン管理の場合は
SwiftlyTools.swift - その他のカテゴリについては、必要に応じて新しいモジュールを作成します
- ビルドおよびテスト機能の場合は
main.swiftのListToolsハンドラーにツールを追加しますCallToolの switch 文にツールのハンドラーメソッドを追加します- サーバーを再ビルドします
テスト
サーバーを実行し、JSON-RPC メッセージを送信して手動でテストできます。
swift run SwiftDeveloperMCPServer
次に、標準入力経由で初期化メッセージとツール呼び出しメッセージを送信します。
要件
- macOS 13.0+ または Linux(Ubuntu 20.04+、その他の Swift 対応ディストリビューション)
- Swift 5.9+
- Make(ビルドターゲット用)
- Xcode Command Line Tools(macOS のみ)
コントリビューション
- リポジトリをフォークします
- 機能ブランチを作成します
- 変更を加えます
- 該当する場合はテストを追加します
- プルリクエストを送信します
ライセンス
このプロジェクトは Apache 2.0 License の下でライセンスされています。詳細については LICENSE ファイルを参照してください。
トラブルシューティング
よくある問題
-
「Command not found」:
make pathを実行して再ビルドし、正しいパスを取得します- AI クライアントの設定にあるパスが出力と一致していることを確認します
-
「Permission denied」:実行ファイルに適切な権限があることを確認します。
chmod +x .build/release/SwiftDeveloperMCPServer # Or simply run 'make path' which handles this automatically -
Swift のバージョンの競合:複数のインストールがある場合は、
swiftlyを使用して Swift のバージョンを管理します。 -
ビルドの失敗:
- 最新の Xcode Command Line Tools がインストールされていることを確認します(macOS)。
xcode-select --install make pathコマンドを実行すると、エラーが発生した場合に詳細なビルドエラーが表示されます
- 最新の Xcode Command Line Tools がインストールされていることを確認します(macOS)。
-
設定の問題:
make pathコマンドは、サポートされているすべての AI クライアント向けに、そのままコピーできる設定例を提供します。
サーバーのデバッグ
サーバー自体をデバッグするには、main.swift ファイルにログを追加するか、Swift の詳細な出力を有効にして実行します。
swift run -v SwiftDeveloperMCPServer
ExampleLib でのテスト
このリポジトリには、非同期のフィボナッチ計算を含む完全な Swift パッケージ ExampleLib/ があり、MCP サーバーのデバッグ機能をテストするのに最適です。
ExampleLib のビルドと実行
ExampleLib ディレクトリに移動し、標準的な Swift コマンドを使用します。
cd ExampleLib
# Build the library and executable
swift build
# Run the demo application
swift run ExampleApp
# Run tests
swift test
MCP サーバーのデバッグツールを使ったテスト
ExampleLib プロジェクトは、MCP サーバーのデバッグ機能をテストするのに最適な環境です。デバッグのワークフロー全体をテストする方法は次のとおりです。
1. 基本的なビルドとテスト
MCP サーバーのツールを使用してビルドとテストを行います。
Use swift_build tool with:
- target: "ExampleApp"
- project_path: "/path/to/swift-developer-mcp-server/ExampleLib"
- configuration: "debug"
- verbose: true
Use swift_test tool with:
- project_path: "/path/to/swift-developer-mcp-server/ExampleLib"
- verbose: true
2. デバッグセッションのセットアップ
ExampleApp のデバッグセッションを開始します。
Use debug_start tool with:
- target: "ExampleApp"
- project_path: "/path/to/swift-developer-mcp-server/ExampleLib"
- arguments: [] (optional)
これにより、次の処理が行われます。
- ExampleApp ターゲットをビルドします
- LLDB セッションを開始します
- 実行ファイルをデバッグ用に読み込みます
3. ブレークポイントの設定
フィボナッチ計算を調査するため、適切な位置にブレークポイントを設定します。
Use debug_set_breakpoint tool with:
- file_path: "/path/to/ExampleLib/Sources/ExampleApp/main.swift"
- line_number: 89 (in performanceTest function)
- session_id: "your_session_id"
Use debug_set_breakpoint tool with:
- file_path: "/path/to/ExampleLib/Sources/ExampleLib/FibonacciCalculator.swift"
- line_number: 37 (inside calculate method)
- session_id: "your_session_id"
4. コードの実行とステップ実行
# Start execution
Use debug_continue tool with:
- session_id: "your_session_id"
# Step through code when breakpoint hits
Use debug_step tool with:
- session_id: "your_session_id"
- step_type: "over" (or "into", "out")
5. 変数とアクターの状態の調査
FibonacciCalculator はアクターであり、非同期デバッグのテストに最適です。
# Inspect the calculator actor
Use debug_inspect_variable tool with:
- session_id: "your_session_id"
- variable_name: "calculator"
# Inspect specific values
Use debug_inspect_variable tool with:
- session_id: "your_session_id"
- variable_name: "result"
# Evaluate expressions
Use debug_inspect_variable tool with:
- session_id: "your_session_id"
- expression: "await calculator.getCalculationCount()"
6. 並行処理のテスト
ExampleLib には、非同期処理のデバッグをテストするのに適した、並行実行されるフィボナッチ計算が含まれています。
# Set breakpoint in concurrent calculation method
Use debug_set_breakpoint tool with:
- file_path: "/path/to/ExampleLib/Sources/ExampleLib/FibonacciCalculator.swift"
- line_number: 57 (in calculateMultiple method)
- session_id: "your_session_id"
# Inspect concurrent task state
Use debug_inspect_variable tool with:
- session_id: "your_session_id"
- variable_name: "tasks"
7. キャッシュ動作の分析
非同期アクターのキャッシュ動作をデバッグしてテストします。
# Set conditional breakpoint for cache hits
Use debug_set_breakpoint tool with:
- file_path: "/path/to/ExampleLib/Sources/ExampleLib/FibonacciCalculator.swift"
- line_number: 19 (cache hit check)
- condition: "cached != nil"
- session_id: "your_session_id"
# Inspect cache state
Use debug_inspect_variable tool with:
- session_id: "your_session_id"
- expression: "await calculator.getCacheState()"
8. Swift Testing フレームワークのテスト
ExampleLib は Swift Testing フレームワークを使用しています。テスト実行のデバッグをテストします。
# Build and run tests with debugging
Use debug_start tool with:
- target: "ExampleLibTests"
- project_path: "/path/to/ExampleLib"
# Set breakpoints in test methods
Use debug_set_breakpoint tool with:
- file_path: "/path/to/ExampleLib/Tests/ExampleLibTests/FibonacciCalculatorTests.swift"
- line_number: 15 (in testBasicCalculations)
- session_id: "your_session_id"
9. デバッグ中のパフォーマンステスト
デバッグしながらパフォーマンステスト関数をテストします。
# Set breakpoint in performance test
Use debug_set_breakpoint tool with:
- file_path: "/path/to/ExampleLib/Sources/ExampleApp/main.swift"
- line_number: 95 (inside performanceTest)
- session_id: "your_session_id"
# Inspect timing variables
Use debug_inspect_variable tool with:
- session_id: "your_session_id"
- variable_name: "totalTime"
10. セッションのクリーンアップ
完了したら、必ずデバッグセッションをクリーンアップしてください。
Use debug_terminate tool with:
- session_id: "your_session_id"
想定されるデバッグシナリオ
ExampleLib では、以下のデバッグシナリオを利用できます。
- アクターの状態の確認:非同期アクターの状態と並行アクセスをデバッグします
- キャッシュの動作:キャッシュのヒット/ミスをリアルタイムで確認します
- 再帰計算:再帰的なフィボナッチ計算をステップ実行します
- 並行処理:複数の計算を同時にデバッグします
- エラー処理:エラー条件のデバッグをテストします
- パフォーマンスのボトルネック:計算の遅い経路を特定します
- テストの実行:Swift Testing フレームワークのテストをデバッグします
デバッグ出力の例
ExampleLib をデバッグすると、次のように表示されます。
Debug session started successfully.
Session ID: debug_12345678-1234-1234-1234-123456789abc
Target: ExampleApp
Executable: /path/to/ExampleLib/.build/debug/ExampleApp
Breakpoint set successfully.
File: /path/to/ExampleLib/Sources/ExampleApp/main.swift
Line: 89
Debug execution continued.
Session: debug_12345678-1234-1234-1234-123456789abc
Command: process launch
Running: true
Variable inspection results.
Session: debug_12345678-1234-1234-1234-123456789abc
Target: calculator
この包括的なテスト方法により、以下を検証できます。
- 実際の LLDB 統合
- Swift アクターのデバッグ
- 並行コードのデバッグ
- ブレークポイントの管理
- 変数の確認
- セッションのライフサイクル管理
サポート
問題や機能のリクエストについては、GitHub リポジトリで issue を作成してください。
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。