()
| 44 | } |
| 45 | |
| 46 | async function main(): Promise<void> { |
| 47 | const { limit, callWindows } = parseArgs(process.argv); |
| 48 | |
| 49 | const transport = new StdioClientTransport({ |
| 50 | command: 'xcrun', |
| 51 | args: ['mcpbridge'], |
| 52 | stderr: 'inherit', |
| 53 | env: mapXcodeEnvForMcpBridge(process.env), |
| 54 | }); |
| 55 | |
| 56 | const client = new Client({ name: 'xcodebuildmcp-probe', version: '0.0.0' }); |
| 57 | await client.connect(transport, { timeout: 15_000 }); |
| 58 | |
| 59 | const serverInfo = client.getServerVersion(); |
| 60 | const capabilities = client.getServerCapabilities(); |
| 61 | |
| 62 | console.log('serverInfo:', serverInfo); |
| 63 | console.log('capabilities.tools.listChanged:', capabilities?.tools?.listChanged ?? false); |
| 64 | |
| 65 | const toolsResult = await client.listTools(undefined, { timeout: 15_000 }); |
| 66 | console.log(`tools: ${toolsResult.tools.length}`); |
| 67 | console.log( |
| 68 | 'first tools:', |
| 69 | toolsResult.tools.slice(0, limit).map((t) => t.name), |
| 70 | ); |
| 71 | |
| 72 | if (callWindows) { |
| 73 | const windows = await client.request( |
| 74 | { method: 'tools/call', params: { name: 'XcodeListWindows', arguments: {} } }, |
| 75 | CompatibilityCallToolResultSchema, |
| 76 | { timeout: 15_000 }, |
| 77 | ); |
| 78 | console.log('XcodeListWindows:', windows); |
| 79 | } |
| 80 | |
| 81 | await client.close(); |
| 82 | } |
| 83 | |
| 84 | main().catch((error) => { |
| 85 | console.error(error); |
no test coverage detected