No description
  • TypeScript 80%
  • Nix 11.4%
  • JavaScript 8.6%
Find a file
2026-11-14 20:50:48 +07:00
docs feat: support explicitly acknowledged Xcode allow-all mode 2026-11-14 20:50:48 +07:00
extensions/xcode feat: support explicitly acknowledged Xcode allow-all mode 2026-11-14 20:50:48 +07:00
nix feat: support explicitly acknowledged Xcode allow-all mode 2026-11-14 20:50:48 +07:00
scripts feat: support explicitly acknowledged Xcode allow-all mode 2026-11-14 20:50:48 +07:00
skills/xcode-device feat: support explicitly acknowledged Xcode allow-all mode 2026-11-14 20:50:48 +07:00
.gitignore feat: add project-scoped Xcode MCP integration 2026-11-14 12:27:28 +07:00
AGENTS.md feat: support explicitly acknowledged Xcode allow-all mode 2026-11-14 20:50:48 +07:00
flake.nix feat: add project-scoped Xcode MCP integration 2026-11-14 12:27:28 +07:00
package.json feat: support explicitly acknowledged Xcode allow-all mode 2026-11-14 20:50:48 +07:00
README.md feat: support explicitly acknowledged Xcode allow-all mode 2026-11-14 20:50:48 +07:00
tsconfig.json feat: add project-scoped Xcode MCP integration 2026-11-14 12:27:28 +07:00

Pi Xcode

Project-opted-in Apple Xcode integration for Pi, using Pi's native MCP client unchanged. No additional MCP adapter, transport, service manager, or credentials are installed.

Requirements

  • macOS with owner-managed Xcode 27.1-compatible headless tooling selected by xcode-select or DEVELOPER_DIR.
  • Pi 1.3+ with built-in MCP support enabled, running on Node.js 24+.
  • Owner-enabled headless Xcode with per-agent/folder permissions, or explicitly acknowledged owner-enabled global allow-all mode as described below.
  • A trusted project containing an .xcworkspace or .xcodeproj.

This first version checks readiness, registers the native MCP bridge, and provides explicit workspace preparation plus a device-workflow skill. It does not wrap builds/tests, automatically apply schemes/destinations, serialize different agents, or enforce isolation around raw MCP tools.

Install once, activate per project

Declarative installation

The flake intentionally has no nixpkgs input: it uses the consumer's pinned package set. Import homeManagerModules.default from this repository's flake input, then set:

programs.pi-xcode.enable = true;

The Home Manager module installs the pi-xcode CLI and makes these resources available outside Pi's automatic discovery directories:

~/.local/share/pi/optional-extensions/xcode/
~/.local/share/pi/optional-skills/xcode-device/

It does not edit Pi settings, enable Xcode, register a global MCP connection, or grant permissions. The flake also exposes lib.mkPackage pkgs for consumers not using Home Manager.

The consumer chooses the Git source/ref; flake.lock records the exact installed revision even when tracking main. Updating this package requires updating that input and activating the new Nix configuration. This repository does not edit or activate dotfiles automatically.

Project opt-in

Merge these entries into the project's .pi/settings.json, preserving existing resources:

{
  "extensions": ["~/.local/share/pi/optional-extensions/xcode"],
  "skills": ["~/.local/share/pi/optional-skills/xcode-device"]
}

The skill entry is optional. Start Pi from the project directory and complete its normal project-trust review. For a running session, use /reload after changing settings. Do not put the extension in ~/.pi/agent/extensions or add an always-enabled global Xcode MCP entry.

For local development before Nix installation, the same entries can point to the checked-out extensions/xcode and skills/xcode-device directories. Loading code does not imply permission to operate Xcode; its own approvals remain separate.

Optional target configuration

Create .pi/xcode.json at the nearest Git repository/worktree root (or the Pi working directory when there is no Git root):

{
  "workspace": "ios/MyApp.xcworkspace",
  "scheme": "MyApp",
  "destination": "the requested iPhone simulator"
}

