Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ enabledWorkflows: ['simulator', 'ui-automation', 'debugging']
experimentalWorkflowDiscovery: false
disableSessionDefaults: false
incrementalBuildsEnabled: false
debug: false
sentryDisabled: false
sessionDefaults:
projectPath: './MyApp.xcodeproj' # xor workspacePath
workspacePath: './MyApp.xcworkspace' # xor projectPath
Expand Down
5 changes: 5 additions & 0 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ xcodebuildmcp --help

# View tool help
xcodebuildmcp <workflow> <tool> --help

# Run interactive setup for .xcodebuildmcp/config.yaml
xcodebuildmcp setup
```

## Tool Options
Expand Down Expand Up @@ -116,6 +119,8 @@ enabledWorkflows:

See [CONFIGURATION.md](CONFIGURATION.md) for the full schema.

To create/update config interactively, run `xcodebuildmcp setup`.

## Environment Variables

| Variable | Description |
Expand Down
19 changes: 16 additions & 3 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Create a config file at your workspace root:
<workspace-root>/.xcodebuildmcp/config.yaml
```

Or run the interactive setup wizard:

```bash
xcodebuildmcp setup
```

Minimal example:

```yaml
Expand Down Expand Up @@ -61,6 +67,7 @@ incrementalBuildsEnabled: false

# Debugging
debug: false
sentryDisabled: false
debuggerBackend: "dap"
dapRequestTimeoutMs: 30000
dapLogEvents: false
Expand Down Expand Up @@ -262,8 +269,13 @@ Default templates:
By default, only internal XcodeBuildMCP runtime failures are sent to Sentry. User-domain errors (such as project build/test/config failures) are not sent. To disable telemetry entirely:

```yaml
# Environment variable only (no config.yaml option)
# XCODEBUILDMCP_SENTRY_DISABLED=true
sentryDisabled: true
```

You can also disable telemetry via environment variable:

```bash
XCODEBUILDMCP_SENTRY_DISABLED=true
```

See [PRIVACY.md](PRIVACY.md) for more information.
Expand All @@ -286,6 +298,7 @@ Notes:
| `sessionDefaults` | object | `{}` |
| `incrementalBuildsEnabled` | boolean | `false` |
| `debug` | boolean | `false` |
| `sentryDisabled` | boolean | `false` |
| `debuggerBackend` | string | `"dap"` |
| `dapRequestTimeoutMs` | number | `30000` |
| `dapLogEvents` | boolean | `false` |
Expand All @@ -310,6 +323,7 @@ Environment variables are supported for backwards compatibility but the config f
| `disableSessionDefaults` | `XCODEBUILDMCP_DISABLE_SESSION_DEFAULTS` |
| `incrementalBuildsEnabled` | `INCREMENTAL_BUILDS_ENABLED` |
| `debug` | `XCODEBUILDMCP_DEBUG` |
| `sentryDisabled` | `XCODEBUILDMCP_SENTRY_DISABLED` |
| `debuggerBackend` | `XCODEBUILDMCP_DEBUGGER_BACKEND` |
| `dapRequestTimeoutMs` | `XCODEBUILDMCP_DAP_REQUEST_TIMEOUT_MS` |
| `dapLogEvents` | `XCODEBUILDMCP_DAP_LOG_EVENTS` |
Expand All @@ -320,7 +334,6 @@ Environment variables are supported for backwards compatibility but the config f
| `iosTemplateVersion` | `XCODEBUILD_MCP_IOS_TEMPLATE_VERSION` |
| `macosTemplatePath` | `XCODEBUILDMCP_MACOS_TEMPLATE_PATH` |
| `macosTemplateVersion` | `XCODEBUILD_MCP_MACOS_TEMPLATE_VERSION` |
| (no config option) | `XCODEBUILDMCP_SENTRY_DISABLED` |

Config file takes precedence over environment variables when both are set.

Expand Down
6 changes: 6 additions & 0 deletions docs/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ For deterministic session defaults and runtime configuration, add a config file
<workspace-root>/.xcodebuildmcp/config.yaml
```

Use the setup wizard to create or update this file interactively:

```bash
xcodebuildmcp setup
```

See [CONFIGURATION.md](CONFIGURATION.md) for the full schema and examples.

## Client-specific configuration
Expand Down
6 changes: 4 additions & 2 deletions example_projects/iOS_Calculator/.xcodebuildmcp/config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
schemaVersion: 1
enabledWorkflows:
- debugging
- simulator
- ui-automation
- debugging
- xcode-ide
debug: false
sentryDisabled: false
sessionDefaults:
workspacePath: ./CalculatorApp.xcworkspace
workspacePath: CalculatorApp.xcworkspace
scheme: CalculatorApp
configuration: Debug
simulatorName: iPhone 17 Pro
Expand Down
29 changes: 28 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"url": "https://github.com/getsentry/XcodeBuildMCP/issues"
},
"dependencies": {
"@clack/prompts": "^1.0.1",
"@modelcontextprotocol/sdk": "^1.25.1",
"@sentry/cli": "^3.1.0",
"@sentry/node": "^10.38.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-docs-cli-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function extractCommandCandidates(content) {
}

