How to use the Xcode 27 MCP server and agent tools

Issue #1074

Xcode 27 ships a set of tools made for coding agents. There’s an MCP server that exposes Xcode’s build system, previews, tests and simulators, a command line tool that edits .xcodeproj files, new devicectl commands for screenshots and device settings, and a pack of skills written by Apple. Each one covers a different part of the loop, so it helps to know which tool does what before wiring them into Claude Code, Codex or Cursor.

The Xcode MCP server

The entry point is mcpbridge, a small stdio bridge between an MCP client and Xcode’s tool service. Register it once per repo:

bash
claude mcp add --scope project xcode -- xcrun mcpbridge

This writes a .mcp.json at the repo root, so teammates get the same setup. Each person still approves the server on their own machine.

Xcode controls access in Settings > Intelligence, under Model Context Protocol. “Allow External Agents to Use Xcode Tools” can be Always, While Xcode is Open, or Never.

Xcode MCP setting

With Always, the tools run headless, with Xcode closed, which is handy for agents that run in a terminal or on a build machine. The mcp-server command manages that mode from the terminal:

bash
sudo xcrun mcp-server enable    # turn headless mode on
xcrun mcp-server status         # is it running, which agents and folders are allowed
xcrun mcp-server show-logs      # dump what agents did

The first time an agent opens a project, Xcode asks for permission for that folder. sudo xcrun mcp-server clear-permissions removes every grant if you want to start over.

There’s also xcrun agent claude, which launches Claude Code with Xcode’s configuration already in place. It’s quicker for a first try, but nothing ends up in your repo, so the .mcp.json route is better for a team.

What the MCP tools can do

Xcode 27.2 exposes 54 tools. The agent can create projects from Xcode’s templates (XcodeNewProject), edit files through the project navigator, build (BuildProject), run tests, and render a #Preview to a PNG without opening the canvas (RenderPreview). It can also change build settings and entitlements, fill in String Catalog translations, send lldb commands, and search Apple’s documentation (DocumentationSearch).

The device tools close the loop. DeviceInteractionInstallAndRun builds and launches the app on a simulator or device, and DeviceInteractionSynthesize taps, swipes and types, then returns a screenshot and the UI hierarchy so the agent can see what changed. GetConsoleOutput reads the app’s logs.

Create a project from the command line

The MCP route makes projects from Xcode’s templates. When you want to build the structure yourself, for example in a script or an agent that shouldn’t depend on Xcode running, Xcode 27 has xcodeproj. It reads and writes .xcodeproj files directly:

bash
mkdir -p Notes/Sources && cd Notes
# put NotesApp.swift in Sources

xcrun xcodeproj init Notes.xcodeproj
xcrun xcodeproj target add Notes --product-type application
xcrun xcodeproj target phase add --target Notes sources
xcrun xcodeproj group add Sources --filesystem-path Sources
xcrun xcodeproj group include --group Sources --target Notes
xcrun xcodeproj setting set SDKROOT macosx
xcrun xcodeproj setting set SWIFT_VERSION 6.0 --target Notes

init makes an empty project, and a new target starts with no build phases, so add a sources phase before including any files. group add --filesystem-path creates a folder-synchronized group, the same kind Xcode 16 and later create by default, so any Swift file you drop in Sources gets compiled without touching the project again. After these commands, xcodebuild -scheme Notes build produces a working app.

The tool also covers packages and inspection:

bash
xcrun xcodeproj pkg add https://github.com/apple/swift-collections --from 1.1.0 --product Collections --target Notes
xcrun xcodeproj target list
xcrun xcodeproj group ls
xcrun xcodeproj setting list --target Notes

It only edits the .xcodeproj. Workspaces, schemes and the contents of .xcconfig files are out of its scope.

devicectl for captures and device state

devicectl has been around since Xcode 15 for installing and launching apps on devices. Xcode 27 adds a lot more under xcrun devicectl device:

bash
xcrun devicectl device capture screenshot --device <id> --destination shot.png
xcrun devicectl device capture screen-record --device <id> --destination demo.mov --duration 10
xcrun devicectl device orientation set --device <id> landscapeLeft
xcrun devicectl device settings appearance --device <id> --mode dark
echo "hello" | xcrun devicectl device pasteboard copy --device <id>
xcrun devicectl device pasteboard paste --device <id>

settings appearance also takes text size, increase contrast and reduce motion, and there are settings voiceover, simulate location, simulate statusBar and simulate biometrics. Add --json-output - to any command to get stable JSON for scripts.

What devicectl doesn’t do is interact with the UI. There’s no tap or type command, and no way to read the view hierarchy. Use it to set up a device and capture the result, and leave interaction to the MCP device tools or a UI test.

Device Hub

In Xcode 27, simulators run in Device Hub, which also shows connected iPhones. You can view and control a real phone’s screen from your Mac, which is handy for a quick check or a demo. It’s a manual tool though. It has no scripting interface, so an agent can’t drive it. For automation, use the MCP device tools and devicectl.

Apple’s agent skills

The last piece is knowledge. Xcode 27 bundles skills written by Apple, and they’re plain SKILL.md folders that any agent which reads skills can use. Export them into your repo:

bash
xcrun agent skills export "$PWD/.claude/skills"

Use an absolute path. The export runs inside Xcode, so a relative path resolves against / and fails with a read-only volume error. Pass --replace-existing to update them after an Xcode upgrade.

If you’d rather not export them into every repo, or want them on a machine without Xcode 27, I packaged an export as a Claude Code plugin in xcode-skills. Install it with the skills CLI or as a plugin:

bash
npx skills add onmyway133/xcode-skills
text
/plugin marketplace add onmyway133/xcode-skills
/plugin install xcode-skills@xcode-skills

The repo was exported from an earlier Xcode 27 build, so its list and names differ a little from what 27.2 exports. When the two disagree, trust xcrun agent skills export.

Xcode 27.2 exports these:

  • swiftui-specialist: SwiftUI best practices for data flow, ForEach identity, @Observable, environment and localization
  • swiftui-whats-new-27: new SwiftUI APIs in iOS 27, like reorderable(), swipe actions outside List, and @State becoming a macro
  • app-intents-specialist and app-intents-whats-new-27: App Intents rules and the iOS 26 and 27 additions
  • building-document-based-swiftui-applications: the new Document protocol and DocumentGroup APIs
  • app-resizability: layouts that adapt to resizable windows, Stage Manager and foldable iPhones
  • modernize-tests: moving from XCTest to Swift Testing
  • device-interaction: how to drive a device through the MCP interaction tools
  • xctrace: profiling with Instruments from the command line
  • audit-xcode-security-settings and adopt-c-bounds-safety: hardening build settings and C code

The “what’s new” skills matter most. A model trained before iOS 27 doesn’t know these APIs, and the skill gives it Apple’s own reference instead of a guess.

Written by

I’m open source contributor, writer, speaker and product maker.

Start the conversation