These are our settings, not built-in Pi fields. All are optional; unknown fields are rejected. The optional boolean acknowledgeUnsafeAllAgents defaults to false; it acknowledges an owner-selected global Xcode policy, not project-scoped access or a request to change permissions. Workspace paths resolve from that root and must remain inside it after symlink resolution. Scheme/destination strings are preferences only: the agent must inspect available targets and explicitly verify actual settings before an operation. Keep personal device identifiers in local, uncommitted configuration where appropriate.

Without workspace, discovery scans at most three directory levels, 1000 directories, 10,000 entries per directory, and 50 candidates. It excludes hidden/generated dependency directories, does not follow directory symlinks, stops at nested repositories, and never searches unrelated open Xcode projects. A same-directory App.xcworkspace/App.xcodeproj pair prefers the workspace. All other multiple candidates require explicit configuration; there is no guessed fallback.

Runtime behavior

  1. Loading the extension registers commands/tools only; no subprocesses run in its factory.
  2. On session_start, it requires Pi project trust, resolves the workspace, and reads headless Xcode status with bounded CLI calls.
  3. Only if preflight succeeds, it calls pi.registerMcpServer("xcode", ...) for xcrun mcpbridge, using codemode exposure and a 120-second request timeout. Pi owns connection lifecycle and reconnects.
  4. Connecting can start Apple's already-enabled background service. Startup does not open a project or grant permissions.
  5. /xcode open or xcode_project with action: "open" explicitly requests opening the selected workspace. It may require owner approval. The request is never retried automatically.
  6. Native XcodeListWorkspaces provides the real workspaceIdentifier. The agent must match its path exactly and discover current tool schemas before proceeding.
  7. Readiness/policy is rechecked before each agent turn and each new mcp__xcode__* tool call, including calls nested through codemode. An unsafe mode change without acknowledgment blocks new calls; already-running operations are not cancelled.
  8. Active global allow-all produces JSON/model-context warnings, a persistent Xcode: UNSAFE ALLOW-ALL footer, and a warning notification on entering that mode. Blocked unsafe mode remains visibly marked too. Changes are noticed on the next preflight, not through a background poller.
  9. Shutdown removes only this Pi session's bridge registration. It never stops the shared backend or shuts down a device/simulator.

A separate xcode entry in mcp.json overrides extension registration under Pi's native rules. Do not define both; /mcp shows the effective source. Registration, CLI exit success, and MCP transport success are not proof of permission or successful app verification.

Commands and tools

Interface Behavior
/xcode or /xcode status Read project/headless readiness; no connection or open request.
/xcode connect Recheck readiness and register the bridge if not already registered.
/xcode open Recheck and request opening only the selected workspace; register the bridge if needed.
xcode_project({"action":"status"}) Model-callable readiness and canonical target context.
xcode_project({"action":"open"}) Model-callable explicit open request with the same safety checks.
/mcp Pi's native connection/tool/error management.
/mcp reconnect xcode Explicitly reconnect through Pi after resolving connection issues.
/skill:xcode-device Load the optional device-workflow instructions.

Run the helper without starting Pi or connecting MCP:

pi-xcode --help
pi-xcode status --project /path/to/project
pi-xcode open --project /path/to/project

status only reads filesystem/toolchain/headless metadata; it does not start Xcode. open can start the already-enabled backend and request opening the selected project. JSON goes to stdout; errors and active-policy warnings go to stderr. Exit 1 means not ready or failure; acknowledged allow-all can return ready/exit 0 but always retains its warning. The open response reports preflight state and request acceptance, not verified workspace readiness. From a checkout, use node scripts/pi-xcode.mjs instead of pi-xcode.

Owner-controlled setup

Read the installed command help; never approve requests or execute privileged changes automatically. For the checked Xcode 27.1 installation:

xcrun mcp-server status
sudo xcrun mcp-server enable
sudo xcrun mcp-server allow-folder /path/to/project --for-24-hours

