Skip to content

Commit 890c75f

Browse files
cameroncookeclaude
andcommitted
feat(session): Add namespaced session defaults profiles
Add profile-aware session defaults so agents can switch between global and named defaults in multi-target projects. Keep existing global defaults behavior fully backward compatible while enabling per-profile persistence in project config. Add session_use_defaults_profile, config schema support, runtime/bootstrap wiring, docs updates, and tests for profile activation and persistence behavior. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a01a1f1 commit 890c75f

31 files changed

Lines changed: 965 additions & 91 deletions

docs/SESSION_DEFAULTS.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,40 @@ The persistence is patch-only: only keys provided in that call are written (plus
2525

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

28+
## Namespaced profiles
29+
Session defaults support named profiles so one workspace can keep separate defaults for iOS/watchOS/macOS (or any custom profile names).
30+
31+
- Use `session_use_defaults_profile` to switch the active profile.
32+
- Existing tools (`session_set_defaults`, `session_show_defaults`, build/test tools) use the active profile automatically.
33+
- Use `global: true` to switch back to the unnamed global profile.
34+
- Set `persist: true` on `session_use_defaults_profile` to write `activeSessionDefaultsProfile` in `.xcodebuildmcp/config.yaml`.
35+
36+
## Recommended startup flow (monorepo / multi-target)
37+
Copy/paste this sequence when starting a new session:
38+
39+
```json
40+
{"name":"session_use_defaults_profile","arguments":{"profile":"ios","persist":true}}
41+
{"name":"session_set_defaults","arguments":{
42+
"workspacePath":"/repo/MyApp.xcworkspace",
43+
"scheme":"MyApp-iOS",
44+
"simulatorName":"iPhone 16 Pro",
45+
"persist":true
46+
}}
47+
{"name":"session_show_defaults","arguments":{}}
48+
```
49+
50+
Switch targets later in the same session:
51+
52+
```json
53+
{"name":"session_use_defaults_profile","arguments":{"profile":"watch","persist":true}}
54+
{"name":"session_set_defaults","arguments":{
55+
"workspacePath":"/repo/MyApp.xcworkspace",
56+
"scheme":"MyApp-watchOS",
57+
"simulatorName":"Apple Watch Series 10 (45mm)",
58+
"persist":true
59+
}}
60+
```
61+
2862
## Related docs
2963
- Configuration options: [CONFIGURATION.md](CONFIGURATION.md)
3064
- Tools reference: [TOOLS.md](TOOLS.md)

docs/TOOLS-CLI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,4 @@ XcodeBuildMCP provides 73 canonical tools organized into 13 workflow groups.
189189

190190
---
191191

192-
*This documentation is automatically generated by `scripts/update-tools-docs.ts` from the tools manifest. Last updated: 2026-02-17T14:53:05.834Z UTC*
192+
*This documentation is automatically generated by `scripts/update-tools-docs.ts` from the tools manifest. Last updated: 2026-02-17T16:38:52.535Z UTC*

docs/TOOLS.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# XcodeBuildMCP MCP Tools Reference
22

3-
This document lists MCP tool names as exposed to MCP clients. XcodeBuildMCP provides 78 canonical tools organized into 15 workflow groups for comprehensive Apple development workflows.
3+
This document lists MCP tool names as exposed to MCP clients. XcodeBuildMCP provides 79 canonical tools organized into 15 workflow groups for comprehensive Apple development workflows.
44

55
## Workflow Groups
66

@@ -126,11 +126,12 @@ This document lists MCP tool names as exposed to MCP clients. XcodeBuildMCP prov
126126

127127

128128
### Session Management (`session-management`)
129-
**Purpose**: Manage session defaults for project/workspace paths, scheme, configuration, simulator/device settings. (4 tools)
129+
**Purpose**: Manage session defaults for project/workspace paths, scheme, configuration, simulator/device settings. (5 tools)
130130

131131
- `session_clear_defaults` - Clear session defaults.
132132
- `session_set_defaults` - Set the session defaults, should be called at least once to set tool defaults.
133133
- `session_show_defaults` - Show session defaults.
134+
- `session_use_defaults_profile` - Select the active session defaults profile for multi-target workflows.
134135
- `sync_xcode_defaults` - Sync session defaults (scheme, simulator) from Xcode's current IDE selection.
135136

136137

@@ -198,10 +199,10 @@ This document lists MCP tool names as exposed to MCP clients. XcodeBuildMCP prov
198199

199200
## Summary Statistics
200201

201-
- **Canonical Tools**: 78
202-
- **Total Tools**: 102
202+
- **Canonical Tools**: 79
203+
- **Total Tools**: 103
203204
- **Workflow Groups**: 15
204205

205206
---
206207

207-
*This documentation is automatically generated by `scripts/update-tools-docs.ts` from the tools manifest. Last updated: 2026-02-17T14:53:05.834Z UTC*
208+
*This documentation is automatically generated by `scripts/update-tools-docs.ts` from the tools manifest. Last updated: 2026-02-17T16:38:52.535Z UTC*
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
id: session_use_defaults_profile
2+
module: mcp/tools/session-management/session_use_defaults_profile
3+
names:
4+
mcp: session_use_defaults_profile
5+
cli: use-defaults-profile
6+
description: Select the active session defaults profile for multi-target workflows.
7+
annotations:
8+
title: Use Session Defaults Profile
9+
readOnlyHint: true

manifests/workflows/session-management.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ selection:
99
autoInclude: true
1010
tools:
1111
- session_show_defaults
12+
- session_use_defaults_profile
1213
- session_set_defaults
1314
- session_clear_defaults
1415
- sync_xcode_defaults

src/cli/yargs-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function buildYargsApp(opts: YargsAppOptions): ReturnType<typeof yargs> {
5757
setLogLevel(level);
5858
}
5959
})
60-
.version(version)
60+
.version(String(version))
6161
.help()
6262
.alias('h', 'help')
6363
.alias('v', 'version')