function findInvalidCommands(files, validPairs, validWorkflows) {
const validTopLevel = new Set(['mcp', 'tools', 'daemon', 'init']);
const validTopLevel = new Set(['mcp', 'tools', 'daemon', 'init', 'setup']);
const validDaemonActions = new Set(['status', 'start', 'stop', 'restart', 'list']);
const findings = [];

Expand Down
31 changes: 26 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { startMcpServer } from './server/start-mcp-server.ts';
import { listCliWorkflowIdsFromManifest } from './runtime/tool-catalog.ts';
import { flushAndCloseSentry, initSentry, recordBootstrapDurationMetric } from './utils/sentry.ts';
import { setLogLevel, type LogLevel } from './utils/logger.ts';
import { hydrateSentryDisabledEnvFromProjectConfig } from './utils/sentry-config.ts';

function findTopLevelCommand(argv: string[]): string | undefined {
const flagsWithValue = new Set(['--socket', '--log-level', '--style']);
Expand All @@ -31,12 +32,11 @@ function findTopLevelCommand(argv: string[]): string | undefined {
return undefined;
}

async function runInitCommand(): Promise<void> {
async function buildLightweightYargsApp(): Promise<ReturnType<typeof import('yargs').default>> {
const yargs = (await import('yargs')).default;
const { hideBin } = await import('yargs/helpers');
const { registerInitCommand } = await import('./cli/commands/init.ts');

const app = yargs(hideBin(process.argv))
return yargs(hideBin(process.argv))
.scriptName('')
.strict()
.help()
Expand All @@ -48,7 +48,11 @@ async function runInitCommand(): Promise<void> {
.option('log-level', {
type: 'string',
describe: 'Set log verbosity level',
choices: ['none', 'error', 'warning', 'info', 'debug'] as const,
choices: ['none', 'error', 'warn', 'info', 'debug'] as const,
coerce: (value: unknown) => {
if (typeof value !== 'string') return value;
return value.trim().toLowerCase() === 'warning' ? 'warn' : value;
},
default: 'none',
})
.option('style', {
Expand All @@ -63,10 +67,22 @@ async function runInitCommand(): Promise<void> {
setLogLevel(level);
}
});
}

async function runInitCommand(): Promise<void> {
const { registerInitCommand } = await import('./cli/commands/init.ts');
const app = await buildLightweightYargsApp();
registerInitCommand(app, { workspaceRoot: process.cwd() });
await app.parseAsync();
}

async function runSetupCommand(): Promise<void> {
const { registerSetupCommand } = await import('./cli/commands/setup.ts');
const app = await buildLightweightYargsApp();
registerSetupCommand(app);
await app.parseAsync();
}

async function main(): Promise<void> {
const cliBootstrapStartedAt = Date.now();
const earlyCommand = findTopLevelCommand(process.argv.slice(2));
Expand All @@ -78,6 +94,12 @@ async function main(): Promise<void> {
await runInitCommand();
return;
}
if (earlyCommand === 'setup') {
await runSetupCommand();
return;
}

await hydrateSentryDisabledEnvFromProjectConfig();
initSentry({ mode: 'cli' });

// CLI mode uses disableSessionDefaults to show all tool parameters as flags
Expand Down Expand Up @@ -115,7 +137,6 @@ async function main(): Promise<void> {
socketPath: defaultSocketPath,
workspaceRoot,
cliExposedWorkflowIds,
logLevel: result.runtime.config.debug ? 'info' : undefined,
discoveryMode,
});

Expand Down
16 changes: 2 additions & 14 deletions src/cli/cli-tool-catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ interface BuildCliToolCatalogOptions {
socketPath: string;
workspaceRoot: string;
cliExposedWorkflowIds: string[];
logLevel?: string;
discoveryMode?: 'none' | 'quick';
}

Expand Down Expand Up @@ -50,16 +49,6 @@ function jsonSchemaToToolSchemaShape(inputSchema: unknown): ToolSchemaShape {
return shape;
}

function buildDaemonEnvOverrides(opts: BuildCliToolCatalogOptions): Record<string, string> {
const env: Record<string, string> = {};

if (opts.logLevel) {
env.XCODEBUILDMCP_DAEMON_LOG_LEVEL = opts.logLevel;
}

return env;
}

async function invokeRemoteToolOneShot(
remoteToolName: string,
args: Record<string, unknown>,
Expand Down Expand Up @@ -123,11 +112,10 @@ async function loadDaemonBackedXcodeProxyTools(
startDaemonBackground({
socketPath: opts.socketPath,
workspaceRoot: opts.workspaceRoot,
env: buildDaemonEnvOverrides(opts),
});
} catch (startError) {
const message = startError instanceof Error ? startError.message : String(startError);
log('warning', `[xcode-ide] Failed to start daemon in background: ${message}`);
log('warn', `[xcode-ide] Failed to start daemon in background: ${message}`);
}
return [];
}
Expand All @@ -149,7 +137,7 @@ async function loadDaemonBackedXcodeProxyTools(
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
if (quickMode) {
log('warning', `[xcode-ide] CLI daemon-backed bridge discovery failed: ${message}`);
log('warn', `[xcode-ide] CLI daemon-backed bridge discovery failed: ${message}`);
} else {
log('debug', `[xcode-ide] CLI cached bridge discovery skipped: ${message}`);
}
Expand Down
Loading
Loading