Skip to main content

MCP plugin for extracting and viewing Xcode build errors and warnings

Project description

Xcode Diagnostics MCP Plugin

An MCP (Model Control Protocol) plugin for extracting and viewing errors and warnings from Xcode build logs.

Overview

This plugin implements the Model Control Protocol (MCP) specification to provide Xcode diagnostics functionality to any compatible AI assistants. It connects to Xcode's build system to extract, parse, and display diagnostics (errors and warnings) from your Swift projects. It helps AI assistants quickly identify issues in your code without having to manually search through build logs.

Note that since this works at the log level, Xcode must have already attempted a build before you run this tool.

Prerequisites

  • macOS operating system
  • Xcode installed
  • Python 3.6+

Installation

Installing from PyPI

The simplest way to install the Xcode Diagnostics MCP plugin:

pip install mcp-xcode-diagnostics

Installing from GitHub

You can install directly from GitHub:

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

Installing from source

To install from source:

  1. Clone or download this repository
  2. Install the plugin using pip:
    cd mcp-xcode-diagnostics
    pip install .
    

The plugin can now be used with any MCP-compatible client.

Features

  • Lists all Xcode projects that have build logs in DerivedData
  • Extracts errors and warnings from the latest build log of a specific project
  • Parses complex diagnostics, including associated notes and fix-it suggestions
  • Provides detailed information about each issue, including file paths, line numbers, and error messages
  • Optimized for capturing Swift concurrency-related warnings

Supported Diagnostic Types

The plugin can detect and display various types of Xcode diagnostics including:

Errors

  • Syntax errors (e.g., "expected '{'" or "expected expression")
  • Type errors (e.g., "cannot convert value of type X to expected argument type Y")
  • Unresolved identifiers and missing imports
  • Protocol conformance errors
  • Generic parameter inference failures
  • Access control violations

Warnings

  • Unused variables, constants, and results
  • Implicit conversions that may lose precision
  • Redundant code or unnecessary expressions
  • Deprecation warnings
  • String interpolation issues
  • Swift concurrency warnings, including:
    • Non-isolated global shared mutable state warnings
    • Main actor isolation warnings
    • Protocol conformance concurrency warnings
    • Actor isolation violations
    • Swift 6 language mode compatibility warnings

Notes and Fix-it Suggestions

  • Associated notes that provide additional context for errors and warnings
  • Fix-it suggestions that propose code changes to resolve issues
  • Code snippets showing the problematic code

Limitations

  • Binary/serialized formats in runtime logs may not be fully parsed
  • Some highly specialized diagnostic formats may not be recognized
  • Very large build logs may be truncated
  • Project-specific custom diagnostics might not be properly categorized

MCP Tools

The plugin provides two main MCP tools:

get_xcode_projects

Lists all Xcode projects with build logs in the DerivedData directory.

Parameters: None

get_project_diagnostics

Gets diagnostic information from the latest build log of a specific project.

Parameters:

  • project_dir_name: Directory name of the project in DerivedData (e.g., 'ProjectName-hash')
  • include_warnings: Whether to include warnings in addition to errors (default: True)

Debug Information

For debugging purposes, the plugin saves raw log output to:

  • /tmp/xcode-mcp-debug.log - Main application logs
  • /tmp/xcode-diagnostic-raw.log - Raw output from Xcode activity logs

Example Output

{
  "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
}

Testing

The plugin includes a test suite to verify parsing functionality:

# Run all tests
python -m unittest test_xcode_diagnostics.py

License

This project is available under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file iflow_mcp_leftspin_mcp_xcode_diagnostics-1.0.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_leftspin_mcp_xcode_diagnostics-1.0.0.tar.gz
  • Upload date:
  • Size: 38.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_leftspin_mcp_xcode_diagnostics-1.0.0.tar.gz
Algorithm Hash digest
SHA256 956eb7448913ed894c3ef8d513f37c516530e36f2b2a4b490e58e43d1c39d52e
MD5 655c4504d284695b1cb563ca34b9012d
BLAKE2b-256 5311c01ced91318502d65bda4117760ff689c6de50cd73aa17368e12bee0c24f

See more details on using hashes here.

File details

Details for the file iflow_mcp_leftspin_mcp_xcode_diagnostics-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_leftspin_mcp_xcode_diagnostics-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_leftspin_mcp_xcode_diagnostics-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de47b00a71ca3bfe4c3a0a9262e7d68d01c8b6c66e080d81109ded0376a68c92
MD5 24e80d3971ca8881db4304b16cbf681e
BLAKE2b-256 ae8639627af093516db082d31a8b02794692afae578a35e2784df6183932f8a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page