forked from getsentry/XcodeBuildMCP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
179 lines (144 loc) · 5.4 KB
/
index.ts
File metadata and controls
179 lines (144 loc) · 5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/usr/bin/env node
/**
* XcodeBuildMCP - Main entry point
*
* This file serves as the entry point for the XcodeBuildMCP server, importing and registering
* all tool modules with the MCP server. It follows the platform-specific approach for Xcode tools.
*
* Responsibilities:
* - Creating and starting the MCP server
* - Registering all platform-specific tool modules
* - Configuring server options and logging
* - Handling server lifecycle events
*/
// Import server components
import { createServer, startServer } from './server/server.js';
// Import macOS build tools
import { registerMacOSBuildTools, registerMacOSBuildAndRunTools } from './tools/build_macos.js';
// Import iOS simulator build tools
import {
registerIOSSimulatorBuildTools,
registerIOSSimulatorBuildAndRunTools,
} from './tools/build_ios_simulator.js';
// Import iOS device build tools
import { registerIOSDeviceBuildTools } from './tools/build_ios_device.js';
// Import app path tools
import {
registerGetMacOSAppPathWorkspaceTool,
registerGetMacOSAppPathProjectTool,
registerGetiOSDeviceAppPathWorkspaceTool,
registerGetiOSDeviceAppPathProjectTool,
registerGetSimulatorAppPathByNameWorkspaceTool,
registerGetSimulatorAppPathByNameProjectTool,
registerGetSimulatorAppPathByIdWorkspaceTool,
registerGetSimulatorAppPathByIdProjectTool,
} from './tools/app_path.js';
// Import build settings and scheme tools
import {
registerShowBuildSettingsWorkspaceTool,
registerShowBuildSettingsProjectTool,
registerListSchemesWorkspaceTool,
registerListSchemesProjectTool,
} from './tools/build_settings.js';
// Import simulator tools
import {
registerListSimulatorsTool,
registerBootSimulatorTool,
registerOpenSimulatorTool,
registerInstallAppInSimulatorTool,
registerLaunchAppInSimulatorTool,
registerLaunchAppWithLogsInSimulatorTool,
} from './tools/simulator.js';
// Import bundle ID tools
import { registerGetMacOSBundleIdTool, registerGetiOSBundleIdTool } from './tools/bundleId.js';
// Import clean tool
import { registerCleanWorkspaceTool, registerCleanProjectTool } from './tools/clean.js';
// Import launch tools
import { registerLaunchMacOSAppTool } from './tools/launch.js';
// Import project/workspace discovery tool
import { registerDiscoverProjectsTool } from './tools/discover_projects.js';
// Import utilities
import { log } from './utils/logger.js';
// Import log capture tools
import {
registerStartSimulatorLogCaptureTool,
registerStopAndGetSimulatorLogTool,
} from './tools/log.js';
// Import idb tools
import { registerIdbTools } from './tools/idb.js';
// Import diagnostic tool
import { registerDiagnosticTool } from './tools/diagnostic.js';
// Import idb setup utility
import { setupIdb } from './utils/idb-setup.js';
import { version } from './version.js';
/**
* Main function to start the server
*/
async function main(): Promise<void> {
try {
// Create the server
const server = createServer();
// Register the project/workspace discovery tool
registerDiscoverProjectsTool(server);
// Register List/Discovery tools first
registerListSchemesWorkspaceTool(server);
registerListSchemesProjectTool(server);
registerListSimulatorsTool(server);
// Register Clean tools
registerCleanWorkspaceTool(server);
registerCleanProjectTool(server);
// Register Build tools
registerMacOSBuildTools(server);
registerIOSSimulatorBuildTools(server);
registerIOSDeviceBuildTools(server);
// Register Build settings tools
registerShowBuildSettingsWorkspaceTool(server);
registerShowBuildSettingsProjectTool(server);
// Register App path tools
registerGetMacOSAppPathWorkspaceTool(server);
registerGetMacOSAppPathProjectTool(server);
registerGetiOSDeviceAppPathWorkspaceTool(server);
registerGetiOSDeviceAppPathProjectTool(server);
registerGetSimulatorAppPathByNameWorkspaceTool(server);
registerGetSimulatorAppPathByNameProjectTool(server);
registerGetSimulatorAppPathByIdWorkspaceTool(server);
registerGetSimulatorAppPathByIdProjectTool(server);
// Register Simulator management tools
registerBootSimulatorTool(server);
registerOpenSimulatorTool(server);
// Register App installation and launch tools
registerInstallAppInSimulatorTool(server);
registerLaunchAppInSimulatorTool(server);
registerLaunchAppWithLogsInSimulatorTool(server);
// Register Bundle ID tools
registerGetMacOSBundleIdTool(server);
registerGetiOSBundleIdTool(server);
// Register Launch tools
registerLaunchMacOSAppTool(server);
// Register build and run tools
registerMacOSBuildAndRunTools(server);
registerIOSSimulatorBuildAndRunTools(server);
// Register log capture tools
registerStartSimulatorLogCaptureTool(server);
registerStopAndGetSimulatorLogTool(server);
// Register idb tools for iOS simulator UI automation
setupIdb();
registerIdbTools(server);
// Register diagnostic tool (only available when XCODEBUILDMCP_DEBUG is set)
if (process.env.XCODEBUILDMCP_DEBUG) {
registerDiagnosticTool(server);
}
// Start the server
await startServer(server);
// Log successful startup
log('info', `XcodeBuildMCP server (version ${version}) started successfully`);
} catch (error) {
console.error('Fatal error in main():', error);
process.exit(1);
}
}
// Start the server
main().catch((error) => {
console.error('Unhandled exception:', error);
process.exit(1);
});