xcsift-mcp

xcsift-mcp

An MCP server that enables AI assistants to parse Xcode and Swift build outputs into structured, token-efficient formats like JSON or TOON. It provides tools for executing build commands and extracting detailed diagnostic information such as errors, warnings, and test failures.

Category
访问服务器

README

xcsift-mcp

An MCP (Model Context Protocol) server that wraps xcsift, enabling AI coding assistants to parse Xcode build output into structured, token-efficient formats.

Python 3.10+ License: MIT MCP

Overview

xcsift-mcp provides AI coding assistants (like Claude, OpenCode, Cursor, etc.) with tools to:

  • Parse raw xcodebuild or swift build/test output into structured JSON or TOON format
  • Execute build commands and get parsed results automatically
  • Extract errors, warnings, test failures, and linker errors with file/line information
  • Analyze code coverage from test runs

The output is optimized for token efficiency, with TOON format providing 30-60% fewer tokens compared to JSON.

Installation

Prerequisites

  • Python 3.10+
  • macOS (xcsift is macOS-only)
  • pipx (install via brew install pipx)

Install from source

git clone https://github.com/johnnyclem/xcsift_mcp.git
cd xcsift_mcp
pipx install -e ".[dev]"

Install via Homebrew

brew install johnnyclem/xcsift-mcp/xcsift-mcp

xcsift Binary

The server will automatically download the xcsift binary from GitHub releases on first run if it's not already installed. The binary is cached in ~/.local/share/xcsift-mcp/bin/.

You can also install it manually via Homebrew:

brew install xcsift

Usage

Running the Server

# Run with stdio transport (default, for Claude Desktop/OpenCode)
xcsift-mcp

# Run with HTTP transport (for debugging/web clients)
xcsift-mcp --transport http --port 8000

Integration with AI Assistants

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "xcsift": {
      "command": "xcsift-mcp"
    }
  }
}

OpenCode

Add to your opencode.json (or opencode.jsonc):

{
  "mcp": {
    "xcsift": {
      "type": "local",
      "command": ["xcsift-mcp"]
    }
  }
}

Alternatively, run opencode mcp add and follow the interactive prompts.

Cursor

Add to your MCP configuration in Cursor settings, or add to .cursor/mcp.json:

{
  "mcpServers": {
    "xcsift": {
      "command": "xcsift-mcp"
    }
  }
}

Available Tools

Parsing Tools

Tool Description
parse_xcodebuild_output Parse raw xcodebuild/swift output into JSON or TOON format
extract_errors Extract only errors with file/line information
extract_warnings Extract only warnings with file/line/type
extract_test_failures Extract failed tests with assertion messages
get_build_summary Get a quick summary with error/warning counts

Build Execution Tools

Tool Description
xcodebuild Run xcodebuild and parse output automatically
swift_build Run swift build for SPM projects
swift_test Run swift test with optional coverage
run_shell_build_command Run arbitrary build commands and parse output

Tool Parameters

parse_xcodebuild_output

Parameter Type Default Description
output string required Raw xcodebuild/swift output (use 2>&1 to capture stderr)
format "json" | "toon" "json" Output format
include_warnings bool false Include detailed warnings list
include_coverage bool false Include coverage data if available

xcodebuild

Parameter Type Default Description
action "build" | "test" | "clean" | "analyze" "build" Build action
scheme string none Scheme to build
project string none Path to .xcodeproj
workspace string none Path to .xcworkspace
destination string none Destination (e.g., "platform=iOS Simulator,name=iPhone 15")
configuration "Debug" | "Release" none Build configuration
enable_code_coverage bool false Enable coverage for tests
output_format "json" | "toon" "json" Output format
timeout int 600 Timeout in seconds

swift_build

Parameter Type Default Description
configuration "debug" | "release" "debug" Build configuration
package_path string none Path to Swift package
target string none Specific target to build
output_format "json" | "toon" "json" Output format
timeout int 300 Timeout in seconds

swift_test

Parameter Type Default Description
package_path string none Path to Swift package
filter_test string none Filter tests (e.g., "MyTests.testFoo")
enable_code_coverage bool false Enable coverage collection
parallel bool true Run tests in parallel
output_format "json" | "toon" "json" Output format
timeout int 600 Timeout in seconds

Example Usage

Parse existing build output

# In your AI assistant
result = parse_xcodebuild_output(
    output="<raw xcodebuild output>",
    format="toon",  # or "json"
    include_warnings=True
)

