Skip to content

Commit a8a2cfc

Browse files
committed
Add diagnostic tool
1 parent 78c3571 commit a8a2cfc

File tree

8 files changed

+486
-21
lines changed

8 files changed

+486
-21
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,22 @@ body:
1616
placeholder: When trying to build my iOS app using the AI assistant...
1717
validations:
1818
required: true
19-
20-
- type: input
21-
id: macos-version
22-
attributes:
23-
label: macOS Version
24-
description: The version of macOS you're using
25-
placeholder: macOS 15.4.1
26-
validations:
27-
required: true
28-
29-
- type: input
30-
id: xcode-version
19+
20+
- type: textarea
21+
id: debug
3122
attributes:
32-
label: Xcode Version
33-
description: The version of Xcode you're using
34-
placeholder: Xcode 16.3
23+
label: Debug Output
24+
description: Output from the diagnostic tool
25+
placeholder: |
26+
```
27+
# Run the diagnostic tool using mise
28+
mise x npm:xcodebuildmcp@latest -- xcodebuildmcp-diagnostic
29+
30+
# Or using npx
31+
npx xcodebuildmcp@latest xcodebuildmcp-diagnostic
32+
```
3533
validations:
36-
required: true
34+
required: true
3735

3836
- type: input
3937
id: editor-client

CONTRIBUTING.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,31 @@ To configure your MCP client to use your local XcodeBuildMCP server you can use
6464

6565
You can use MCP Inspector via:
6666

67+
```bash
68+
npm run inspect
69+
```
70+
71+
or if you prefer the explict command:
72+
6773
```bash
6874
npx @modelcontextprotocol/inspector node build/index.js
6975
```
7076

77+
#### Using the diagnostic tool
78+
79+
Running the XcodeBuildMCP server with the environmental variable `XCODEBUILDMCP_DEBUG=true` will expose a new diagnostic tool which you can run using MCP Inspector:
80+
81+
82+
```bash
83+
XCODEBUILDMCP_DEBUG=true npm run inspect
84+
```
85+
86+
Alternatively, you can run the diagnostic tool directly:
87+
88+
```bash
89+
node build/diagnostic-cli.js
90+
```
91+
7192
## Making changes
7293

7394
1. Fork the repository and create a new branch

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ A Model Context Protocol (MCP) server that provides Xcode-related tools for inte
44

55
## Table of contents
66

