Xcode MCP Broker

Xcode MCP Broker

A localhost broker that allows multiple MCP clients to share a persistent xcrun mcpbridge connection to Xcode, enabling tool discovery and serialized calls.

Category
访问服务器

README

Xcode MCP Broker

A small localhost broker that lets multiple MCP clients share one persistent xcrun mcpbridge connection to Xcode.

With the broker, Xcode authorization normally happens once per Xcode launch. After allowing the broker connection, agents can delegate work to subagents, custom tools, and external scripts that reuse it instead of starting another bridge and requesting access again.

OpenCode ------------\
Custom MCP clients ----> localhost broker --> mcpbridge --> Xcode
Automation scripts ---/

The broker exposes a Streamable HTTP endpoint, serializes calls to Xcode, forwards progress and cancellation, caches tool discovery, and reconnects when Xcode restarts. It binds to 127.0.0.1 by default.

Requirements

  • macOS with an Xcode version that provides xcrun mcpbridge
  • Node.js 18 or later

Xcode compatibility

The broker does not hardcode Xcode's tools. It reads tools/list from mcpbridge and refreshes the cache when the bridge reconnects or Xcode sends a tools/list_changed notification. New, removed, or changed tools should therefore be picked up automatically after an Xcode update without requiring a broker release. Connected MCP clients are notified when the cached tool list changes.

This has been tested with the latest Xcode 27 beta available at the time of testing. Future Xcode versions should remain compatible as long as mcpbridge continues to implement the standard MCP lifecycle and tool APIs.

If XCODE_MCP_ALLOWED_TOOLS is set, newly added tools remain hidden until they are added to that allowlist. xcrun also uses the active developer directory, so make sure a newly installed Xcode is selected with xcode-select when necessary.

Installation

Clone the repository, install dependencies, and run the tests:

git clone https://github.com/grahammckee/XcodeMCPBroker.git
cd XcodeMCPBroker
npm install
npm test

Install the broker as a user LaunchAgent:

npm run service:install

The installer uses the current Node executable and repository path, starts the broker at login, and writes logs to ~/Library/Logs/xcode-mcp-broker.log.

Xcode does not need to be open when the service starts. The broker remains available and retries until Xcode launches. Xcode may show its normal Allow dialog when the connection is first established.

OpenCode

Point OpenCode at the broker in ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "xcode": {
      "type": "remote",
      "url": "http://127.0.0.1:7341/mcp",
      "oauth": false,
      "enabled": true
    }
  }
}

Restart OpenCode after changing its configuration.

Verification

curl --fail http://127.0.0.1:7341/healthz
npm run broker:smoke
launchctl print gui/$(id -u)/com.gmicc.opencode-xcode-mcp-broker

The smoke command waits up to 60 seconds for initial Xcode discovery, then lists the available tools and calls the read-only XcodeListWindows tool.

To run the broker in the foreground instead:

npm run broker:start

To remove the LaunchAgent:

npm run service:uninstall

Configuration

Variable Default Purpose
XCODE_MCP_BROKER_HOST 127.0.0.1 HTTP bind address
XCODE_MCP_BROKER_PORT 7341 HTTP port
XCODE_MCP_BRIDGE_COMMAND /usr/bin/xcrun Bridge executable
XCODE_MCP_ALLOWED_TOOLS all tools Comma-separated tool allowlist
XCODE_MCP_REQUEST_TIMEOUT_MS 600000 Downstream request timeout
XCODE_MCP_SESSION_IDLE_TIMEOUT_MS 300000 Idle upstream session timeout

These variables are read directly when running in the foreground. To persist an override in the LaunchAgent, provide it while installing:

XCODE_MCP_ALLOWED_TOOLS="XcodeListWindows,BuildProject" npm run service:install

The broker does not provide authentication. Keep it bound to the loopback interface unless you add an appropriate access-control layer.

Contributing

Issues and pull requests are welcome. For code changes:

  1. Create a focused branch from the current default branch.
  2. Add or update tests for protocol, lifecycle, or concurrency behavior.
  3. Run npm test.
  4. If the change affects the live transport, run npm run broker:smoke with Xcode open.
  5. Explain the behavior change and verification performed in the pull request.

Downstream calls are intentionally serialized. Changes to concurrency, cancellation, or retry behavior should account for Xcode operations whose outcome may be uncertain after a connection failure.

License

Licensed under the MIT License.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选