Run build and get parsed results

result = xcodebuild(
    action="build",
    scheme="MyApp",
    destination="platform=iOS Simulator,name=iPhone 15",
    output_format="json"
)

Run tests with coverage

result = swift_test(
    enable_code_coverage=True,
    output_format="toon"
)

Extract just the errors

errors = extract_errors(output="<raw xcodebuild output>")
# Returns: [{"file": "main.swift", "line": 15, "message": "..."}]

Output Formats

JSON Format

Standard structured JSON output:

{
  "status": "failed",
  "summary": {
    "errors": 1,
    "warnings": 3,
    "failed_tests": 0,
    "linker_errors": 0,
    "build_time": "3.2s"
  },
  "errors": [
    {
      "file": "main.swift",
      "line": 15,
      "message": "use of undeclared identifier 'unknown'"
    }
  ],
  "warnings": [
    {
      "file": "view.swift",
      "line": 20,
      "message": "variable 'temp' was never used",
      "type": "compile"
    }
  ]
}

TOON Format (Token-Optimized)

30-60% fewer tokens than JSON:

status: failed
summary:
  errors: 1
  warnings: 3
  failed_tests: 0
  linker_errors: 0
  build_time: 3.2s
errors[1]{file,line,message}:
  main.swift,15,"use of undeclared identifier 'unknown'"
warnings[1]{file,line,message,type}:
  view.swift,20,"variable 'temp' was never used","compile"

When to use each format:

  • JSON: When you need to parse the output programmatically or integrate with other tools
  • TOON: When sending to an LLM to reduce token usage and API costs

Available Resources

Resource URI Description
xcsift://version xcsift version and installation info
xcsift://config-template Example .xcsift.toml configuration
xcsift://output-formats Documentation about output formats
xcsift://help Comprehensive help documentation

Available Prompts

Prompt Description Arguments
analyze_build_failure Template for analyzing build failures errors, code_context
fix_compiler_errors Template for fixing Swift/ObjC compiler errors errors, file_content
improve_test_coverage Template for improving test coverage coverage_report, target_coverage
debug_test_failures Template for debugging test failures test_output, test_code
fix_linker_errors Template for fixing linker errors linker_errors, project_structure
analyze_build_performance Template for analyzing build performance build_info

Development

Running Tests

pytest

Running Tests with Coverage

pytest --cov=xcsift_mcp

Code Formatting

ruff format .
ruff check .

Project Structure

xcsift_mcp/
├── src/xcsift_mcp/
│   ├── __init__.py           # Package init
│   ├── __main__.py           # Entry point
│   ├── server.py             # FastMCP server
│   ├── xcsift_installer.py   # Auto-download xcsift
│   ├── resources.py          # MCP resources
│   ├── prompts.py            # Prompt templates
│   └── tools/
│       ├── parse.py          # Parsing tools
│       └── build.py          # Build execution tools
├── tests/
│   ├── fixtures/             # Sample build outputs
│   └── test_*.py             # Test files
├── pyproject.toml
└── README.md

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                 AI Assistant (Claude, OpenCode, etc.)           │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                     MCP Protocol (stdio/HTTP)                    │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                     xcsift MCP Server (Python)                   │
│  ┌─────────────────┐  ┌──────────────────┐  ┌────────────────┐  │
│  │   Tools (9)     │  │  Resources (4)   │  │  Prompts (6)   │  │
│  │ - parse_output  │  │ - version        │  │ - analyze      │  │
│  │ - xcodebuild    │  │ - config         │  │ - fix_errors   │  │
│  │ - swift_build   │  │ - formats        │  │ - coverage     │  │
│  │ - swift_test    │  │ - help           │  │ - debug        │  │
│  └─────────────────┘  └──────────────────┘  └────────────────┘  │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                     xcsift CLI (subprocess)                      │
└─────────────────────────────────────────────────────────────────┘

Troubleshooting

xcsift not found

If xcsift cannot be downloaded automatically, install it manually:

brew install xcsift

Permission denied

Ensure the xcsift binary has execute permissions:

chmod +x ~/.local/share/xcsift-mcp/bin/xcsift

Build timeout

Increase the timeout parameter for long builds:

xcodebuild(scheme="MyApp", timeout=1200)  # 20 minutes

License

MIT License - see LICENSE for details.

Credits

  • xcsift - The Swift CLI tool that does the actual parsing
  • MCP Python SDK - Model Context Protocol implementation

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选