src/core/manifest/__tests__/load-manifest.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ describe('load-manifest', () => {
3333
expect(manifest.tools.has('build_sim')).toBe(true);
3434
expect(manifest.tools.has('discover_projs')).toBe(true);
3535
expect(manifest.tools.has('session_show_defaults')).toBe(true);
36+
expect(manifest.tools.has('session_use_defaults_profile')).toBe(true);
3637
});
3738

3839
it('should validate tool references in workflows', () => {

src/daemon.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ async function main(): Promise<void> {
392392
pid: process.pid,
393393
startedAt,
394394
enabledWorkflows: daemonWorkflows,
395-
version,
395+
version: String(version),
396396
});
397397

398398
writeLine(`Daemon started (PID: ${process.pid})`);

src/mcp/tools/doctor/doctor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export async function runDoctor(
136136
);
137137

138138
const doctorInfo = {
139-
serverVersion: version,
139+
serverVersion: String(version),
140140
timestamp: new Date().toISOString(),
141141
system: systemInfo,
142142
node: nodeInfo,

src/mcp/tools/session-management/__tests__/session_clear_defaults.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,17 @@ describe('session-clear-defaults tool', () => {
5050
});
5151

5252
it('should clear all when all=true', async () => {
53+
sessionStore.setActiveProfile('ios');
54+
sessionStore.setDefaults({ scheme: 'IOS' });
55+
sessionStore.setActiveProfile(null);
5356
const result = await sessionClearDefaultsLogic({ all: true });
5457
expect(result.isError).toBe(false);
5558
expect(result.content[0].text).toBe('Session defaults cleared');
5659

5760
const current = sessionStore.getAll();
5861
expect(Object.keys(current).length).toBe(0);
62+
expect(sessionStore.listProfiles()).toEqual([]);
63+
expect(sessionStore.getActiveProfile()).toBeNull();
5964
});
6065

6166
it('should clear all when no params provided', async () => {

0 commit comments

Comments
 (0)