Skip to content

Commit 2d9923d

Browse files
committed
Add configuration file and session-default persistance
1 parent 634bb43 commit 2d9923d

40 files changed

Lines changed: 1252 additions & 506 deletions

CHANGELOG.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
# Changelog
22

33
## [Unreleased]
4+
5+
### Breaking
6+
- By default when the `enabledWorkflows` configuration option or `XCODEBUILDMCP_ENABLED_WORKFLOWS` environment variable is not set or empty, XcodeBuildMCP will default to loading only the `simulator` workflow. This a change in behaviour, previously it would load all workflows and therefore tools by default.
7+
8+
This change is to reduce the number of tools loaded by default and requires the user to opt-in to enable the use of additional sets of tools based on their project or workflow requirements.
9+
10+
The reason the simulator workflow is the default is because it is the most common use case based on opt-in analytics data.
11+
12+
For more information see the [CONFIGURATION.md](docs/CONFIGURATION.md) documentation.
13+
14+
- Tool names and descriptions have been made more concise to redune token consumption. Tool argument names that are self explanatory have had their descriptions removed entirely.
15+
416
### Added
517
- Add Smithery support for packaging/distribution.
618
- Add DAP-based debugger backend and simulator debugging toolset (attach, breakpoints, stack, variables, LLDB command).
719
- Add session-status MCP resource with session identifiers.
820
- Add UI automation guard that blocks UI tools when the debugger is paused.
9-
- Add manage-workflows tool for live workflow selection updates.
10-
- Add a bundled XcodeBuildMCP skill to improve MCP client tool discovery.
21+
- Add `manage-workflows` tool to allow agents to change the workflows enable/disabling tools at runtime. This requires clients to support tools changed notifications. (opt-in only)
22+
- Add XcodeBuildMCP skill to improve MCP client tool use/discovery, this needs to be installed see [README.md](README.md) for more information.
23+
- Added support for `.xcodebuildmcp/config.yaml` files for runtime configuration, this is a more flexible and powerful way to configure XcodeBuildMCP than environment variables.
24+
- Added support for session-aware defaults that are persisted between sessions in the config file.
1125

1226
### Changed
1327
- Migrate to Zod v4.
1428
- Improve session default handling (reconcile mutual exclusivity and ignore explicit undefined clears).
1529
- Auto-include workflow-discovery when workflow selection is configured.
1630
- Remove dynamic tool discovery (`discover_tools`) and `XCODEBUILDMCP_DYNAMIC_TOOLS`. Use `XCODEBUILDMCP_ENABLED_WORKFLOWS` to limit startup tool registration.
1731
- Add MCP tool annotations to all tools.
18-
32+
- Route runtime configuration reads through the config store with layered precedence.
33+
- Treat missing/empty `enabledWorkflows` as "load all workflows".
34+
- Add config.yaml support for DAP/log capture tuning (`dapRequestTimeoutMs`, `dapLogEvents`, `launchJsonWaitMs`).
35+
1936
### Fixed
2037
- Update UI automation guard guidance to point at `debug_continue` when paused.
2138
- Fix tool loading bugs in static tool registration.

config.example.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
schemaVersion: 1
2+
enabledWorkflows: ["simulator", "ui-automation", "debugging"]
3+
experimentalWorkflowDiscovery: false
4+
disableSessionDefaults: false
5+
incrementalBuildsEnabled: false
6+
sessionDefaults:
7+
projectPath: "./MyApp.xcodeproj" # xor workspacePath
8+
workspacePath: "./MyApp.xcworkspace" # xor projectPath
9+
scheme: "MyApp"
10+
configuration: "Debug"
11+
simulatorName: "iPhone 16" # xor simulatorId
12+
simulatorId: "<UUID>" # xor simulatorName
13+
deviceId: "<UUID>"
14+
useLatestOS: true
15+
arch: "arm64"
16+
suppressWarnings: false
17+
derivedDataPath: "./.derivedData"
18+
preferXcodebuild: false
19+
platform: "iOS"
20+
bundleId: "com.example.myapp"

docs/CONFIGURATION.md

Lines changed: 128 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,28 @@
11
# Configuration
22