After an intended agent request appears, inspect its identity in status before the owner runs:

sudo xcrun mcp-server approve REQUEST_ID --for-24-hours

Signed agents and folders can receive durable grants with --always; unsigned agents cannot. The current CLI has open, not start. CLI workspace loading does not authorize an MCP agent: in normal mode, the first native MCP XcodeOpenWorkspace call may request owner approval. Missing approvals, failed/uncertain opens, or ambiguous targets require human judgment, not automatic retries or replacement sessions.

Explicit owner acknowledgment of global allow-all

Per-agent mode remains the default. If the owner deliberately chooses to trust every local client that can reach Xcode's MCP service, version 0.2.0+ supports that existing native mode without silently accepting it. This is a global service policy, not a grant limited to this project, Pi session, or extension.

  1. Deploy/activate the updated package first. Version 0.1.0 rejects the new configuration field; do not add it to a live project using that version.

  2. After explicit owner approval, merge this into that project's existing .pi/xcode.json without replacing its target settings:

    { "acknowledgeUnsafeAllAgents": true }
    

    Never add/change this acknowledgment automatically to repair readiness or silence a warning. It does not enable Xcode's native mode.

  3. Only the owner runs the privileged command:

    sudo xcrun mcp-server enable --unsafe-always-allow-all-agents
    xcrun mcp-server status --format json
    
  4. Reload the project session. Check /xcode status for the true acknowledgment, the active native flag, and its warning. The footer must display UNSAFE ALLOW-ALL. Projects without the acknowledgment are blocked by this extension.

To return to per-agent mode, the owner runs sudo xcrun mcp-server enable without the unsafe flag, then verifies unsafeAlwaysAllowAllAgents is false with status --format json. Acknowledgment can be removed/set false afterward. The extension never runs either privileged command or changes grants; it does not reset permissions or stop the shared service.

Safety and concurrency limits

Project trust controls loading, not filesystem or MCP access isolation. Separate bridge processes are not per-agent project sandboxes. The extension validates its own selected workspace/open request and rechecks readiness/allow-all acknowledgment before new native mcp__xcode__* calls. It does not validate every raw tool's workspace arguments, guard generic resource tools, constrain shell commands, or protect other clients of the globally permissive service.

Preparation is serialized inside one Pi process only. Different agents still share workspace scheme/destination state, build resources, and devices. Coordinate those operations and use separate worktrees for simultaneous writers. The skill instructs cleanup of only known, workflow-owned device sessions; the extension does not automatically track or clean native device sessions.

The extension never enables headless access, grants permissions, invokes sudo, automatically launches an app or runs a build/test, or stops shared services. App operations remain explicit uses of the native MCP tools. Xcode, platform runtimes, signing, and device provisioning remain owner-managed.

Development and validation

No runtime npm dependencies are bundled. Pi supplies the peer SDK packages. Do not imperatively install dependencies to bypass the Nix setup.

The flake exposes lib.mkTypecheck { pkgs, piPackage }, which runs TypeScript using the supplied pinned Pi package's lib/node_modules SDK/types and the consumer's TypeScript package. This is a static compiler check, not an automated test runner. Alternatively, run tsc --project tsconfig.json in a declarative development environment that already resolves those types.

Useful non-mutating checks:

node --check scripts/pi-xcode.mjs
node scripts/pi-xcode.mjs --help
node scripts/pi-xcode.mjs status --project .
nixfmt --check flake.nix nix/*.nix

A repository without an Xcode target should report not ready and exit 1. Loading the extension through Pi's resource loader can validate registration without dispatching session_start or connecting to Xcode. No automated tests, fixtures, or mocks are included.

Live acceptance still requires an owner-approved real application: confirm project-local activation, connect, open the intended workspace, verify its native identifier, perform an explicitly authorized app/device operation, and end only that workflow's interaction session. This is not implied by static checks.