7-
- [Table of contents](#table-of-contents)
87
- [Overview](#overview)
98
- [Why?](#why)
109
- [Features](#features)
@@ -16,13 +15,17 @@ A Model Context Protocol (MCP) server that provides Xcode-related tools for inte
1615
* [One-line setup with mise](#one-line-setup-with-mise)
1716
* [Configure MCP clients](#configure-mcp-clients)
1817
* [Enabling UI Automation (beta)](#enabling-ui-automation-beta)
18+
- [Troubleshooting](#troubleshooting)
19+
* [Diagnostic Tool](#diagnostic-tool)
20+
+ [Using with mise](#using-with-mise)
21+
+ [Using with npx](#using-with-npx)
1922
- [Demos](#demos)
2023
* [Autonomously fixing build errors in Cursor](#autonomously-fixing-build-errors-in-cursor)
24+
* [Utilising the new UI automation and screen capture features](#utilising-the-new-ui-automation-and-screen-capture-features)
2125
* [Building and running iOS app in Claude Code](#building-and-running-ios-app-in-claude-code)
2226
- [Contributing](#contributing)
2327
- [Licence](#licence)
2428

25-
2629
## Overview
2730

2831
This project implements an MCP server that exposes Xcode operations as tools that can be invoked by AI agents via the MCP protocol. It enables programmatic interaction with Xcode projects through a standardised interface, optimised for agent-driven development workflows.
@@ -121,6 +124,38 @@ brew install idb-companion
121124
> [!NOTE]
122125
> Displaying images in tool responses and embedding them in chat context may not be supported by all MCP Clients; it's currently known to be supported in Cursor.
123126
127+
## Troubleshooting
128+
129+
If you encounter issues with XcodeBuildMCP, the diagnostic tool can help identify the problem by providing detailed information about your environment and dependencies.
130+
131+
### Diagnostic Tool
132+
133+
The diagnostic tool is a standalone utility that checks your system configuration and reports on the status of all dependencies required by XcodeBuildMCP. It's particularly useful when reporting issues.
134+
135+
#### Using with mise
136+
137+
```bash
138+
# Run the diagnostic tool using mise
139+
mise x npm:xcodebuildmcp@latest -- xcodebuildmcp-diagnostic
140+
```
141+
142+
#### Using with npx
143+
144+
```bash
145+
# Run the diagnostic tool using npx
146+
npx xcodebuildmcp@latest xcodebuildmcp-diagnostic
147+
```
148+
149+
The diagnostic tool will output comprehensive information about:
150+
151+
- System and Node.js environment
152+
- Xcode installation and configuration
153+
- Required dependencies (xcodebuild, idb, etc.)
154+
- Environment variables affecting XcodeBuildMCP
155+
- Feature availability status
156+
157+
When reporting issues on GitHub, please include the full output from the diagnostic tool to help with troubleshooting.
158+
124159
## Demos
125160

126161
### Autonomously fixing build errors in Cursor
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1630"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
</BuildAction>
10+
<TestAction
11+
buildConfiguration = "Debug"
12+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
13+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
14+
shouldUseLaunchSchemeArgsEnv = "YES"
15+
shouldAutocreateTestPlan = "YES">
16+
<Testables>
17+
<TestableReference
18+
skipped = "NO"
19+
parallelizable = "YES">
20+
<BuildableReference
21+
BuildableIdentifier = "primary"
22+
BlueprintIdentifier = "8BA9F8302D62A18100C22D5D"
23+
BuildableName = "MCPTestTests.xctest"
24+
BlueprintName = "MCPTestTests"
25+
ReferencedContainer = "container:MCPTest.xcodeproj">
26+
</BuildableReference>
27+
</TestableReference>
28+
</Testables>
29+
</TestAction>
30+
<LaunchAction
31+
buildConfiguration = "Debug"
32+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
33+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
34+
launchStyle = "0"
35+
useCustomWorkingDirectory = "NO"
36+
ignoresPersistentStateOnLaunch = "NO"
37+
debugDocumentVersioning = "YES"
38+
debugServiceExtension = "internal"
39+
allowLocationSimulation = "YES">
40+
</LaunchAction>
41+
<ProfileAction
42+
buildConfiguration = "Release"
43+
shouldUseLaunchSchemeArgsEnv = "YES"
44+
savedToolIdentifier = ""
45+
useCustomWorkingDirectory = "NO"
46+
debugDocumentVersioning = "YES">
47+
</ProfileAction>
48+
<AnalyzeAction
49+
buildConfiguration = "Debug">
50+
</AnalyzeAction>
51+
<ArchiveAction
52+
buildConfiguration = "Release"
53+
revealArchiveInOrganizer = "YES">
54+
</ArchiveAction>
55+
</Scheme>

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
"main": "build/index.js",
55
"type": "module",
66
"bin": {
7-
"xcodebuildmcp": "./build/index.js"
7+
"xcodebuildmcp": "./build/index.js",
8+
"xcodebuildmcp-diagnostic": "./build/diagnostic-cli.js"
89
},
910
"scripts": {
1011
"prebuild": "echo \"export const version = '$npm_package_version';\" > src/version.ts",
11-
"build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\"",
12+
"build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755') && require('fs').chmodSync('build/diagnostic-cli.js', '755')\"",
1213
"lint": "eslint 'src/**/*.{js,ts}'",
1314
"lint:fix": "eslint 'src/**/*.{js,ts}' --fix",
1415
"format": "prettier --write 'src/**/*.{js,ts}'",
15-
"format:check": "prettier --check 'src/**/*.{js,ts}'"
16+
"format:check": "prettier --check 'src/**/*.{js,ts}'",
17+
"inspect": "npx @modelcontextprotocol/inspector node build/index.js",
18+
"diagnostic": "node build/diagnostic-cli.js"
1619
},
1720
"files": [
1821
"build"

src/diagnostic-cli.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* XcodeBuildMCP Diagnostic CLI
5+
*
6+
* This standalone script runs the diagnostic tool and outputs the results
7+
* to the console. It's designed to be run directly via npx or mise.
8+
*/
9+
10+
import { version } from './version.js';
11+
12+
// Set the debug environment variable
13+
process.env.XCODEBUILDMCP_DEBUG = 'true';
14+
15+
async function runDiagnostic(): Promise<void> {
16+
try {
17+
// Using console.error to avoid linting issues as it's allowed by the project's linting rules
18+
console.error(`Running XcodeBuildMCP Diagnostic Tool (v${version})...`);
19+
console.error('Collecting system information and checking dependencies...\n');
20+
21+
const { runDiagnosticTool } = await import('./tools/diagnostic.js');
22+
23+
// Run the diagnostic tool
24+
const result = await runDiagnosticTool({});
25+
26+
// Output the diagnostic information
27+
if (result.content && result.content.length > 0) {
28+
const textContent = result.content.find((item: { type: string }) => item.type === 'text');
29+
if (textContent && 'text' in textContent) {
30+
console.error(textContent.text);
31+
} else {
32+
console.error('Error: Unexpected diagnostic result format');
33+
}
34+
} else {
35+
console.error('Error: No diagnostic information returned');
36+
}
37+
38+
console.error('\nDiagnostic complete. Please include this output when reporting issues.');
39+
} catch (error) {
40+
console.error('Error running diagnostic:', error);
41+
process.exit(1);
42+
}
43+
}
44+
45+
// Run the diagnostic
46+
runDiagnostic().catch((error) => {
47+
console.error('Unhandled exception:', error);
48+
process.exit(1);
49+
});

src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ import {
8282
// Import idb tools
8383
import { registerIdbTools } from './tools/idb.js';
8484

85+
// Import diagnostic tool
86+
import { registerDiagnosticTool } from './tools/diagnostic.js';
87+
8588
// Import idb setup utility
8689
import { setupIdb } from './utils/idb-setup.js';
8790
import { version } from './version.js';
@@ -153,6 +156,11 @@ async function main(): Promise<void> {
153156
setupIdb();
154157
registerIdbTools(server);
155158

159+
// Register diagnostic tool (only available when XCODEBUILDMCP_DEBUG is set)
160+
if (process.env.XCODEBUILDMCP_DEBUG) {
161+
registerDiagnosticTool(server);
162+
}
163+
156164
// Start the server
157165
await startServer(server);
158166

0 commit comments

Comments
 (0)