Xcode Diagnostics MCP server

Extracts and parses Xcode build errors and warnings from DerivedData logs, providing structured diagnostic information with file paths, line numbers, error messages, and fix-it suggestions for Swift projects.
Back to servers
Provider
Mike R. Manzano
Release date
Mar 12, 2025
Language
Python
Stats
4 stars

The Xcode Diagnostics MCP plugin connects to Xcode's build system to extract, parse, and display errors and warnings from your Swift projects. It helps AI assistants identify issues in your code without manually searching through build logs. The plugin works at the log level, so Xcode must have already attempted a build before you use this tool.

Prerequisites

  • macOS operating system
  • Xcode installed
  • Python 3.6+

Installation Options

Installing from PyPI

The simplest installation method:

pip install mcp-xcode-diagnostics

Installing from GitHub

Install directly from the GitHub repository:

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

Installing from Source

To install from source code:

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

Using the Plugin

The plugin provides two main tools that can be used with any MCP-compatible client:

Listing Available Xcode Projects

Use the get_xcode_projects tool to list all Xcode projects that have build logs in the DerivedData directory.

This tool takes no parameters and returns a list of projects.

Getting Project Diagnostics

Use the get_project_diagnostics tool to extract diagnostic information from a specific project's latest build log.

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)

Diagnostic Information

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

Error Types

  • Syntax errors
  • Type errors
  • Unresolved identifiers and missing imports
  • Protocol conformance errors
  • Generic parameter inference failures
  • Access control violations

Warning Types

  • Unused variables, constants, and results
  • Implicit conversions that may lose precision
  • Redundant code
  • Deprecation warnings
  • String interpolation issues
  • Swift concurrency warnings

Additional Information

  • Associated notes providing context for errors/warnings
  • Fix-it suggestions proposing code changes
  • Code snippets showing problematic code

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

Debug Information

For troubleshooting purposes, the plugin logs information to:

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

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later