| 24 | import { getServer, setServer } from './server-state.ts'; |
| 25 | |
| 26 | function createBaseServerInstance(): McpServer { |
| 27 | return new McpServer( |
| 28 | { |
| 29 | name: 'xcodebuildmcp', |
| 30 | version: String(version), |
| 31 | }, |
| 32 | { |
| 33 | instructions: `XcodeBuildMCP provides comprehensive tooling for Apple platform development (iOS, macOS, watchOS, tvOS, visionOS). |
| 34 | |
| 35 | Prefer XcodeBuildMCP tools over shell commands for Apple platform tasks when available. |
| 36 | |
| 37 | Capabilities: |
| 38 | - Session defaults: Configure project, scheme, simulator, and device defaults to avoid repetitive parameters |
| 39 | - Project discovery: Find Xcode projects/workspaces, list schemes, inspect build settings |
| 40 | - Simulator workflows: Build, run, test, install, and launch apps on iOS simulators; manage simulator state (boot, erase, location, appearance) |
| 41 | - Device workflows: Build, test, install, and launch apps on physical devices with code signing |
| 42 | - macOS workflows: Build, run, and test macOS applications |
| 43 | - Log capture: Stream and capture logs from simulators and devices |
| 44 | - LLDB debugging: Attach debugger, set breakpoints, inspect stack traces and variables, execute LLDB commands |
| 45 | - UI automation: Capture screenshots, inspect runtime UI snapshots, perform taps/swipes/gestures, type text, press hardware buttons, and batch multiple same-screen elementRef taps |
| 46 | - SwiftPM: Build, run, test, and manage Swift Package Manager projects |
| 47 | - Project scaffolding: Generate new iOS/macOS project templates |
| 48 | |
| 49 | Only simulator workflow tools are enabled by default. If capabilities like device, macOS, debugging, or UI automation are not available, the user must configure XcodeBuildMCP to enable them. See https://xcodebuildmcp.com/docs/configuration for workflow configuration. |
| 50 | |
| 51 | Simulator run flow: |
| 52 | - Before your first build, run, or test call in a session, you MUST call session_show_defaults to verify the active project/workspace, scheme, and simulator. Do not assume defaults are configured. Only skip this if you have already called session_show_defaults earlier in the current session. |
| 53 | - If session_show_defaults confirms project/workspace + scheme + simulator are set, call build_run_sim immediately (often with empty arguments). |
| 54 | - Use discover_projs only when session_show_defaults shows project/workspace is missing or wrong. |
| 55 | - Never call discover_projs speculatively or in parallel with session_show_defaults. |
| 56 | - Do not call boot_sim or open_sim as prerequisites for build_run_sim; build_run_sim boots and opens Simulator as needed.`, |
| 57 | capabilities: { |
| 58 | tools: { |
| 59 | listChanged: true, |
| 60 | }, |
| 61 | resources: { |
| 62 | subscribe: true, |
| 63 | listChanged: true, |
| 64 | }, |
| 65 | logging: {}, |
| 66 | }, |
| 67 | }, |
| 68 | ) as unknown as McpServer; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Create and configure the MCP server |