Xcode Diagnostics MCP Plugin

by leftspin
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Enables installation of the plugin directly from its GitHub repository.

  • Interfaces with macOS to access Xcode DerivedData directories and retrieve build logs for diagnostic analysis.

  • Allows installation of the plugin directly from the Python Package Index using pip.

Xcode 診断 MCP プラグイン

Xcode ビルド ログからエラーと警告を抽出して表示するための MCP (Model Control Protocol) プラグイン。

概要

このプラグインは、Model Control Protocol(MCP)仕様を実装し、互換性のあるAIアシスタントにXcodeの診断機能を提供します。Xcodeのビルドシステムに接続し、Swiftプロジェクトから診断情報(エラーと警告)を抽出、解析、表示します。これにより、AIアシスタントはビルドログを手動で検索することなく、コード内の問題を迅速に特定できるようになります。

これはログ レベルで機能するため、このツールを実行する前に Xcode がすでにビルドを試行している必要があることに注意してください。

前提条件

  • macOSオペレーティングシステム
  • Xcodeがインストールされている
  • Python 3.6以上

インストール

PyPIからのインストール

Xcode Diagnostics MCP プラグインをインストールする最も簡単な方法:

pip install mcp-xcode-diagnostics

GitHubからのインストール

GitHub から直接インストールできます:

pip install git+https://github.com/leftspin/mcp-xcode-diagnostics.git

ソースからインストールする

ソースからインストールするには:

  1. このリポジトリをクローンまたはダウンロードする
  2. pip を使用してプラグインをインストールします。
    cd mcp-xcode-diagnostics pip install .

このプラグインは、MCP 互換のあらゆるクライアントで使用できるようになりました。

特徴

  • DerivedData にビルドログがあるすべての Xcode プロジェクトを一覧表示します
  • 特定のプロジェクトの最新のビルドログからエラーと警告を抽出します
  • 関連するメモや修正提案を含む複雑な診断を解析します
  • ファイルパス、行番号、エラーメッセージなど、各問題に関する詳細情報を提供します。
  • Swiftの並行性に関する警告をキャプチャするために最適化されています

サポートされている診断タイプ

プラグインは、次のようなさまざまな種類の Xcode 診断を検出して表示できます。

エラー

  • 構文エラー(例:「{' が必要です」または「式が必要です」)
  • 型エラー(例:「型Xの値を期待される引数型Yに変換できない」)
  • 未解決の識別子と欠落したインポート
  • プロトコル適合エラー
  • 一般的なパラメータ推論の失敗
  • アクセス制御違反

警告

  • 未使用の変数、定数、および結果
  • 精度が失われる可能性のある暗黙の変換
  • 冗長なコードや不要な表現
  • 非推奨の警告
  • 文字列補間の問題
  • Swift の同時実行に関する警告には以下が含まれます:
    • 非分離グローバル共有可変状態警告
    • 主役の孤立に関する警告
    • プロトコル適合同時実行警告
    • アクター分離違反
    • Swift 6 言語モードの互換性に関する警告

メモと修正案

  • エラーや警告に関する追加のコンテキストを提供する関連メモ
  • 問題を解決するためのコード変更を提案する修正提案
  • 問題のあるコードを示すコードスニペット

制限事項

  • ランタイムログのバイナリ/シリアル化形式は完全に解析されない可能性があります
  • 高度に専門化された診断フォーマットは認識されない場合があります
  • 非常に大きなビルドログは切り捨てられる可能性がある
  • プロジェクト固有のカスタム診断が適切に分類されない可能性があります

MCPツール

プラグインは、2 つの主要な MCP ツールを提供します。

get_xcode_projects

DerivedData ディレクトリ内のビルド ログを含むすべての Xcode プロジェクトを一覧表示します。

パラメータ: なし

get_project_diagnostics

特定のプロジェクトの最新のビルド ログから診断情報を取得します。

パラメータ:

  • project_dir_name : DerivedData内のプロジェクトのディレクトリ名(例: 'ProjectName-hash')
  • include_warnings : エラーに加えて警告を含めるかどうか(デフォルト: True)

デバッグ情報

デバッグの目的で、プラグインは生のログ出力を次の場所に保存します。

  • /tmp/xcode-mcp-debug.log - メインアプリケーションログ
  • /tmp/xcode-diagnostic-raw.log - Xcode アクティビティ ログからの生の出力

出力例

{ "success": true, "log_file": "/path/to/build.xcactivitylog", "timestamp": "2025-03-11T12:34:56.789", "errors": [ { "type": "error", "message": "use of unresolved identifier 'NonExistentType'", "file_path": "/path/to/MyFile.swift", "line_number": 42, "column": 15, "code": " let x: NonExistentType = value", "notes": [] } ], "warnings": [ { "type": "warning", "message": "static property 'sharedInstance' is not concurrency-safe because it is nonisolated global shared mutable state; this is an error in the Swift 6 language mode", "file_path": "/path/to/SharedManager.swift", "line_number": 10, "column": 16, "code": " static var sharedInstance: SharedManager?", "notes": [ { "type": "note", "message": "convert 'sharedInstance' to a 'let' constant to make 'Sendable' shared state immutable", "file_path": "/path/to/SharedManager.swift", "line_number": 10, "column": 16 } ] } ], "error_count": 1, "warning_count": 1 }

テスト

プラグインには解析機能を検証するためのテスト スイートが含まれています。

# Run all tests python -m unittest test_xcode_diagnostics.py

ライセンス

このプロジェクトは MIT ライセンスの下で利用可能です。

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

Xcode のビルド システムに接続して、Swift プロジェクトからエラーと警告を抽出、解析、表示し、AI アシスタントがビルド ログを手動で検索することなくコードの問題を迅速に特定できるようにします。

  1. Overview
    1. Prerequisites
      1. Installation
        1. Installing from PyPI
        2. Installing from GitHub
        3. Installing from source
      2. Features
        1. Supported Diagnostic Types
          1. Errors
          2. Warnings
          3. Notes and Fix-it Suggestions
        2. Limitations
          1. MCP Tools
            1. get_xcode_projects
            2. get_project_diagnostics
          2. Debug Information
            1. Example Output
              1. Testing
                1. License
                  ID: mavqfwluan