3-
XcodeBuildMCP is configured through environment variables provided by your MCP client. Here is a single example showing how to add options to a typical MCP config:
4-
5-
```json
6-
"XcodeBuildMCP": {
7-
"command": "npx",
8-
"args": ["-y", "xcodebuildmcp@latest"],
9-
"env": {
10-
"XCODEBUILDMCP_ENABLED_WORKFLOWS": "simulator,device,project-discovery",
11-
"INCREMENTAL_BUILDS_ENABLED": "false",
12-
"XCODEBUILDMCP_DISABLE_SESSION_DEFAULTS": "false",
13-
"XCODEBUILDMCP_SENTRY_DISABLED": "false"
14-
}
15-
}
16-
```
17-
18-
## Workflow selection
19-
20-
By default, XcodeBuildMCP loads the `simulator` workflow at startup (plus `session-management`). If you want a smaller or different tool surface, set `XCODEBUILDMCP_ENABLED_WORKFLOWS` to a comma-separated list of workflow directory names. The `session-management` workflow is always auto-included since other tools depend on it. When `XCODEBUILDMCP_DEBUG=true`, the `doctor` workflow is also auto-included.
21-
22-
**Available workflows:**
23-
- `device` (14 tools) - iOS Device Development
24-
- `simulator` (19 tools) - iOS Simulator Development
25-
- `logging` (4 tools) - Log Capture & Management
26-
- `macos` (11 tools) - macOS Development
27-
- `project-discovery` (5 tools) - Project Discovery
28-
- `project-scaffolding` (2 tools) - Project Scaffolding
29-
- `utilities` (1 tool) - Project Utilities
30-
- `session-management` (3 tools) - session-management
31-
- `workflow-discovery` (1 tool) - Workflow Discovery
32-
- `debugging` (8 tools) - Simulator Debugging
33-
- `simulator-management` (8 tools) - Simulator Management
34-
- `swift-package` (6 tools) - Swift Package Manager
35-
- `doctor` (1 tool) - System Doctor
36-
- `ui-testing` (11 tools) - UI Testing & Automation
37-
38-
## Incremental build support
39-
40-
XcodeBuildMCP includes experimental support for incremental builds. This feature is disabled by default and can be enabled by setting the `INCREMENTAL_BUILDS_ENABLED` environment variable to `true`.
41-
42-
> [!IMPORTANT]
43-
> Incremental builds are highly experimental and your mileage may vary. Please report issues to the [issue tracker](https://github.com/cameroncooke/XcodeBuildMCP/issues).
3+
XcodeBuildMCP reads configuration from a project config file and environment variables. The config file is optional but provides deterministic, repo-scoped behavior for every session.
444

45-
## Experimental workflow discovery
46-
47-
Set `XCODEBUILDMCP_EXPERIMENTAL_WORKFLOW_DISCOVERY=true` to auto-include the `workflow-discovery` workflow at startup.
48-
49-
The workflow discovery tool lets agents and clients enable or disable workflows at runtime. This can reduce upfront context by loading only what is needed as the session evolves. Note: most clients do not yet support the MCP notifications required for an agent harness to re-query the tool list after changes.
50-
51-
## Session-aware opt-out
5+
## Precedence
6+
For runtime config (non-session defaults), precedence is:
7+
1. `.xcodebuildmcp/config.yaml`
8+
2. Environment variables
529

53-
By default, XcodeBuildMCP uses a session-aware mode: the LLM (or client) sets shared defaults once (simulator, device, project/workspace, scheme, etc.), and all tools reuse them. This cuts context bloat not just in each call payload, but also in the tool schemas themselves.
10+
## Config file (config.yaml)
5411

55-
If you prefer the older, explicit style where each tool requires its own parameters, set `XCODEBUILDMCP_DISABLE_SESSION_DEFAULTS=true`. This restores the legacy schemas with per-call parameters while still honoring any session defaults you choose to set.
56-
57-
Leave this unset for the streamlined session-aware experience; enable it to force explicit parameters on each tool call.
58-
59-
## Project config (config.yaml)
60-
61-
You can provide deterministic session defaults for every AI coding session by creating a project config file at:
12+
Create a config file at your workspace root.
6213

6314
```
6415
<workspace-root>/.xcodebuildmcp/config.yaml
6516
```
6617

67-
Notes:
68-
- Put the file in your **workspace root** (where your Xcode project is located).
69-
- Agents can persist changes by calling `session_set_defaults` with `"persist": true` (see below).
70-
71-
### Schema
18+
Example:
7219

7320
```yaml
7421
schemaVersion: 1
22+
enabledWorkflows: ["simulator, ui-automation, debugging"]
23+
experimentalWorkflowDiscovery: false
24+
disableSessionDefaults: false
25+
incrementalBuildsEnabled: false
7526
sessionDefaults:
7627
projectPath: "./MyApp.xcodeproj" # xor workspacePath
7728
workspacePath: "./MyApp.xcworkspace" # xor projectPath
@@ -89,31 +40,138 @@ sessionDefaults:
8940
bundleId: "com.example.myapp"
9041
```
9142
92-
Behavior:
93-
- Relative paths in `projectPath`, `workspacePath`, and `derivedDataPath` resolve against the workspace root at load time.
43+
Notes:
44+
- `schemaVersion` is required and currently only supports `1`.
9445
- If both `projectPath` and `workspacePath` are set, **workspacePath wins**.
9546
- If both `simulatorId` and `simulatorName` are set, **simulatorId wins**.
9647

9748
### Persisting defaults from an agent
9849

9950
By default, when the agent calls `session_set_defaults`, defaults are only stored in memory for that session. To persist them to the config file, ask the agent to set the `persist` flag to `true`.
10051

52+
## Workflow selection
53+
54+
By default, XcodeBuildMCP loads all workflows at startup.
55+
56+
You can configure workflows in either:
57+
- `enabledWorkflows` in `config.yaml` (preferred), or
58+
- via environment variable `XCODEBUILDMCP_ENABLED_WORKFLOWS` (comma-separated)
59+
60+
Notes:
61+
- If `enabledWorkflows` is omitted, empty or not set, only the default `simulator` workflow is loaded.
62+
63+
See [TOOLS.md](TOOLS.md) for a list of available workflows and tools.
64+
65+
## Debug logging
66+
67+
Enable debug logging with:
68+
- `debug: true` in `config.yaml` (preferred), or
69+
- via environment variable `XCODEBUILDMCP_DEBUG=true`
70+
71+
This enables an extra doctor tool that agents can run to get MCP and system environment information useful for debugging issues with XcodeBuildMCP.
72+
73+
## Incremental build support
74+
75+
Enable incremental builds with either:
76+
- `incrementalBuildsEnabled: true` in `config.yaml` (preferred), or
77+
- via environment variable `INCREMENTAL_BUILDS_ENABLED=true`
78+
10179
> [!IMPORTANT]
102-
> The write is **patch-only**: only keys provided in that call are written (plus any removals needed for mutual exclusivity).
80+
> Incremental builds are experimental and won't work for all projects. If you encounter issues, you can disable the option. The agent can also bypass incremental builds by passing a flag when calling build tools.
81+
82+
## Experimental workflow discovery
83+
84+
Enable via:
85+
- `experimentalWorkflowDiscovery: true` in `config.yaml` (preferred), or
86+
- via environment variable `XCODEBUILDMCP_EXPERIMENTAL_WORKFLOW_DISCOVERY=true`
87+
88+
Enables experimental workflow discovery, this feature adds a `manage-workflows` tool that the agent can use to add/remove workflows at runtime. This requires clients to support tools changed notifications and therefore is an opt-in and experimental feature.
89+
90+
> [!IMPORTANT]
91+
> At time of writing neither Cursor, Claude Code or Codex support tools changed notifications.
92+
93+
## Session-aware opt-out
94+
95+
Disable session-aware schemas with:
96+
- `disableSessionDefaults: true` in `config.yaml` (preferred), or
97+
- via environment variable `XCODEBUILDMCP_DISABLE_SESSION_DEFAULTS=true`
98+
99+
Disables the session-aware defaults feature. This means that the agent will need to set the defaults for each tool call explictly. This is not recommended and will use more tokens per call. It's recommended to only enable this if your specific requirements need the build, device and simulator settings change frequently in a single coding session, i.e. monorepos with multiple projects.
100+
101+
## UI automation guard
102+
103+
Control UI automation when a debugger is paused with:
104+
- `uiDebuggerGuardMode: "error" | "warn" | "off"` in `config.yaml` (preferred), or
105+
- via environment variable `XCODEBUILDMCP_UI_DEBUGGER_GUARD_MODE=error|warn|off`
106+
107+
This feature is used to block UI tools when the debugger is paused, this is to prevent the agent from executing UI tools that will fail or return incorrect results when the debugger is paused.
108+
109+
Default is `error` when unset.
103110

104111
## Sentry telemetry opt-out
105112

106-
If you do not wish to send error logs to Sentry, set `XCODEBUILDMCP_SENTRY_DISABLED=true`.
113+
Disable Sentry with:
114+
- `XCODEBUILDMCP_SENTRY_DISABLED=true`
115+
116+
By default we send error logs to Sentry, this can be disabled to prevent any error logs from being sent.
117+
118+
See [PRIVACY.md](PRIVACY.md) for more information.
107119

108120
## AXe binary override
109121

110-
UI automation and simulator video capture require the AXe binary. By default, XcodeBuildMCP uses the bundled AXe when available, then falls back to `PATH`. To force a specific binary location, set `XCODEBUILDMCP_AXE_PATH` (preferred). `AXE_PATH` is also recognized for compatibility.
122+
UI automation and simulator video capture require AXe. By default AXe is bundled with XcodeBuildMCP, but you can override the path to use a different version of AXe by setting these options.
111123

112-
Example:
124+
Configure the binary path with:
125+
- `axePath: "/opt/axe/bin/axe"` in `config.yaml` (preferred), or
126+
- via environment variable `XCODEBUILDMCP_AXE_PATH=/opt/axe/bin/axe`
113127

114-
```
115-
XCODEBUILDMCP_AXE_PATH=/opt/axe/bin/axe
116-
```
128+
For more information about AXe see: [https://github.com/cameroncooke/axe](https://github.com/cameroncooke/axe).
129+
130+
## Template overrides
131+
132+
The macOS and iOS scaffold tools pull templates from https://github.com/cameroncooke/XcodeBuildMCP-macOS-Template and https://github.com/cameroncooke/XcodeBuildMCP-iOS-Template respectively.
133+
134+
If you want to use your own source/fork for templates you can override the default locations and versions by setting these options.
135+
136+
Set custom template locations and versions with:
137+
- `iosTemplatePath` / `macosTemplatePath` in `config.yaml` (preferred), or
138+
- via environment variable `XCODEBUILDMCP_IOS_TEMPLATE_PATH=/path/to/ios/templates`
139+
- via environment variable `XCODEBUILDMCP_MACOS_TEMPLATE_PATH=/path/to/macos/templates`
140+
- `iosTemplateVersion` / `macosTemplateVersion` in `config.yaml`, or
141+
- `XCODEBUILD_MCP_IOS_TEMPLATE_VERSION=v1.2.3`
142+
- `XCODEBUILD_MCP_MACOS_TEMPLATE_VERSION=v1.2.3`
143+
144+
These override the default template versions bundled in the package.
145+
146+
## Debugger backend
147+
148+
Select the debugger backend with:
149+
- `debuggerBackend: "dap" | "lldb-cli"` in `config.yaml`, or
150+
- `XCODEBUILDMCP_DEBUGGER_BACKEND=dap|lldb-cli`
151+
152+
This overridens the debugger backend and defaults to `dap`. It's not generally recommended to change this.
153+
154+
## DAP backend settings
155+
156+
Tune the DAP backend with:
157+
- `dapRequestTimeoutMs: 30000` in `config.yaml`, or
158+
- `XCODEBUILDMCP_DAP_REQUEST_TIMEOUT_MS=30000`
159+
160+
This overrides the default request timeout of 30 seconds.
161+
162+
Enable DAP event logging with:
163+
- `dapLogEvents: true` in `config.yaml`, or
164+
- `XCODEBUILDMCP_DAP_LOG_EVENTS=true`
165+
166+
This enables logging of DAP events to the console.
167+
168+
## Device log capture JSON wait
169+
170+
Control how long we wait for devicectl JSON output with:
171+
- `launchJsonWaitMs: 8000` in `config.yaml`, or
172+
- `XBMCP_LAUNCH_JSON_WAIT_MS=8000`
173+
174+
This overrides the default wait time of 8 seconds for devicectl JSON output.
117175

118176
## Related docs
119177
- Session defaults: [SESSION_DEFAULTS.md](SESSION_DEFAULTS.md)

docs/GETTING_STARTED.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ Most MCP clients use JSON configuration. Add the following to your client config
3434
}
3535
```
3636

37+
## Project config (optional)
38+
For deterministic session defaults and runtime configuration, add a config file at:
39+
40+
```
41+
<workspace-root>/.xcodebuildmcp/config.yaml
42+
```
43+
44+
See [CONFIGURATION.md](CONFIGURATION.md) for the full schema and examples.
45+
3746
## Client-specific configuration
3847

3948
### OpenAI Codex CLI
@@ -43,7 +52,7 @@ Codex uses TOML for MCP configuration. Add this to your Codex CLI config file:
4352
[mcp_servers.XcodeBuildMCP]
4453
command = "npx"
4554
args = ["-y", "xcodebuildmcp@latest"]
46-
env = { "INCREMENTAL_BUILDS_ENABLED" = "false", "XCODEBUILDMCP_SENTRY_DISABLED" = "false" }
55+
env = { "XCODEBUILDMCP_SENTRY_DISABLED" = "false" }
4756
```
4857

4958
If you see tool calls timing out (for example, `timed out awaiting tools/call after 60s`), increase the timeout:
@@ -61,7 +70,7 @@ https://github.com/openai/codex/blob/main/docs/config.md#connecting-to-mcp-serve
6170
claude mcp add XcodeBuildMCP npx xcodebuildmcp@latest
6271

6372
# Or with environment variables
64-
claude mcp add XcodeBuildMCP npx xcodebuildmcp@latest -e INCREMENTAL_BUILDS_ENABLED=false -e XCODEBUILDMCP_SENTRY_DISABLED=false
73+
claude mcp add XcodeBuildMCP npx xcodebuildmcp@latest -e XCODEBUILDMCP_SENTRY_DISABLED=false
6574
```
6675

6776
Note: XcodeBuildMCP requests xcodebuild to skip macro validation to avoid Swift Macro build errors.

docs/SESSION_DEFAULTS.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,21 @@ By default, XcodeBuildMCP uses a session-aware mode. The client sets shared defa
77
- Tools reuse those defaults automatically.
88
- Agent can call `session_show_defaults` to inspect current values.
99
- Agent can call `session_clear_defaults` to clear values when switching contexts.
10-
- Defaults can also be seeded from `.xcodebuildmcp/config.yaml` at server startup.
10+
- Defaults can be seeded from `.xcodebuildmcp/config.yaml` at server startup.
1111

1212
See the session-management tools in [TOOLS.md](TOOLS.md).
1313

1414
## Opting out
15-
If you prefer explicit parameters on every tool call, set:
15+
If you prefer explicit parameters on every tool call, set `disableSessionDefaults: true` in your `.xcodebuildmcp/config.yaml` file.
1616

17-
```json
18-
"env": {
19-
"XCODEBUILDMCP_DISABLE_SESSION_DEFAULTS": "true"
20-
}
21-
```
17+
This restores the legacy schemas with per-call parameters while still honoring any defaults you choose to set.
2218

23-
This restores the legacy schemas with per-call parameters while still honoring any defaults you choose to set. Though this is not recommended, it can be useful in certain scenarios where you are working on monorepos or multiple projects at once.
19+
See [CONFIGURATION.md](CONFIGURATION.md) for more information.
2420

2521
## Persisting defaults
26-
Session defaults can be persisted between sessions by asking your agent to set the defaults with the `persist` flag set to `true`. This will save the defaults into `.xcodebuildmcp/config.yaml` at the root of your project's workspace.
22+
Session defaults can be persisted between sessions by setting the `persist` flag to `true` on `session_set_defaults`. This writes to `.xcodebuildmcp/config.yaml` at the root of your workspace.
2723

28-
The persisted config is patch-only (only provided keys are written).
24+
The persistence is patch-only: only keys provided in that call are written (plus any removals needed for mutual exclusivity).
2925

3026
You can also manually create the config file to essentially seed the defaults at startup; see [CONFIGURATION.md](CONFIGURATION.md) for more information.
3127

docs/TOOLS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ XcodeBuildMCP provides 72 tools organized into 14 workflow groups for comprehens
3434

3535
- `start_device_log_cap` - Start device log capture.
3636
- `start_sim_log_cap` - Start sim log capture.
37-
- `stop_device_log_cap` - Stop device log capture.
38-
- `stop_sim_log_cap` - Stop sim log capture.
37+
- `stop_device_log_cap` - Stop device app and return logs.
38+
- `stop_sim_log_cap` - Stop sim app and return logs.
3939
### macOS Development (`macos`)
4040
**Purpose**: Complete macOS development workflow for both .xcodeproj and .xcworkspace files. Build, test, deploy, and manage macOS applications. (6 tools)
4141

@@ -126,4 +126,4 @@ XcodeBuildMCP provides 72 tools organized into 14 workflow groups for comprehens
126126

127127
---
128128

129-
*This documentation is automatically generated by `scripts/update-tools-docs.ts` using static analysis. Last updated: 2026-01-27*
129+
*This documentation is automatically generated by `scripts/update-tools-docs.ts` using static analysis. Last updated: 2026-01-28*

0 commit comments

Comments
 (0)