XcodeBuildMCPdocs
Install

Session Defaults

Set shared values once per session (workspace, scheme, simulator, etc.) and every tool reuses them automatically.

Session defaults are the single biggest token saver when working with an agent. Instead of your agent re-asking for project path, scheme, and simulator on every tool call, it sets them once and all subsequent calls reuse the values.

Session defaults are on by default.

How it works#

  1. The agent calls session_set_defaults once at the start of the session (or you seed them in config).
  2. Every tool call with a matching parameter uses the default if not explicitly passed.
  3. The agent can call session_show_defaults to inspect the current values at any time.
  4. The agent can call session_clear_defaults when switching contexts.

Setting defaults#

From the agent (runtime)#

json
{
  "name": "session_set_defaults",
  "arguments": {
    "workspacePath": "/repo/MyApp.xcworkspace",
    "scheme": "MyApp",
    "simulatorName": "iPhone 17 Pro"
  }
}

By default these live in memory only. Pass persist: true to write them back to .xcodebuildmcp/config.yaml, patch-only, so only the keys in that call are updated.

From config (startup)#

Seed defaults when the server boots by adding a sessionDefaults block to .xcodebuildmcp/config.yaml:

yaml
schemaVersion: 1
sessionDefaults:
  projectPath: "./MyApp.xcodeproj"
  scheme: "MyApp"
  simulatorName: "iPhone 17 Pro"
  configuration: "Debug"

From environment variables (MCP client bootstrap)#

When your MCP client can't supply workspace context directly, use env vars:

json
{
  "env": {
    "XCODEBUILDMCP_WORKSPACE_PATH": "/repo/MyApp.xcworkspace",
    "XCODEBUILDMCP_SCHEME": "MyApp",
    "XCODEBUILDMCP_SIMULATOR_NAME": "iPhone 17 Pro"
  }
}

See Environment Variables for the full list.

Reference#

OptionTypeDescription
projectPathstringPath to .xcodeproj. Mutually exclusive with workspacePath.
workspacePathstringPath to .xcworkspace. Takes precedence if both are set.
schemestringBuild scheme name.
configurationstringBuild configuration (Debug, Release).
simulatorNamestringSimulator name (e.g. iPhone 17). Mutually exclusive with simulatorId.
simulatorIdstringSimulator UUID. Takes precedence if both are set.
deviceIdstringPhysical device UUID.
platformstringTarget platform (iOS, macOS, watchOS, tvOS, visionOS).
useLatestOSbooleanUse the latest available OS for the simulator.
archstringBuild architecture (arm64, x86_64).
suppressWarningsbooleanSuppress compiler warnings in build output.
derivedDataPathstringCustom derived data path.
preferXcodebuildbooleanUse xcodebuild instead of experimental incremental builds per call.
bundleIdstringApp bundle identifier.

Mutual exclusivity#

  • projectPath vs workspacePathworkspacePath wins if both are set.
  • simulatorId vs simulatorNamesimulatorId wins if both are set.

Named profiles#

For monorepos, keep separate defaults per sub-project. Each profile is strictly isolated, values are not inherited from the global profile.

yaml
schemaVersion: 1
sessionDefaultsProfiles:
  ios:
    workspacePath: ./MyApp.xcworkspace
    scheme: MyApp-iOS
    simulatorName: iPhone 17 Pro
  watch:
    workspacePath: ./MyApp.xcworkspace
    scheme: MyApp-watchOS
    simulatorName: Apple Watch Series 10 (45mm)
activeSessionDefaultsProfile: ios

The agent switches profiles with session_use_defaults_profile:

json
{
  "name": "session_use_defaults_profile",
  "arguments": { "profile": "watch", "persist": true }
}

Pass global: true to switch back to the unnamed global profile. Pass createIfNotExists: true on session_set_defaults to create a new profile in one call.

Copy/paste for an agent starting a new session:

json
{"name":"session_use_defaults_profile","arguments":{"profile":"ios","persist":true}}
{"name":"session_set_defaults","arguments":{
  "workspacePath":"/repo/MyApp.xcworkspace",
  "scheme":"MyApp-iOS",
  "simulatorName":"iPhone 17 Pro",
  "persist":true
}}
{"name":"session_show_defaults","arguments":{}}

Opting out#

If you prefer explicit parameters on every tool call, set this at the top level of your config:

yaml
disableSessionDefaults: true

Or via env:

shell
export XCODEBUILDMCP_DISABLE_SESSION_DEFAULTS=true

This restores the legacy behavior where every parameter must be passed on every call.

CLI behavior#

The CLI auto-fills matching flags from session defaults. If your config sets scheme, projectPath, and simulatorName, xcodebuildmcp simulator build just works, no need to repeat those flags. Override for a single call with --profile <name> or by passing the flag explicitly.

See CLI for more.