diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d58aeb6..30335a3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,8 +88,8 @@ jobs: - name: Restore source modification times run: ./scripts/restore-source-mtimes.sh - - name: Verify proxy target boundaries - run: ./scripts/verify-proxy-target-boundaries.sh + - name: Verify server target boundaries + run: ./scripts/verify-server-target-boundaries.sh - name: Build package tests run: swift build --build-tests -Xswiftc -strict-concurrency=minimal @@ -103,8 +103,8 @@ jobs: fail-fast: false matrix: shard: - - XcodeMCPProxyRuntimeTests - - ProxyIntegrationTests + - XcodeMCPServerRuntimeTests + - ServerIntegrationTests - remaining steps: - name: Checkout @@ -155,7 +155,7 @@ jobs: ./scripts/ci-test-watchdog.sh swift test \ --skip-build \ --no-parallel \ - --skip 'XcodeMCPProxyRuntimeTests|ProxyIntegrationTests' \ + --skip 'XcodeMCPServerRuntimeTests|ServerIntegrationTests' \ -Xswiftc -strict-concurrency=minimal exit 0 ;; diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5895b7e4..46e49604 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -294,7 +294,7 @@ jobs: python3 scripts/package_release.py verify --version "$VERSION" \ --release-dir release --checksums-sha256 "$CHECKSUMS_SHA256" - - name: Build, bottle, reinstall and exercise the native helper and proxy + - name: Build, bottle, reinstall and exercise the native helper and server run: scripts/test-homebrew.sh release tap-status: @@ -399,7 +399,7 @@ jobs: if not installed["poured_from_bottle"]: sys.exit("Published tap verification expected a bottle installation.") ' - installed_binary="$(brew --prefix "$formula")/bin/xcode-mcp-proxy-server" + installed_binary="$(brew --prefix "$formula")/bin/xcode-mcp-server" test "$("$installed_binary" --version)" = "$VERSION" brew test "$formula" "$(brew --prefix python@3.14)/bin/python3.14" \ diff --git a/.gitignore b/.gitignore index 3afa676e..860cc3c8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,6 @@ DerivedData/ .codex/tmp/ /dist /release -/ProxyToolVerifierOutput/ +/ToolVerifierOutput/ __pycache__/ .vscode/ diff --git a/Docs/README.md b/Docs/README.md index 75074017..2c5a4526 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -12,12 +12,12 @@ ## Use the Swift libraries - [XcodeMCPKit](../Sources/XcodeMCPKit/README.md): discover and call MCP tools. -- [XcodeMCPProxyKit](../Sources/XcodeMCPProxyKit/README.md): embed the server. +- [XcodeMCPServerKit](../Sources/XcodeMCPServerKit/README.md): embed the server. - [XcodeMCPKitTesting](../Sources/XcodeMCPKitTesting/README.md): use the client API with an in-memory runtime. ## Maintain the project - [Architecture](architecture.md): public contracts, routing, sessions, and HTTP delivery. - [Maintainer guide](maintainer-architecture.md): module ownership, native integration constraints, and verification. -- [Live tool verifier](../Sources/XcodeMCPProxyToolVerifier/README.md): disposable fixtures and preview comparisons. +- [Live tool verifier](../Sources/XcodeMCPToolVerifier/README.md): disposable fixtures and preview comparisons. - [Homebrew distribution](../Homebrew/README.md): release approval, publication, and recovery. diff --git a/Docs/architecture.md b/Docs/architecture.md index 386e9f43..57d280a0 100644 --- a/Docs/architecture.md +++ b/Docs/architecture.md @@ -1,6 +1,6 @@ # Architecture -`xcode-mcp-proxy-server` exposes one public MCP tool contract over Streamable +`xcode-mcp-server` exposes one public MCP tool contract over Streamable HTTP. Workspace and device-session handles retain their owned headless execution context across requests. @@ -8,16 +8,16 @@ context across requests. ```mermaid flowchart LR - client["MCP client"] -->|"Streamable HTTP"| proxy["Public tool contract"] - proxy --> handles["Workspace and session handles"] + client["MCP client"] -->|"Streamable HTTP"| server["Public tool contract"] + server --> handles["Workspace and session handles"] handles --> headless["Owned native host"] headless --> saved["Saved workspace models"] - proxy -->|"Native crash tools / GUI tab IDs"| bridge["Apple mcpbridge"] + server -->|"Native crash tools / GUI tab IDs"| bridge["Apple mcpbridge"] bridge --> gui["Running GUI Xcode"] headless -->|"Explicit Organizer tools"| gui ``` -`XcodeListWorkspaces` returns proxy identifiers for loaded headless models. +`XcodeListWorkspaces` returns server identifiers for loaded headless models. A handle binds one native workspace to its host. The public input is `workspaceIdentifier`; adapters supply the owning backend's selector. Workspace and device operations use owned headless hosts. The standard crash @@ -36,7 +36,7 @@ of replaying an operation against another host. ## Public and native catalogs -The proxy owns public tool names and schemas. Its adapters translate arguments +The server owns public tool names and schemas. Its adapters translate arguments and results at the native boundary, including workspace selectors and device-key spellings. Public tools remain callable without relying on a client to process `notifications/tools/list_changed` after a routing change. An unavailable backend @@ -82,7 +82,7 @@ deinitialization requests cancellation only. The server binds `localhost:8765` by default. `--listen`, `--host`, `--port`, and `LISTEN` / `HOST` / `PORT` select another address. Endpoint discovery uses -`~/Library/Caches/XcodeMCPProxy/endpoint.json` unless overridden. +`~/Library/Caches/XcodeMCPServer/endpoint.json` unless overridden. The Swift client's default `.server()` transport reads the discovery record and requires a running server. Explicit standalone `.nativeHost(...)` starts an owned @@ -123,7 +123,7 @@ values, and workspace resources. Apple's frameworks remain in the installed Xcode and are not redistributed. The optional Accessibility permission monitor approves other agents' direct -connections to GUI Xcode, including the proxy's Apple bridge. It is composed +connections to GUI Xcode, including the server's Apple bridge. It is composed separately and has no role in tool routing. See the [maintainer guide](maintainer-architecture.md) for module boundaries, native corrections, signing, and verification. diff --git a/Docs/configuration.md b/Docs/configuration.md index 8decf86b..322331b7 100644 --- a/Docs/configuration.md +++ b/Docs/configuration.md @@ -36,7 +36,7 @@ a failure after selection does not switch a running host to another installation The standard `DEVELOPER_DIR` environment variable can prefer an installation: ```bash -DEVELOPER_DIR=/Applications/Xcode_27.0.app/Contents/Developer xcode-mcp-proxy-server +DEVELOPER_DIR=/Applications/Xcode_27.0.app/Contents/Developer xcode-mcp-server ``` To use another installation for a workspace, pass a `hostIdentifier` from @@ -46,7 +46,7 @@ retains that host for subsequent operations. See ## Server options -Use `xcode-mcp-proxy-server --help` for CLI usage. +Use `xcode-mcp-server --help` for CLI usage. | Option | Description | | --- | --- | @@ -57,7 +57,7 @@ Use `xcode-mcp-proxy-server --help` for CLI usage. | `--share-compilation-cache` | Enable shared compilation caching and Swift/Clang prefix mapping in native hosts. Off by default; see [compilation caching](#compilation-caching). | | `--auto-approve` | Automatically allow MCP connection dialogs for agents connecting directly to GUI Xcode. Off by default; requires macOS Accessibility access. | | `--debug-endpoints` | Serve `/debug/hosts` and `/debug/reset` when the listener is loopback. Off by default. | -| `--force-restart` | Terminate an existing `xcode-mcp-proxy-server` on the listen port before starting. | +| `--force-restart` | Terminate an existing `xcode-mcp-server` on the listen port before starting. | | `--dry-run` | Print the resolved server command without starting it. | ## Crash data storage @@ -75,7 +75,7 @@ new content versions are acquired. When launching the packaged native host directly, use `--crash-cache-root path` to select a different location. This is a native-host option, not an -`xcode-mcp-proxy-server` option. Its `--artifacts-root` controls request artifacts +`xcode-mcp-server` option. Its `--artifacts-root` controls request artifacts and does not change the persistent crash cache. See [crash collection](usage.md#collect-crash-reports) for acquisition and reading. @@ -105,8 +105,8 @@ for admission and completion boundaries. | `XCODE_MCP_NATIVE_HOST_BUNDLE` | Helper bundle override for custom embedded/install layouts. | | `DEVELOPER_DIR` | Xcode selection for the native host. | | `MCP_LOG_LEVEL` | `trace`, `debug`, `info`, `notice`, `warning`, `error`, or `critical`. Defaults to `info`; `debug` includes native console output, HTTP access, and routing telemetry. | -| `XCODE_MCP_PROXY_DISCOVERY_FILE` | Discovery file override for isolated local/live test runs. | -| `XCODE_MCP_PROXY_CACHE_ROOT` | Cache root for the discovery path when `XCODE_MCP_PROXY_DISCOVERY_FILE` is unset. | +| `XCODE_MCP_SERVER_DISCOVERY_FILE` | Discovery file override for isolated local/live test runs. | +| `XCODE_MCP_SERVER_CACHE_ROOT` | Cache root for the discovery path when `XCODE_MCP_SERVER_DISCOVERY_FILE` is unset. | ### Logging @@ -115,7 +115,7 @@ matches a recognized diagnostic format. The default `info` level hides these lines. To inspect them, start the server with: ```bash -MCP_LOG_LEVEL=debug xcode-mcp-proxy-server +MCP_LOG_LEVEL=debug xcode-mcp-server ``` The helper marks each line of its own diagnostics with @@ -128,7 +128,7 @@ level, and native-host NSLog diagnostics remain errors. `--auto-approve` monitors running Xcode permission-dialog processes and presses `Allow` on MCP connection dialogs for agents connecting directly to Xcode -through the proxy's Apple bridge or from external clients. Proxy workspace +through the server's Apple bridge or from external clients. Server workspace operations run headlessly and do not create these dialogs. Grant macOS Accessibility access to the process hosting the server when prompted; otherwise dialogs remain for manual approval. @@ -145,7 +145,7 @@ Start the server with `--share-compilation-cache` to reuse compatible compilation results across worktrees: ```bash -xcode-mcp-proxy-server --share-compilation-cache +xcode-mcp-server --share-compilation-cache ``` This opt-in enables compilation caching and Swift/Clang prefix mapping in native @@ -223,7 +223,7 @@ to apply a changed setting to an already running native host. For an explicit override, start the server with the service executable path: ```sh -XCBBUILDSERVICE_PATH=/path/to/SWBBuildServiceBundle xcode-mcp-proxy-server +XCBBUILDSERVICE_PATH=/path/to/SWBBuildServiceBundle xcode-mcp-server ``` When neither environment specifies a service, Swift Build uses the selected diff --git a/Docs/crash-reports.md b/Docs/crash-reports.md index 39e07b70..7738c34a 100644 --- a/Docs/crash-reports.md +++ b/Docs/crash-reports.md @@ -9,7 +9,7 @@ coverage. Native results do not identify network versus cache provenance. The report UI and Markdown are in Japanese. JSON field names are stable English identifiers. Keep GUI Xcode running with an open workspace and App Store Connect -account access. `--auto-approve` on the proxy can approve its bridge connection. +account access. `--auto-approve` on the server can approve its bridge connection. Standard acquisition does not operate Organizer. ## Start the report page diff --git a/Docs/maintainer-architecture.md b/Docs/maintainer-architecture.md index 64cc4462..48d80e5a 100644 --- a/Docs/maintainer-architecture.md +++ b/Docs/maintainer-architecture.md @@ -5,14 +5,14 @@ | Module | Responsibility | | --- | --- | | `XcodeMCPCore` | Code that the SDK and the server share: clocks, endpoint discovery, native host lookup, SSE framing, and subprocess primitives. Depends only on `XcodeMCPWire`, so the SDK product builds without swift-nio or swift-log. | -| `XcodeMCPInstallation` | Installation discovery and path normalization shared by proxy and native host. | +| `XcodeMCPInstallation` | Installation discovery and path normalization shared by server and native host. | | `XcodeMCPKit` | Public Swift client and MCP values. `MCPClientSessionAuthority` owns transport identity/recovery; `InitializedMCPClientSession` owns request correlation and progress lanes. | | `XcodeMCPNativeRuntime` / `XcodeMCPNativeHost` | Xcode framework integration, native actions, headless workspace models, execution queues, and owned preview resources. | -| `XcodeMCPProxyRuntimeContract` | Package request/reply/session values and serving protocols. No execution or I/O state. | -| `XcodeMCPProxyRuntime` | Public tool contract and handle routing (`Broker/`), and one connection per host process with its catalog, request correlation, and recovery (`Host/`). | -| `XcodeMCPProxyHTTP` | Listener, protocol validation, MCP session lifetime (`HTTPSessionStore`), responses, and SSE delivery, including each request's progress on its POST response. Depends on the runtime contract rather than concrete Runtime. | +| `XcodeMCPServerRuntimeContract` | Package request/reply/session values and serving protocols. No execution or I/O state. | +| `XcodeMCPServerRuntime` | Public tool contract and handle routing (`Broker/`), and one connection per host process with its catalog, request correlation, and recovery (`Host/`). | +| `XcodeMCPServerHTTP` | Listener, protocol validation, MCP session lifetime (`HTTPSessionStore`), responses, and SSE delivery, including each request's progress on its POST response. Depends on the runtime contract rather than concrete Runtime. | | `XcodeMCPPermissionAutomation` | Accessibility dialog recognition and opt-in approval monitor. Independent of native execution and routing. | -| `XcodeMCPProxyKit` | Public server facade, runtime/HTTP composition, discovery, CLI hosting, and installation. | +| `XcodeMCPServerKit` | Public server facade, runtime/HTTP composition, discovery, CLI hosting, and installation. | Runtime and HTTP use Core rather than importing the public SDK. Internal targets remain package implementation, not library products. The SDK keeps transport @@ -60,7 +60,7 @@ Shutdown stops admission and awaits owned tasks before closing workspace and transport resources. In the native host, the main task owns shutdown and runs it once, for whichever comes first: input end, input or output failure, or a failure that leaves Xcode's state in the process unreliable (such as a failed testable-state -hook). The failing request still gets its reply; the proxy then fails in-flight +hook). The failing request still gets its reply; the server then fails in-flight requests and starts a new process on the next use. Input framing and preview product digests run off the main actor, which Xcode's models use. `deinit` is a synchronous cancellation backstop and must not spawn an unowned task or promise graceful shutdown. Report cleanup failure @@ -68,7 +68,7 @@ alongside the original failure. Do not replay mutations with unknown delivery. The native host retains a dedicated stdout descriptor for MCP messages and redirects ordinary stdout to stderr, keeping framework output out of the protocol -stream. The proxy logs stderr lines without a recognized diagnostic format at +stream. The server logs stderr lines without a recognized diagnostic format at `debug`, including test progress and other console output. The default `info` level hides them; `MCP_LOG_LEVEL=debug` makes them available for diagnosis. Each line of the helper's own diagnostics carries @@ -315,7 +315,7 @@ and account operations require their own checks. Run the relevant existing suite with an explicit macOS destination, for example: ```sh -xcodebuild test -workspace XcodeMCPKit.xcworkspace -scheme XcodeMCPProxyRuntimeTests -destination 'platform=macOS' +xcodebuild test -workspace XcodeMCPKit.xcworkspace -scheme XcodeMCPServerRuntimeTests -destination 'platform=macOS' ``` | Test target | Boundary | @@ -323,18 +323,18 @@ xcodebuild test -workspace XcodeMCPKit.xcworkspace -scheme XcodeMCPProxyRuntimeT | `XcodeMCPCoreTests` | Wire/framing, SSE codec, discovery, and native host lookup. | | `XcodeMCPProcessRuntimeTests` | Process I/O and termination with fake drivers and opt-in live cases. | | `XcodeMCPNativeRuntimeTests` | Native schemas, workspace/execution lifetime, previews, and documentation assets. | -| `XcodeMCPProxyRuntimeTests` | Public/backend contracts, handle routing, scheduling, and recovery. | -| `XcodeMCPProxyHTTPTests` | HTTP/SSE gateway with a runtime-contract fake. | -| `ProxyIntegrationTests` | Actual HTTP/runtime and configuration composition. | +| `XcodeMCPServerRuntimeTests` | Public/backend contracts, handle routing, scheduling, and recovery. | +| `XcodeMCPServerHTTPTests` | HTTP/SSE gateway with a runtime-contract fake. | +| `ServerIntegrationTests` | Actual HTTP/runtime and configuration composition. | | `PublicProductContractTests` | Supported library consumers compiled from an external package. | -Core fixtures live in `XcodeMCPCoreTestSupport`, shared proxy fixtures in -`XcodeMCPProxyTestSupport`, and scripted host processes (`FakeHostSession`) in -`XcodeMCPProxyRuntimeTestSupport`. A fixture used by one suite stays with that +Core fixtures live in `XcodeMCPCoreTestSupport`, shared server fixtures in +`XcodeMCPServerTestSupport`, and scripted host processes (`FakeHostSession`) in +`XcodeMCPServerRuntimeTestSupport`. A fixture used by one suite stays with that suite. Keep deterministic observations at owner boundaries instead of adding production test hooks or reproducing internal branch order in assertions. -`scripts/verify-proxy-target-boundaries.sh` checks dependency direction; +`scripts/verify-server-target-boundaries.sh` checks dependency direction; `scripts/check.sh` runs the full local maintainer checks. Package test schemes can include several targets. Filtering execution does not prove compilation isolation; inspect `swift build --target -v` when that boundary matters. @@ -352,9 +352,9 @@ python3 scripts/benchmark-live-server.py --agents 4 --requests-per-agent 100 It uses persistent sessions against a running server and deletes those sessions on exit. Non-loopback endpoints require `--allow-non-loopback`. -For live checks, use the [tool verifier](../Sources/XcodeMCPProxyToolVerifier/README.md) +For live checks, use the [tool verifier](../Sources/XcodeMCPToolVerifier/README.md) and disposable saved projects with an explicit scheme, destination, and test plan. -The legacy `ProxyLiveMCPBridgeTests` suite name remains a test identifier for +The legacy `LiveMCPBridgeTests` suite name remains a test identifier for owned-host smoke cases. Verify workspace listing and operations with GUI Xcode both closed and running; neither case may connect to the GUI process or require its MCP connection approval. diff --git a/Docs/migrations/native-backend.md b/Docs/migrations/native-backend.md index 038e2d63..ce3309ce 100644 --- a/Docs/migrations/native-backend.md +++ b/Docs/migrations/native-backend.md @@ -1,9 +1,33 @@ # Migration -Restart the proxy and connected MCP clients after upgrading so clients load the +Restart the server and connected MCP clients after upgrading so clients load the current public tool definitions. Installation instructions are in the [quick start](../../README.md#quick-start). +## Renamed server commands and products + +The server, its library, and its commands no longer use the name `proxy`. +Update startup scripts, launch agents, MCP client registrations that start the +server, and package dependencies: + +| Previous name | Current name | +| --- | --- | +| `xcode-mcp-proxy-server` | `xcode-mcp-server` | +| `xcode-mcp-proxy-install` | `xcode-mcp-install` | +| `xcode-mcp-proxy-tool-verifier` | `xcode-mcp-tool-verifier` | +| `XcodeMCPProxyKit` product and module | `XcodeMCPServerKit` | +| `XcodeMCPProxyServer`, `XcodeMCPProxyServerConfiguration` | `XcodeMCPServer`, `XcodeMCPServerConfiguration` | +| `XCODE_MCP_PROXY_DISCOVERY_FILE`, `XCODE_MCP_PROXY_CACHE_ROOT` | `XCODE_MCP_SERVER_DISCOVERY_FILE`, `XCODE_MCP_SERVER_CACHE_ROOT` | +| Discovery directory `XcodeMCPProxy` under the cache root | `XcodeMCPServer` | +| `XCODE_MCP_PROXY_ENDPOINT` for `scripts/benchmark-live-server.py` | `XCODE_MCP_SERVER_ENDPOINT` | + +The Homebrew formula is still `xcode-mcpkit`; upgrading it replaces the +`xcode-mcp-proxy-server` command with `xcode-mcp-server`. Upgrade the server and +SDK clients together, because both look for the discovery record in the new +directory. +`--force-restart` recognizes only `xcode-mcp-server`, so stop a running +`xcode-mcp-proxy-server` yourself before starting the new command on its port. + ## Workspace and host routing Open a saved project with `XcodeOpenWorkspace`, then pass its returned @@ -19,10 +43,10 @@ operations as described below. | `XcodeMCPKitSelectHost({hostIdentifier,createsNewHost:true})` or `XcodeOpenWorkspace({path,createsNewHost:true})` | `XcodeOpenWorkspace({path,hostIdentifier})`. Each installation has one shared headless host; use a separate checkout when settings must differ. | | GUI tab IDs for workspace operations | Use `XcodeOpenWorkspace` / `XcodeListWorkspaces` for headless workspace IDs. `XcodeListWindows` now supplies native tab IDs for the standard crash tools only. | | `GetBuildLog({tabIdentifier: ...})` or other GUI workspace inputs | `GetBuildLog({workspaceIdentifier: ...})` using the identifier from List/Open. | -| A native workspace ID retained across host selection | A new proxy identifier from List/Open. Do not reuse an old native ID. | +| A native workspace ID retained across host selection | A new server identifier from List/Open. Do not reuse an old native ID. | | `DeviceInteractionStartWorkspaceSession` | `DeviceInteractionStartSession` with `workspaceIdentifier`; omit that field for standalone device interaction. | | `interactSessionKey` in `DeviceInteractionSynthesize` | `interactionSessionKey`, using the session returned by the public device-start operation. | -| Native `launchSessionReference` with a separately selected host | Keep the proxy reference returned by `RunProject`; pass it to `GetConsoleOutput` to retain the creating context. | +| Native `launchSessionReference` with a separately selected host | Keep the server reference returned by `RunProject`; pass it to `GetConsoleOutput` to retain the creating context. | For example, replace the host-selection sequence with: @@ -133,7 +157,7 @@ new tool definitions. ## Native helper and server configuration -Install `XcodeMCPNativeHost.app` beside the proxy commands. Reinstall the complete +Install `XcodeMCPNativeHost.app` beside the server commands. Reinstall the complete package if it is missing. The default helper executes headlessly through the selected Xcode's frameworks without Xcode Service setup. Workspace operations work without an open GUI window; the standard crash tools use Apple's bridge. @@ -145,7 +169,7 @@ Remove these older settings from startup scripts and embedding configuration: | Removed | Current setup | | --- | --- | | `--upstream-processes`, `upstreamProcessCount` | One owned host per installation multiplexes concurrent requests. | -| `--xcode-mode`, `--session-id`, `--upstream-command`, `--upstream-args`, `--upstream-arg` | Use the normal proxy server. Remove explicit Service enable/status and `mcpbridge` launch steps. | +| `--xcode-mode`, `--session-id`, `--upstream-command`, `--upstream-args`, `--upstream-arg` | Use the normal server. Remove explicit Service enable/status and `mcpbridge` launch steps. | | `--config`, `MCP_XCODE_CONFIG`, TOML files, `configurationFileURL`, `ToolPolicy`, disabled-tool lists | Configure endpoint/deadlines directly; the MCP client controls allowed tools. | | `--refresh-code-issues-mode` and its policy/environment settings | `XcodeRefreshCodeIssuesInFile` uses its owning native context. | | Server CLI `--native-host-bundle`, `--developer-dir` | Keep the helper beside the commands; use `DEVELOPER_DIR` to prefer an installation. Embedders can set `nativeHostBundleURL` / `developerDirectoryURL`. | @@ -159,10 +183,10 @@ that monitor. See [configuration](../configuration.md). ## Swift client `XcodeMCPConfiguration` defaults to `.server()`. Start the -proxy before constructing the client. `.defaultMCPBridge` is removed. For a +server before constructing the client. `.defaultMCPBridge` is removed. For a standalone headless process, use `.nativeHost()`; generic processes use `.process(command:arguments:environment:)`. Standalone transports -expose their own native catalog, outside proxy handle routing. +expose their own native catalog, outside the server's handle routing. For consumers upgrading across v0.14.0: @@ -200,7 +224,7 @@ See the [client guide](../../Sources/XcodeMCPKit/README.md) for current examples ## Embedded server The current server API is documented in -[XcodeMCPProxyKit](../../Sources/XcodeMCPProxyKit/README.md). For v0.14.0 consumers: +[XcodeMCPServerKit](../../Sources/XcodeMCPServerKit/README.md). For v0.14.0 consumers: | Previous API | Current API | | --- | --- | @@ -209,10 +233,10 @@ The current server API is documented in | Server `Configuration.Limits` | Top-level `maxBodyBytes` and `requestTimeout: Duration?`. | | `configurationFilePath` | Remove file-based tool policy; current configuration is typed. | | Struct discovery configuration | `.disabled`, `.defaultLocation`, `.file(URL)`. | -| Public launch-plan/parser/product-metadata types | `XcodeMCPProxyServer.run(...)` for CLI hosting. | -| Public installer library APIs | `xcode-mcp-proxy-install` executable; `--dry-run` remains supported. | +| Public launch-plan/parser/product-metadata types | `XcodeMCPServer.run(...)` for CLI hosting. | +| Public installer library APIs | `xcode-mcp-install` executable; `--dry-run` remains supported. | | `XcodeMCPProxyStdioAdapter` and its configuration | Removed. Connect clients over Streamable HTTP; Swift clients use the [SDK](../../Sources/XcodeMCPKit/README.md). | -| `initializeHandshake` and `XcodeMCPProxyServerConfiguration.InitializeHandshake` | Removed. Hosts always receive the client name `XcodeMCPKit` and no client capabilities. `XcodeMCPProxyKit` no longer depends on the `XcodeMCPKit` product; add that product separately to use `MCPJSONValue` or the client. | +| `initializeHandshake` and `XcodeMCPProxyServerConfiguration.InitializeHandshake` | Removed. Hosts always receive the client name `XcodeMCPKit` and no client capabilities. `XcodeMCPServerKit` no longer depends on the `XcodeMCPKit` product; add that product separately to use `MCPJSONValue` or the client. | | `TimeInterval` request timeout | Positive `Duration?`; `nil` disables it. CLI `--request-timeout 0` also disables it. | | `Status.upstreams`, `Status.Upstream.Health`, `queuedRequestCount`, `proxyInitialized`, `catalogAvailable` | `Status.hosts`: one `Status.Host` per Xcode installation, with its `identifier` (the `hostIdentifier` from `XcodeMCPKitListHosts`), `kind`, `state` (`stopped`, `starting`, `running`), and `activeRequestCount`. Requests queue inside each host, and the catalog is available whenever the server runs. | diff --git a/Docs/troubleshooting.md b/Docs/troubleshooting.md index 56aa8e34..2b140558 100644 --- a/Docs/troubleshooting.md +++ b/Docs/troubleshooting.md @@ -15,7 +15,7 @@ and device-session identifiers from the old context are invalid. ## An operation is unavailable -The public catalog describes stable proxy operations. Availability still depends +The public catalog describes stable server operations. Availability still depends on the workspace's Xcode installation and native context. Read the tool error for the unsupported operation or missing native contract. A public schema does not guarantee that every installed Xcode supports that operation. @@ -26,7 +26,7 @@ require the client to refresh definitions after opening another workspace. ## The native helper cannot be found or started -Keep `XcodeMCPNativeHost.app` beside `xcode-mcp-proxy-server`. Reinstall the complete +Keep `XcodeMCPNativeHost.app` beside `xcode-mcp-server`. Reinstall the complete package if the helper is missing; copying only the command is insufficient. Custom layouts can use `XCODE_MCP_NATIVE_HOST_BUNDLE` or the embedding `nativeHostBundleURL` property. @@ -40,7 +40,7 @@ after such a failure. See [Xcode compatibility](configuration.md#xcode-compatibi ## A tool request times out -Inspect the proxy/helper error before increasing deadlines. `MCP_LOG_LEVEL=debug` +Inspect the server/helper error before increasing deadlines. `MCP_LOG_LEVEL=debug` shows HTTP, initialization, catalog, cancellation, and recovery telemetry. Confirm the workspace path exists, save headless source/project changes, and inspect the owning workspace's scheme, destination, and test plan. Selections made @@ -51,7 +51,7 @@ code, and context in stderr or the tool failure. `Native workspace cleanup faile reports cleanup of a removed model; resolve that failure before retrying against the same removed workspace. -The proxy does not limit how long a request runs, so the client's own timeout +The server does not limit how long a request runs, so the client's own timeout decides; the SDK defaults to 600 seconds. `RenderPreview` defaults to 300 seconds for build/render work, with initial preparation and cleanup outside that budget. Give the external client enough time for the entire request. @@ -85,12 +85,12 @@ proves discovery only; call the tool to verify search execution. ## A client cannot connect -Ensure the proxy is running and check its URL, normally +Ensure the server is running and check its URL, normally `http://localhost:8765/mcp`. The discovery record at -`~/Library/Caches/XcodeMCPProxy/endpoint.json` is a URL hint, not proof that the +`~/Library/Caches/XcodeMCPServer/endpoint.json` is a URL hint, not proof that the server is reachable. For `Address already in use` / `errno: 48`, stop the known listener or use -`xcode-mcp-proxy-server --force-restart` to replace a proxy on the selected port. +`xcode-mcp-server --force-restart` to replace a server on the selected port. Direct HTTP clients must send `Content-Type: application/json` for POST, and list `text/event-stream` in `Accept` to receive progress and slow replies as event @@ -109,5 +109,5 @@ client that retained an incompatible negotiated version. ## Native code diagnostics differ from the navigator `XcodeRefreshCodeIssuesInFile` runs in its owning native workspace. It returns -native diagnostics, progress, and errors. The proxy does not substitute navigator +native diagnostics, progress, and errors. The server does not substitute navigator issues or retry a failed diagnostic operation through another backend. diff --git a/Docs/usage.md b/Docs/usage.md index 639dc896..6cee0fe3 100644 --- a/Docs/usage.md +++ b/Docs/usage.md @@ -37,7 +37,7 @@ For example, call `GetBuildLog` with a returned identifier: } ``` -An identifier refers to one workspace in its owning host. The proxy translates +An identifier refers to one workspace in its owning host. The server translates it to the native workspace identifier. Keep using that identifier; no host-selection call or catalog refresh is needed. Identifiers belong to the MCP session that returned them. After starting a new MCP session or restarting a @@ -71,7 +71,7 @@ them, for example because the destination is no longer available, the operation fails instead of running with another session's settings. Build logs, issues, and preview state remain shared by every session that uses the workspace. -`RenderPreview` defaults to a 300-second timeout. The proxy sets no request +`RenderPreview` defaults to a 300-second timeout. The server sets no request timeout by default, and the SDK defaults to 600 seconds. Set an external client's deadline above the preview timeout to leave time for preparation and cleanup. In a headless workspace, RenderPreview builds saved changes and captures a fresh snapshot. Successful @@ -84,12 +84,12 @@ those headless resources. `RunProject` returns a `launchSessionReference`. Pass it to `GetConsoleOutput` to read that launch's logs without resupplying a workspace or selecting a host. -The proxy retains the creating host and native launch reference. +The server retains the creating host and native launch reference. `DeviceInteractionStartSession` accepts an optional `workspaceIdentifier`. With one, it prepares project-bound interaction, including build/install operations; without one, it prepares standalone device interaction. Follow-up tools use the -returned `interactionSessionKey` consistently, and the proxy supplies its owning +returned `interactionSessionKey` consistently, and the server supplies its owning host and workspace. End the session with `DeviceInteractionEndSession` when done. After starting a new MCP session or restarting a host, start a new device session. @@ -110,7 +110,7 @@ schemas, independently of headless `workspaceIdentifier` values. Pass a returned signature name as `signature_name` to `GetCrashIssueLogs`, with the same bundle/platform, version/channel filters, and `tabIdentifier`. The bridge targets a running GUI copy of the selected Xcode installation. -To select a specific instance, set `MCP_XCODE_PID` before starting the proxy. +To select a specific instance, set `MCP_XCODE_PID` before starting the server. The native response does not establish complete issue/sample coverage or whether a result came from the network or Apple's caches. Failure never starts Organizer as a fallback. `--auto-approve` can approve the bridge connection. @@ -405,10 +405,10 @@ can reuse compatible compilation work across installations. ## Tools, failures, and cancellation -`tools/list` describes the proxy's public operations. Backend tool availability +`tools/list` describes the server's public operations. Backend tool availability can differ by installation; a call reports when its owning host cannot perform an operation. Native workspace identifiers and schema changes are internal to -the proxy. Tools without a workspace, such as `DocumentationSearch`, use the default +the server. Tools without a workspace, such as `DocumentationSearch`, use the default host. Restart after installing newer developer documentation to select its index. Tool failures retain MCP `isError` and available diagnostics or partial output. diff --git a/Homebrew/README.md b/Homebrew/README.md index 57d14660..c4fead8b 100644 --- a/Homebrew/README.md +++ b/Homebrew/README.md @@ -1,6 +1,6 @@ # Homebrew distribution -`lynnswap/tap/xcode-mcpkit` installs the two proxy commands and +`lynnswap/tap/xcode-mcpkit` installs the server commands and `XcodeMCPNativeHost.app` together in `libexec`. Only the commands are linked into Homebrew's `bin`. A Swift client can discover the helper through the server link on `PATH`, or supply its bundle explicitly. @@ -16,7 +16,7 @@ The tap builds Apple Silicon bottles on the GitHub-hosted `xcode-27` image and registers them as `arm64_tahoe` for macOS 26 and later. The bottle receipt retains the actual build environment. Before publication, the tap verifies ordinary bottle installation, CLI startup, and signing on macOS 26 and the Xcode 27 runner. -Native and proxy MCP integration tests run on the Xcode 27 runner. The source +Native and server MCP integration tests run on the Xcode 27 runner. The source release also verifies the public bottle on that image without forcing selection. A host without a matching bottle can build from source with Xcode 27. The package's macOS 15.4 deployment target is separate from bottle availability. @@ -56,11 +56,11 @@ Approve its `release-signing` deployment to allow Developer ID signing and notarization. The signing job handles the bottle as data and does not build or execute its payload. A separate job installs the signed bottle, checks the Team ID and stable helper signing identifier, validates its notarization ticket, and -runs the native/proxy smoke tests. The tap then uploads that exact signed bottle +runs the native/server smoke tests. The tap then uploads that exact signed bottle and merges the Formula PR automatically using its own `GITHUB_TOKEN`. The source workflow installs the public bottle, checks its CLI versions and -signature, and exercises native and proxy MCP sessions against a disposable +signature, and exercises native and server MCP sessions against a disposable project. The Formula test covers CLI options and signatures; Xcode integration runs outside Homebrew's test sandbox in both tap CI and source-release CI. The source publisher rechecks the tested delivery before publishing the approved Draft. diff --git a/Homebrew/xcode-mcpkit.rb.in b/Homebrew/xcode-mcpkit.rb.in index 8c52c17d..f082dfa0 100644 --- a/Homebrew/xcode-mcpkit.rb.in +++ b/Homebrew/xcode-mcpkit.rb.in @@ -14,7 +14,7 @@ __EXPLICIT_VERSION__ def install system "scripts/build-release.sh", "--version", "v#{version}", "--dist-root", buildpath/"products" libexec.install Dir["products/arm64/bin/*"] - bin.install_symlink libexec/"xcode-mcp-proxy-server" + bin.install_symlink libexec/"xcode-mcp-server" pkgshare.install "scripts/smoke-homebrew.py" pkgshare.install "Fixtures/ProxyToolVerifierFixture" end @@ -22,18 +22,18 @@ __EXPLICIT_VERSION__ def caveats <<~EOS Start the server before connecting MCP clients: - xcode-mcp-proxy-server + xcode-mcp-server Xcode is required at runtime. Headless tools require Xcode's native service contracts. Restart the server after upgrading. If an older standalone installation is on PATH, - use the Homebrew executable at #{opt_bin}/xcode-mcp-proxy-server. + use the Homebrew executable at #{opt_bin}/xcode-mcp-server. EOS end test do - assert_equal "v#{version}", shell_output("#{bin}/xcode-mcp-proxy-server --version").strip - assert_equal "xcode-mcp-proxy-server --listen 127.0.0.1:0", - shell_output("#{bin}/xcode-mcp-proxy-server --host 127.0.0.1 --port 0 --dry-run").strip + assert_equal "v#{version}", shell_output("#{bin}/xcode-mcp-server --version").strip + assert_equal "xcode-mcp-server --listen 127.0.0.1:0", + shell_output("#{bin}/xcode-mcp-server --host 127.0.0.1 --port 0 --dry-run").strip system "codesign", "--verify", "--deep", "--strict", libexec/"XcodeMCPNativeHost.app" end end diff --git a/Package.swift b/Package.swift index 09b9122a..430215a8 100644 --- a/Package.swift +++ b/Package.swift @@ -24,20 +24,20 @@ let package = Package( targets: ["XcodeMCPKitTesting"] ), .library( - name: "XcodeMCPProxyKit", - targets: ["XcodeMCPProxyKit"] + name: "XcodeMCPServerKit", + targets: ["XcodeMCPServerKit"] ), .executable( - name: "xcode-mcp-proxy-server", - targets: ["XcodeMCPProxyServer"] + name: "xcode-mcp-server", + targets: ["XcodeMCPServerCLI"] ), .executable( - name: "xcode-mcp-proxy-install", - targets: ["XcodeMCPProxyInstall"] + name: "xcode-mcp-install", + targets: ["XcodeMCPInstallCLI"] ), .executable( - name: "xcode-mcp-proxy-tool-verifier", - targets: ["XcodeMCPProxyToolVerifierCLI"] + name: "xcode-mcp-tool-verifier", + targets: ["XcodeMCPToolVerifierCLI"] ), .executable( name: "xcode-mcp-native-host", @@ -112,15 +112,15 @@ let package = Package( swiftSettings: strictSwiftSettings ), .target( - name: "XcodeMCPProxyRuntimeContract", + name: "XcodeMCPServerRuntimeContract", dependencies: ["XcodeMCPCore"], swiftSettings: strictSwiftSettings ), .target( - name: "XcodeMCPProxyRuntime", + name: "XcodeMCPServerRuntime", dependencies: [ "XcodeMCPInstallation", - "XcodeMCPProxyRuntimeContract", + "XcodeMCPServerRuntimeContract", "XcodeMCPCore", "XcodeMCPWire", .product(name: "Logging", package: "swift-log"), @@ -131,9 +131,9 @@ let package = Package( swiftSettings: strictSwiftSettings ), .target( - name: "XcodeMCPProxyHTTP", + name: "XcodeMCPServerHTTP", dependencies: [ - "XcodeMCPProxyRuntimeContract", + "XcodeMCPServerRuntimeContract", "XcodeMCPCore", .product(name: "Logging", package: "swift-log"), .product(name: "NIO", package: "swift-nio"), @@ -158,12 +158,12 @@ let package = Package( swiftSettings: strictSwiftSettings ), .target( - name: "XcodeMCPProxyKit", + name: "XcodeMCPServerKit", dependencies: [ - "XcodeMCPProxyRuntimeContract", + "XcodeMCPServerRuntimeContract", "XcodeMCPCore", - "XcodeMCPProxyRuntime", - "XcodeMCPProxyHTTP", + "XcodeMCPServerRuntime", + "XcodeMCPServerHTTP", "XcodeMCPPermissionAutomation", .product(name: "ArgumentParser", package: "swift-argument-parser"), .product(name: "Logging", package: "swift-log"), @@ -172,17 +172,17 @@ let package = Package( exclude: ["README.md"], swiftSettings: strictSwiftSettings, plugins: [ - .plugin(name: "ProxyBuildInfoPlugin"), + .plugin(name: "ServerBuildInfoPlugin"), ] ), .target( - name: "XcodeMCPProxyTestSupport", + name: "XcodeMCPServerTestSupport", dependencies: [ "XcodeMCPCoreTestSupport", .product(name: "NIO", package: "swift-nio"), .product(name: "NIOConcurrencyHelpers", package: "swift-nio"), ], - path: "Tests/XcodeMCPProxyTestSupport", + path: "Tests/XcodeMCPServerTestSupport", swiftSettings: strictSwiftSettings ), .target( @@ -195,34 +195,34 @@ let package = Package( swiftSettings: strictSwiftSettings ), .executableTarget( - name: "XcodeMCPProxyServer", - dependencies: ["XcodeMCPProxyKit"], + name: "XcodeMCPServerCLI", + dependencies: ["XcodeMCPServerKit"], swiftSettings: strictSwiftSettings ), .executableTarget( - name: "XcodeMCPProxyInstall", - dependencies: ["XcodeMCPProxyKit"], + name: "XcodeMCPInstallCLI", + dependencies: ["XcodeMCPServerKit"], swiftSettings: strictSwiftSettings ), .executableTarget( - name: "XcodeMCPProxyToolVerifierCLI", - dependencies: ["XcodeMCPProxyToolVerifier"], + name: "XcodeMCPToolVerifierCLI", + dependencies: ["XcodeMCPToolVerifier"], swiftSettings: strictSwiftSettings ), .target( - name: "XcodeMCPProxyToolVerifier", + name: "XcodeMCPToolVerifier", dependencies: ["XcodeMCPKit"], exclude: ["README.md"], swiftSettings: strictSwiftSettings ), .executableTarget( - name: "ProxyBuildInfoTool", + name: "ServerBuildInfoTool", swiftSettings: strictSwiftSettings ), .plugin( - name: "ProxyBuildInfoPlugin", + name: "ServerBuildInfoPlugin", capability: .buildTool(), - dependencies: ["ProxyBuildInfoTool"] + dependencies: ["ServerBuildInfoTool"] ), .testTarget( name: "XcodeMCPKitTests", @@ -266,28 +266,28 @@ let package = Package( swiftSettings: strictSwiftSettings ), .target( - name: "XcodeMCPProxyRuntimeTestSupport", + name: "XcodeMCPServerRuntimeTestSupport", dependencies: [ - "XcodeMCPCore", "XcodeMCPProxyRuntime", "XcodeMCPProxyTestSupport", + "XcodeMCPCore", "XcodeMCPServerRuntime", "XcodeMCPServerTestSupport", .product(name: "NIOCore", package: "swift-nio"), ], - path: "Tests/XcodeMCPProxyRuntimeTestSupport", + path: "Tests/XcodeMCPServerRuntimeTestSupport", swiftSettings: strictSwiftSettings ), .testTarget( - name: "XcodeMCPProxyRuntimeTests", + name: "XcodeMCPServerRuntimeTests", dependencies: [ - "XcodeMCPProxyRuntimeTestSupport", - "XcodeMCPProxyRuntimeContract", + "XcodeMCPServerRuntimeTestSupport", + "XcodeMCPServerRuntimeContract", "XcodeMCPCore", - "XcodeMCPProxyRuntime", - "XcodeMCPProxyTestSupport", + "XcodeMCPServerRuntime", + "XcodeMCPServerTestSupport", .product(name: "Logging", package: "swift-log"), .product(name: "NIO", package: "swift-nio"), .product(name: "NIOConcurrencyHelpers", package: "swift-nio"), .product(name: "NIOEmbedded", package: "swift-nio"), ], - path: "Tests/XcodeMCPProxyRuntimeTests", + path: "Tests/XcodeMCPServerRuntimeTests", swiftSettings: strictSwiftSettings ), .testTarget( @@ -300,81 +300,81 @@ let package = Package( swiftSettings: strictSwiftSettings ), .testTarget( - name: "ProxyStressTests", + name: "ServerStressTests", dependencies: [ "XcodeMCPCore", "XcodeMCPKit", - "XcodeMCPProxyRuntime", - "XcodeMCPProxyHTTP", - "XcodeMCPProxyTestSupport", + "XcodeMCPServerRuntime", + "XcodeMCPServerHTTP", + "XcodeMCPServerTestSupport", .product(name: "NIO", package: "swift-nio"), .product(name: "NIOHTTP1", package: "swift-nio"), ], - path: "Tests/ProxyStressTests", + path: "Tests/ServerStressTests", swiftSettings: strictSwiftSettings ), .testTarget( - name: "XcodeMCPProxyHTTPTests", + name: "XcodeMCPServerHTTPTests", dependencies: [ - "XcodeMCPProxyRuntimeContract", - "XcodeMCPProxyHTTP", + "XcodeMCPServerRuntimeContract", + "XcodeMCPServerHTTP", .product(name: "Logging", package: "swift-log"), .product(name: "NIO", package: "swift-nio"), .product(name: "NIOEmbedded", package: "swift-nio"), .product(name: "NIOHTTP1", package: "swift-nio"), ], - path: "Tests/XcodeMCPProxyHTTPTests", + path: "Tests/XcodeMCPServerHTTPTests", swiftSettings: strictSwiftSettings ), .testTarget( - name: "ProxyToolVerifierTests", - dependencies: ["XcodeMCPProxyToolVerifier", "XcodeMCPKitTesting"], + name: "ToolVerifierTests", + dependencies: ["XcodeMCPToolVerifier", "XcodeMCPKitTesting"], swiftSettings: strictSwiftSettings ), .testTarget( - name: "ProxyCLITests", + name: "ServerCLITests", dependencies: [ "XcodeMCPCore", "XcodeMCPKit", - "XcodeMCPProxyKit", - "XcodeMCPProxyRuntime", - "XcodeMCPProxyTestSupport", + "XcodeMCPServerKit", + "XcodeMCPServerRuntime", + "XcodeMCPServerTestSupport", .product(name: "NIO", package: "swift-nio"), .product(name: "NIOHTTP1", package: "swift-nio"), ], - path: "Tests/ProxyCLITests", + path: "Tests/ServerCLITests", swiftSettings: strictSwiftSettings ), .testTarget( - name: "ProxyIntegrationTests", + name: "ServerIntegrationTests", dependencies: [ "XcodeMCPCoreTestSupport", - "XcodeMCPProxyRuntimeTestSupport", - "XcodeMCPProxyRuntimeContract", + "XcodeMCPServerRuntimeTestSupport", + "XcodeMCPServerRuntimeContract", "XcodeMCPCore", "XcodeMCPKit", - "XcodeMCPProxyKit", - "XcodeMCPProxyRuntime", - "XcodeMCPProxyHTTP", - "XcodeMCPProxyTestSupport", + "XcodeMCPServerKit", + "XcodeMCPServerRuntime", + "XcodeMCPServerHTTP", + "XcodeMCPServerTestSupport", .product(name: "Logging", package: "swift-log"), .product(name: "NIO", package: "swift-nio"), .product(name: "NIOEmbedded", package: "swift-nio"), .product(name: "NIOHTTP1", package: "swift-nio"), ], - path: "Tests/ProxyIntegrationTests", + path: "Tests/ServerIntegrationTests", swiftSettings: strictSwiftSettings ), .testTarget( - name: "ProxyLiveMCPBridgeTests", + name: "LiveMCPBridgeTests", dependencies: [ "XcodeMCPCore", "XcodeMCPKit", - "XcodeMCPProxyKit", - "XcodeMCPProxyRuntime", + "XcodeMCPServerKit", + "XcodeMCPServerRuntime", .product(name: "NIO", package: "swift-nio"), ], - path: "Tests/ProxyLiveMCPBridgeTests", + path: "Tests/LiveMCPBridgeTests", swiftSettings: strictSwiftSettings ), ] diff --git a/Plugins/ProxyBuildInfoPlugin/ProxyBuildInfoPlugin.swift b/Plugins/ServerBuildInfoPlugin/ServerBuildInfoPlugin.swift similarity index 89% rename from Plugins/ProxyBuildInfoPlugin/ProxyBuildInfoPlugin.swift rename to Plugins/ServerBuildInfoPlugin/ServerBuildInfoPlugin.swift index 79072ecb..d3d2bf23 100644 --- a/Plugins/ProxyBuildInfoPlugin/ProxyBuildInfoPlugin.swift +++ b/Plugins/ServerBuildInfoPlugin/ServerBuildInfoPlugin.swift @@ -2,7 +2,7 @@ import Foundation import PackagePlugin @main -struct ProxyBuildInfoPlugin: BuildToolPlugin { +struct ServerBuildInfoPlugin: BuildToolPlugin { private static let environmentKey = "XCODE_MCP_BUILD_VERSION" func createBuildCommands(context: PluginContext, target: Target) throws -> [Command] { @@ -11,7 +11,7 @@ struct ProxyBuildInfoPlugin: BuildToolPlugin { } let outputFile = context.pluginWorkDirectoryURL.appending(path: "BuildInfo.generated.swift") - let tool = try context.tool(named: "ProxyBuildInfoTool") + let tool = try context.tool(named: "ServerBuildInfoTool") var arguments = [ "--output", outputFile.path, "--package-directory", context.package.directoryURL.path, diff --git a/README.md b/README.md index 45a8a9fb..0548bba9 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ With Homebrew set up, no additional `PATH` setting is needed. ### Start the server ```bash -xcode-mcp-proxy-server +xcode-mcp-server ``` Keep this terminal open while using MCP. Workspace operations work with Xcode @@ -46,7 +46,7 @@ To automatically allow the bridge's and other agents' MCP connections to Xcode, start the server with `--auto-approve`: ```bash -xcode-mcp-proxy-server --auto-approve +xcode-mcp-server --auto-approve ``` Grant macOS Accessibility access to the server's host process when prompted. @@ -97,13 +97,13 @@ directory: ```bash git clone https://github.com/lynnswap/XcodeMCPKit.git cd XcodeMCPKit -swift run -c release xcode-mcp-proxy-install --bindir "$HOME/.local/opt/xcode-mcpkit-dev/bin" +swift run -c release xcode-mcp-install --bindir "$HOME/.local/opt/xcode-mcpkit-dev/bin" ``` -Stop any running proxy server, then start this build by its full path: +Stop any running server, then start this build by its full path: ```bash -"$HOME/.local/opt/xcode-mcpkit-dev/bin/xcode-mcp-proxy-server" +"$HOME/.local/opt/xcode-mcpkit-dev/bin/xcode-mcp-server" ``` Connect your client using the HTTP commands in Quick start. No `PATH` change is @@ -115,7 +115,7 @@ existing commands there, including links created by the Homebrew migration. Using a separate directory keeps development builds independent of that installation. The installer also accepts `--prefix directory` to install into its `bin` -subdirectory. Run `swift run -c release xcode-mcp-proxy-install --help` for details. +subdirectory. Run `swift run -c release xcode-mcp-install --help` for details. @@ -140,7 +140,7 @@ Stop the server before updating, then start it again: ```bash brew update brew upgrade lynnswap/tap/xcode-mcpkit -xcode-mcp-proxy-server +xcode-mcp-server ``` To uninstall, stop the server and run `brew uninstall xcode-mcpkit`. diff --git a/Sources/ProxyBuildInfoTool/ProxyBuildInfoTool.swift b/Sources/ServerBuildInfoTool/ServerBuildInfoTool.swift similarity index 85% rename from Sources/ProxyBuildInfoTool/ProxyBuildInfoTool.swift rename to Sources/ServerBuildInfoTool/ServerBuildInfoTool.swift index 071d52e6..33fc882e 100644 --- a/Sources/ProxyBuildInfoTool/ProxyBuildInfoTool.swift +++ b/Sources/ServerBuildInfoTool/ServerBuildInfoTool.swift @@ -1,7 +1,7 @@ import Foundation @main -struct ProxyBuildInfoTool { +struct ServerBuildInfoTool { static func main() throws { let options = try Options.parse(arguments: CommandLine.arguments) let outputURL = URL(fileURLWithPath: options.outputPath) @@ -41,32 +41,32 @@ private struct Options { switch arguments[index] { case "--output": guard index + 1 < arguments.count else { - throw ProxyBuildInfoToolError.message("--output requires a value") + throw ServerBuildInfoToolError.message("--output requires a value") } outputPath = arguments[index + 1] index += 2 case "--package-directory": guard index + 1 < arguments.count else { - throw ProxyBuildInfoToolError.message("--package-directory requires a value") + throw ServerBuildInfoToolError.message("--package-directory requires a value") } packageDirectoryPath = arguments[index + 1] index += 2 case "--environment-version": guard index + 1 < arguments.count else { - throw ProxyBuildInfoToolError.message("--environment-version requires a value") + throw ServerBuildInfoToolError.message("--environment-version requires a value") } environmentVersion = arguments[index + 1] index += 2 default: - throw ProxyBuildInfoToolError.message("unknown option: \(arguments[index])") + throw ServerBuildInfoToolError.message("unknown option: \(arguments[index])") } } guard let outputPath else { - throw ProxyBuildInfoToolError.message("--output is required") + throw ServerBuildInfoToolError.message("--output is required") } guard let packageDirectoryPath else { - throw ProxyBuildInfoToolError.message("--package-directory is required") + throw ServerBuildInfoToolError.message("--package-directory is required") } return Self( @@ -98,9 +98,9 @@ private enum BuildInfoVersionResolver { static func generatedSource(version: String) -> String { """ - // Generated by ProxyBuildInfoTool. Do not edit. + // Generated by ServerBuildInfoTool. Do not edit. - enum ProxyBuildGeneratedInfo { + enum ServerBuildGeneratedInfo { static let version = "\(escapedStringLiteral(version))" } """ @@ -146,7 +146,7 @@ private enum BuildInfoVersionResolver { } } -private enum ProxyBuildInfoToolError: Error, CustomStringConvertible { +private enum ServerBuildInfoToolError: Error, CustomStringConvertible { case message(String) var description: String { diff --git a/Sources/XcodeMCPCore/CoreRuntime/Discovery.swift b/Sources/XcodeMCPCore/CoreRuntime/Discovery.swift index af5540e6..9a6b9047 100644 --- a/Sources/XcodeMCPCore/CoreRuntime/Discovery.swift +++ b/Sources/XcodeMCPCore/CoreRuntime/Discovery.swift @@ -24,8 +24,8 @@ package struct DiscoveryRecord: Codable, Sendable { } package enum Discovery { - package static let cacheRootEnvironmentVariable = "XCODE_MCP_PROXY_CACHE_ROOT" - package static let discoveryFileEnvironmentVariable = "XCODE_MCP_PROXY_DISCOVERY_FILE" + package static let cacheRootEnvironmentVariable = "XCODE_MCP_SERVER_CACHE_ROOT" + package static let discoveryFileEnvironmentVariable = "XCODE_MCP_SERVER_DISCOVERY_FILE" package static var defaultFileURL: URL { defaultFileURL(environment: ProcessInfo.processInfo.environment) @@ -53,7 +53,7 @@ package enum Discovery { } return cacheRootURL - .appendingPathComponent("XcodeMCPProxy", isDirectory: true) + .appendingPathComponent("XcodeMCPServer", isDirectory: true) .appendingPathComponent("endpoint.json") } diff --git a/Sources/XcodeMCPCore/ProcessRuntime/Process/NativeHostInvocation.swift b/Sources/XcodeMCPCore/ProcessRuntime/Process/NativeHostInvocation.swift index 15dd15b7..85d851c1 100644 --- a/Sources/XcodeMCPCore/ProcessRuntime/Process/NativeHostInvocation.swift +++ b/Sources/XcodeMCPCore/ProcessRuntime/Process/NativeHostInvocation.swift @@ -25,7 +25,7 @@ package enum NativeHostInvocation { for directory in (environment["PATH"] ?? "").split(separator: ":") { let directoryURL = URL(fileURLWithPath: String(directory), isDirectory: true) candidates.append(directoryURL.appendingPathComponent(bundleName)) - let serverURL = directoryURL.appendingPathComponent("xcode-mcp-proxy-server").resolvingSymlinksInPath() + let serverURL = directoryURL.appendingPathComponent("xcode-mcp-server").resolvingSymlinksInPath() candidates.append(serverURL.deletingLastPathComponent().appendingPathComponent(bundleName)) let linkedExecutable = directoryURL.appendingPathComponent(executableName).resolvingSymlinksInPath() if linkedExecutable.deletingLastPathComponent().lastPathComponent == "MacOS" { diff --git a/Sources/XcodeMCPCore/ProcessRuntime/ProcessRunner.swift b/Sources/XcodeMCPCore/ProcessRuntime/ProcessRunner.swift index 8bed132a..bf774fad 100644 --- a/Sources/XcodeMCPCore/ProcessRuntime/ProcessRunner.swift +++ b/Sources/XcodeMCPCore/ProcessRuntime/ProcessRunner.swift @@ -311,11 +311,11 @@ private final class LiveProcessRunnerProcessDriver: ProcessRunnerProcessDriving, let stdinPipe = Pipe() let stdoutReader = OrderedPipeReader( fileHandle: stdoutPipe.fileHandleForReading, - label: "XcodeMCPProxy.ProcessRunner.stdout" + label: "XcodeMCPServer.ProcessRunner.stdout" ) let stderrReader = OrderedPipeReader( fileHandle: stderrPipe.fileHandleForReading, - label: "XcodeMCPProxy.ProcessRunner.stderr" + label: "XcodeMCPServer.ProcessRunner.stderr" ) process.executableURL = URL(fileURLWithPath: request.executablePath) diff --git a/Sources/XcodeMCPCore/ProcessRuntime/Session/MCPProcessLauncher.swift b/Sources/XcodeMCPCore/ProcessRuntime/Session/MCPProcessLauncher.swift index e3bb8d3e..e891be9d 100644 --- a/Sources/XcodeMCPCore/ProcessRuntime/Session/MCPProcessLauncher.swift +++ b/Sources/XcodeMCPCore/ProcessRuntime/Session/MCPProcessLauncher.swift @@ -169,11 +169,11 @@ private final class LiveMCPProcessDriver: MCPProcessDriving, @unchecked Sendable let stdoutReader = OrderedPipeReader( fileHandle: stdoutPipe.fileHandleForReading, - label: "XcodeMCPProxy.MCPProcessSession.stdout" + label: "XcodeMCPServer.MCPProcessSession.stdout" ) let stderrReader = OrderedPipeReader( fileHandle: stderrPipe.fileHandleForReading, - label: "XcodeMCPProxy.MCPProcessSession.stderr" + label: "XcodeMCPServer.MCPProcessSession.stderr" ) do { @@ -190,7 +190,7 @@ private final class LiveMCPProcessDriver: MCPProcessDriving, @unchecked Sendable let stdinWriter = StdinWriter( fileHandle: stdinPipe.fileHandleForWriting, maxQueuedWriteBytes: maxQueuedWriteBytes, - label: "XcodeMCPProxy.MCPProcessSession.stdin", + label: "XcodeMCPServer.MCPProcessSession.stdin", onComplete: { [weak self] bytes, error in self?.completeStdinWrite(bytes: bytes, error: error) } diff --git a/Sources/XcodeMCPProxyInstall/main.swift b/Sources/XcodeMCPInstallCLI/main.swift similarity index 59% rename from Sources/XcodeMCPProxyInstall/main.swift rename to Sources/XcodeMCPInstallCLI/main.swift index 8ef51782..22ddf3ea 100644 --- a/Sources/XcodeMCPProxyInstall/main.swift +++ b/Sources/XcodeMCPInstallCLI/main.swift @@ -1,11 +1,11 @@ import Foundation -import XcodeMCPProxyKit +import XcodeMCPServerKit -let exitCode = XcodeMCPProxyInstaller.run( +let exitCode = XcodeMCPInstaller.run( arguments: CommandLine.arguments, environment: ProcessInfo.processInfo.environment, stdout: { print($0) }, - stderr: XcodeMCPProxyConsole.writeStandardErrorLine + stderr: XcodeMCPConsole.writeStandardErrorLine ) if exitCode != 0 { exit(exitCode) diff --git a/Sources/XcodeMCPKit/README.md b/Sources/XcodeMCPKit/README.md index af43c18d..c291569e 100644 --- a/Sources/XcodeMCPKit/README.md +++ b/Sources/XcodeMCPKit/README.md @@ -5,9 +5,9 @@ Swift client API for calling Xcode MCP from an app or tool. ## Overview Use `XcodeMCPKit` when Swift code needs to discover and call Xcode MCP tools. -The default transport discovers a running `xcode-mcp-proxy-server` endpoint. -The proxy routes public workspace handles to owned headless models. -Start the proxy before constructing a default client. +The default transport discovers a running `xcode-mcp-server` endpoint. +The server routes public workspace handles to owned headless models. +Start the server before constructing a default client. The public API is intentionally small: @@ -22,7 +22,7 @@ The public API is intentionally small: Use `listTools()` to discover the connected server's operations, `callTool` to invoke them, and `request(_:params:)` for MCP methods outside `tools/call`. The SDK preserves JSON schemas and values rather than providing tool-specific -Swift wrappers. The proxy keeps its public inputs stable across native backends. +Swift wrappers. The server keeps its public inputs stable across native backends. Use `XcodeMCPKitTesting` when tests need deterministic tool catalogs, progress notifications, and tool results through the same `XcodeMCP` API without @@ -30,7 +30,7 @@ launching Xcode or the native helper. ## Quickstart -Add the `XcodeMCPKit` product to your target and start `xcode-mcp-proxy-server`, +Add the `XcodeMCPKit` product to your target and start `xcode-mcp-server`, then construct a client: ```swift @@ -86,7 +86,7 @@ let config = XcodeMCPConfiguration( ``` The default transport, `.server()`, reads the standard discovery location, -including `XCODE_MCP_PROXY_DISCOVERY_FILE` and `XCODE_MCP_PROXY_CACHE_ROOT` +including `XCODE_MCP_SERVER_DISCOVERY_FILE` and `XCODE_MCP_SERVER_CACHE_ROOT` overrides. ### Workspace routing @@ -106,7 +106,7 @@ if let workspace = opened.structuredContent?["workspaceIdentifier"]?.stringValue } ``` -`XcodeListWorkspaces` lists already loaded headless models. The proxy retains +`XcodeListWorkspaces` lists already loaded headless models. The server retains each workspace's host and translates native workspace selectors internally. Obtain fresh identifiers after a new MCP session or host restart. Absolute workspace paths also load saved models in the default headless host when explicit Open is unnecessary. See [workspace usage](../../Docs/usage.md) @@ -132,7 +132,7 @@ await standalone.close() This transport exposes the host's native tools and owns its process lifecycle. Conditions that the transport handles itself, such as process output that is not MCP JSON, are reported to unified logging under the `XcodeMCPKit` subsystem. -Its native catalog and identifiers are outside the proxy's stable tool/handle +Its native catalog and identifiers are outside the server's stable tool/handle contract. Discover its capabilities with `listTools()` and keep native identifiers within that standalone session. @@ -188,7 +188,7 @@ let symbols = try await xcode.request( the default timeout; nonpositive durations are rejected. The standard `XcodeListWindows`, `GetTopCrashIssues`, and `GetCrashIssueLogs` -tools require the HTTP proxy, which routes them through Apple's GUI bridge. +tools require the HTTP server, which routes them through Apple's GUI bridge. Direct native-host transports omit these GUI-only tools from their catalogs. Each operation can override the default with `XcodeMCPTimeout`: @@ -240,7 +240,7 @@ transport, then publishes the terminal state. Deinitialization is only a synchronous cancellation backstop. `XcodeMCPError` conforms to `LocalizedError`. Use `errorDescription` and -`recoverySuggestion` for consumer-facing diagnostics; missing or stale proxy +`recoverySuggestion` for consumer-facing diagnostics; missing or stale server discovery is reported as `transportUnavailable`, not as an invalid request. ## Testing diff --git a/Sources/XcodeMCPKit/XcodeMCP.swift b/Sources/XcodeMCPKit/XcodeMCP.swift index 15d2f004..205d4e22 100644 --- a/Sources/XcodeMCPKit/XcodeMCP.swift +++ b/Sources/XcodeMCPKit/XcodeMCP.swift @@ -24,9 +24,9 @@ public struct XcodeMCPConfiguration: Equatable, Sendable { /// The running server, found through its discovery file in the standard /// location. /// - /// The file path honors `XCODE_MCP_PROXY_DISCOVERY_FILE` first, then - /// `XCODE_MCP_PROXY_CACHE_ROOT`, and otherwise uses the default user - /// caches location used by `xcode-mcp-proxy-server`. + /// The file path honors `XCODE_MCP_SERVER_DISCOVERY_FILE` first, then + /// `XCODE_MCP_SERVER_CACHE_ROOT`, and otherwise uses the default user + /// caches location used by `xcode-mcp-server`. /// /// - Parameter environment: Environment used to resolve the discovery /// file location. diff --git a/Sources/XcodeMCPKit/XcodeMCPError.swift b/Sources/XcodeMCPKit/XcodeMCPError.swift index 0c56a623..3aeed4fe 100644 --- a/Sources/XcodeMCPKit/XcodeMCPError.swift +++ b/Sources/XcodeMCPKit/XcodeMCPError.swift @@ -72,7 +72,7 @@ extension XcodeMCPError: LocalizedError { case .serverError: return "Inspect the server error data and correct the request before retrying." case .transportUnavailable: - return "Start Xcode or the configured proxy, then reconnect." + return "Start Xcode or the configured server, then reconnect." case .sessionRecoveryFailed: return "Call reconnect() after confirming the MCP endpoint is available." } diff --git a/Sources/XcodeMCPKitTesting/README.md b/Sources/XcodeMCPKitTesting/README.md index b73d5994..51675566 100644 --- a/Sources/XcodeMCPKitTesting/README.md +++ b/Sources/XcodeMCPKitTesting/README.md @@ -1,7 +1,7 @@ # XcodeMCPKitTesting `XcodeMCPKitTesting` provides an in-memory MCP runtime for tests that should use -the real `XcodeMCP` public API without launching Xcode, a native helper, or a proxy server. +the real `XcodeMCP` public API without launching Xcode, a native helper, or a server. Use it from app or SDK tests when the production code accepts an `XcodeMCP` client and you want deterministic tool catalogs, progress notifications, and diff --git a/Sources/XcodeMCPKitTesting/XcodeMCPTestRuntime.swift b/Sources/XcodeMCPKitTesting/XcodeMCPTestRuntime.swift index 06a6366b..ad49cede 100644 --- a/Sources/XcodeMCPKitTesting/XcodeMCPTestRuntime.swift +++ b/Sources/XcodeMCPKitTesting/XcodeMCPTestRuntime.swift @@ -3,7 +3,7 @@ import Foundation import XcodeMCPKit /// An in-memory MCP runtime for tests that need an ``XcodeMCP`` client without -/// launching a native host or connecting to a proxy. +/// launching a native host or connecting to a server. /// /// Use this target from app or SDK tests when the code under test should talk /// to the real ``XcodeMCP`` public API, while tool catalogs, tool responses, diff --git a/Sources/XcodeMCPNativeRuntime/NativeHostDiagnostic.swift b/Sources/XcodeMCPNativeRuntime/NativeHostDiagnostic.swift index 73d64147..612b3b99 100644 --- a/Sources/XcodeMCPNativeRuntime/NativeHostDiagnostic.swift +++ b/Sources/XcodeMCPNativeRuntime/NativeHostDiagnostic.swift @@ -11,7 +11,7 @@ package enum NativeHostDiagnostic { } static func formattedMessage(_ message: String, level: Level) -> String { - // The proxy classifies stderr one line at a time, including multiline errors. + // The server classifies stderr one line at a time, including multiline errors. message.split(separator: "\n", omittingEmptySubsequences: false) .map { "[xcode-mcp-native-host] \(level.rawValue) : \($0)" } .joined(separator: "\n") diff --git a/Sources/XcodeMCPNativeRuntime/NativeMCPSession.swift b/Sources/XcodeMCPNativeRuntime/NativeMCPSession.swift index 39b59356..785f160d 100644 --- a/Sources/XcodeMCPNativeRuntime/NativeMCPSession.swift +++ b/Sources/XcodeMCPNativeRuntime/NativeMCPSession.swift @@ -185,7 +185,7 @@ package actor NativeMCPSession { resource: NativeExecutionResource) async throws -> JSONValue { let directory = artifactsRoot.appendingPathComponent(UUID().uuidString, isDirectory: true) try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) - // The proxy identifies the calling MCP session and its selection for a headless workspace. + // The server identifies the calling MCP session and its selection for a headless workspace. var metadata: [String: JSONValue] = [:] if case .object(let fields)? = fieldsForMetadata(params) { metadata = fields } // Results can name files in the directory, so only a directory nothing was written to is removed. diff --git a/Sources/XcodeMCPNativeRuntime/NativeWorkspaceSelections.swift b/Sources/XcodeMCPNativeRuntime/NativeWorkspaceSelections.swift index fcd3ef03..abba7233 100644 --- a/Sources/XcodeMCPNativeRuntime/NativeWorkspaceSelections.swift +++ b/Sources/XcodeMCPNativeRuntime/NativeWorkspaceSelections.swift @@ -3,7 +3,7 @@ import XcodeMCPWire /// The scheme, run destination, and test plan that one MCP session uses in a headless workspace. package struct NativeWorkspaceSelection: Equatable, Sendable { - /// The `_meta` key of a selection in requests and results between the proxy and the host. + /// The `_meta` key of a selection in requests and results between the server and the host. package static let metadataKey = "com.lynnswap.xcode-mcpkit/selection" /// The scheme's name, with its container when several schemes share the name. @@ -27,7 +27,7 @@ package struct NativeWorkspaceSelection: Equatable, Sendable { return selection } - /// Reads the selection that the proxy sends in a request's `_meta`. + /// Reads the selection that the server sends in a request's `_meta`. package init?(json: JSONValue?) { guard case .object(let fields)? = json else { return nil } self.init(scheme: Self.string(fields["scheme"]), destination: Self.string(fields["destination"]), diff --git a/Sources/XcodeMCPProxyServer/XcodeMCPProxyServer.swift b/Sources/XcodeMCPServerCLI/XcodeMCPServerMain.swift similarity index 59% rename from Sources/XcodeMCPProxyServer/XcodeMCPProxyServer.swift rename to Sources/XcodeMCPServerCLI/XcodeMCPServerMain.swift index d47654d3..9ae70b29 100644 --- a/Sources/XcodeMCPProxyServer/XcodeMCPProxyServer.swift +++ b/Sources/XcodeMCPServerCLI/XcodeMCPServerMain.swift @@ -1,17 +1,17 @@ import Foundation -import XcodeMCPProxyKit +import XcodeMCPServerKit @main -struct XcodeMCPProxyServerMain { +struct XcodeMCPServerMain { static func main() async { - XcodeMCPProxyKit.XcodeMCPProxyServer.bootstrapLogging( + XcodeMCPServerKit.XcodeMCPServer.bootstrapLogging( environment: ProcessInfo.processInfo.environment ) - let exitCode = await XcodeMCPProxyKit.XcodeMCPProxyServer.run( + let exitCode = await XcodeMCPServerKit.XcodeMCPServer.run( arguments: CommandLine.arguments, environment: ProcessInfo.processInfo.environment, stdout: { print($0) }, - stderr: XcodeMCPProxyConsole.writeStandardErrorLine + stderr: XcodeMCPConsole.writeStandardErrorLine ) guard exitCode != 0 else { return diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPControlService.swift b/Sources/XcodeMCPServerHTTP/HTTP/HTTPControlService.swift similarity index 94% rename from Sources/XcodeMCPProxyHTTP/HTTP/HTTPControlService.swift rename to Sources/XcodeMCPServerHTTP/HTTP/HTTPControlService.swift index a178bd92..4e09e6d1 100644 --- a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPControlService.swift +++ b/Sources/XcodeMCPServerHTTP/HTTP/HTTPControlService.swift @@ -3,10 +3,10 @@ import Logging import NIO import NIOConcurrencyHelpers import XcodeMCPCore -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract struct HTTPNotificationOverflowWarning: Equatable, Sendable { - let sessionID: ProxySessionID + let sessionID: ServerSessionID let droppedNotificationCount: UInt64 let droppedSinceLastWarning: UInt64 let droppedMethodsSinceLastWarning: [String: UInt64] @@ -19,7 +19,7 @@ private enum HTTPEventDeliveryStoreError: Error { /// A request's claim on its session's progress notifications for one progress token. struct HTTPProgressRoute: Sendable { - fileprivate let sessionID: ProxySessionID + fileprivate let sessionID: ServerSessionID fileprivate let tokenKey: String fileprivate let id = UUID() } @@ -44,8 +44,8 @@ final class HTTPEventDeliveryStore: Sendable { var progressReceivers: [String: (route: UUID, receive: @Sendable (Data) -> Void)] = [:] } - private let sessions = NIOLockedValueBox<[ProxySessionID: SessionDelivery]>([:]) - private let logger = Logger(label: "XcodeMCPProxy.http.sse") + private let sessions = NIOLockedValueBox<[ServerSessionID: SessionDelivery]>([:]) + private let logger = Logger(label: "XcodeMCPServer.http.sse") private let bufferLimit: Int private let notificationOverflowWarningIntervalNanoseconds: UInt64 private let uptimeNanoseconds: @Sendable () -> UInt64 @@ -70,7 +70,7 @@ final class HTTPEventDeliveryStore: Sendable { } /// Starts buffering notifications for a session until a client stream opens. - func register(_ sessionID: ProxySessionID) { + func register(_ sessionID: ServerSessionID) { sessions.withLockedValue { sessions in if sessions[sessionID] == nil { sessions[sessionID] = SessionDelivery() @@ -80,7 +80,7 @@ final class HTTPEventDeliveryStore: Sendable { /// Delivers a notification for a session. Progress goes to the request that routed its token /// and is dropped when no running request did; others go to the session's event stream. - func deliver(_ data: Data, to sessionID: ProxySessionID) { + func deliver(_ data: Data, to sessionID: ServerSessionID) { let object = try? JSONSerialization.jsonObject(with: data) as? [String: Any] guard object?["method"] as? String == "notifications/progress" else { receiveNotification(data, sessionID: sessionID) @@ -95,7 +95,7 @@ final class HTTPEventDeliveryStore: Sendable { /// Sends the session's progress notifications for `token` to `receive` until /// ``removeProgressRoute(_:)``. Returns `nil` for an unknown session or a token that is /// neither a string nor a number. - func routeProgress(_ token: Any, of sessionID: ProxySessionID, + func routeProgress(_ token: Any, of sessionID: ServerSessionID, to receive: @escaping @Sendable (Data) -> Void) -> HTTPProgressRoute? { guard let key = Self.progressTokenKey(token) else { return nil } let route = HTTPProgressRoute(sessionID: sessionID, tokenKey: key) @@ -129,13 +129,13 @@ final class HTTPEventDeliveryStore: Sendable { } /// Drops a session's buffered notifications and closes its streams. - func remove(_ sessionID: ProxySessionID) { + func remove(_ sessionID: ServerSessionID) { let delivery = sessions.withLockedValue { $0.removeValue(forKey: sessionID) } delivery?.hub.closeAll() } @discardableResult - func open(sessionID: ProxySessionID, channel: Channel) -> Bool { + func open(sessionID: ServerSessionID, channel: Channel) -> Bool { sessions.withLockedValue { sessions in guard var delivery = sessions[sessionID] else { return false } switch delivery.hub.add(channel) { @@ -159,13 +159,13 @@ final class HTTPEventDeliveryStore: Sendable { } } - func close(sessionID: ProxySessionID, channel: Channel) { + func close(sessionID: ServerSessionID, channel: Channel) { sessions.withLockedValue { sessions in sessions[sessionID]?.hub.remove(channel) } } - func waitForClient(sessionID: ProxySessionID) async throws { + func waitForClient(sessionID: ServerSessionID) async throws { guard let hub = sessions.withLockedValue({ $0[sessionID]?.hub }) else { throw HTTPEventDeliveryStoreError.sessionNotOpen } @@ -183,7 +183,7 @@ final class HTTPEventDeliveryStore: Sendable { } } - private func receiveNotification(_ data: Data, sessionID: ProxySessionID) { + private func receiveNotification(_ data: Data, sessionID: ServerSessionID) { deliverOrBuffer( BufferedNotification(data: data, method: Self.messageMethod(from: data)), sessionID: sessionID, @@ -193,7 +193,7 @@ final class HTTPEventDeliveryStore: Sendable { private func deliverOrBuffer( _ notification: BufferedNotification, - sessionID: ProxySessionID, + sessionID: ServerSessionID, expectedHub: SSEHub? ) { var warning: HTTPNotificationOverflowWarning? @@ -285,7 +285,7 @@ final class HTTPEventDeliveryStore: Sendable { private func broadcast( _ notification: BufferedNotification, - sessionID: ProxySessionID, + sessionID: ServerSessionID, hub: SSEHub ) -> SSEHub.BroadcastResult { hub.broadcast(notification.data) { [weak self] in @@ -409,12 +409,12 @@ final class HTTPControlService: Sendable { static let defaultSessionInactivityGrace: TimeAmount = .seconds(5 * 60) static let defaultSessionExpirySweepInterval: TimeAmount = .seconds(60) - private let runtime: any ProxyRuntimeServing + private let runtime: any ServerRuntimeServing let sessions: HTTPSessionStore private let sessionExpirySweep: HTTPSessionExpirySweep init( - runtime: any ProxyRuntimeServing, + runtime: any ServerRuntimeServing, deliveryStore: HTTPEventDeliveryStore = HTTPEventDeliveryStore(), sessionInactivityGrace: TimeAmount = HTTPControlService.defaultSessionInactivityGrace, sessionExpirySweepInterval: TimeAmount = @@ -453,7 +453,7 @@ final class HTTPControlService: Sendable { ) } - func waitForSSEClient(sessionID: ProxySessionID) async throws { + func waitForSSEClient(sessionID: ServerSessionID) async throws { try await sessions.delivery.waitForClient(sessionID: sessionID) } diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPHandler+Responses.swift b/Sources/XcodeMCPServerHTTP/HTTP/HTTPHandler+Responses.swift similarity index 98% rename from Sources/XcodeMCPProxyHTTP/HTTP/HTTPHandler+Responses.swift rename to Sources/XcodeMCPServerHTTP/HTTP/HTTPHandler+Responses.swift index 20946ab3..dc5ca33e 100644 --- a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPHandler+Responses.swift +++ b/Sources/XcodeMCPServerHTTP/HTTP/HTTPHandler+Responses.swift @@ -3,7 +3,7 @@ import NIO import NIOConcurrencyHelpers import NIOHTTP1 import XcodeMCPCore -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract /// The response to one POST request. The request's first progress notification or keepalive /// opens it as an event stream, which then carries the reply; a quick reply is sent as JSON. @@ -82,7 +82,7 @@ extension HTTPHandler { } func sendPostResolution( - _ resolution: ProxyRuntimeReply, + _ resolution: ServerRuntimeReply, in response: HTTPPostResponse, on channel: Channel, keepAlive: Bool, diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPHandler.swift b/Sources/XcodeMCPServerHTTP/HTTP/HTTPHandler.swift similarity index 96% rename from Sources/XcodeMCPProxyHTTP/HTTP/HTTPHandler.swift rename to Sources/XcodeMCPServerHTTP/HTTP/HTTPHandler.swift index abda3193..a1ae1845 100644 --- a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPHandler.swift +++ b/Sources/XcodeMCPServerHTTP/HTTP/HTTPHandler.swift @@ -5,7 +5,7 @@ import NIOFoundationCompat import NIOHTTP1 import NIOConcurrencyHelpers import XcodeMCPCore -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract final class HTTPHandler: ChannelDuplexHandler, Sendable { typealias InboundIn = HTTPServerRequestPart @@ -25,9 +25,9 @@ final class HTTPHandler: ChannelDuplexHandler, Sendable { } struct ActivePostRequest: Sendable { - let call: any ProxyRuntimeCall + let call: any ServerRuntimeCall /// The session the request holds until its reply is written. - let sessionID: ProxySessionID + let sessionID: ServerSessionID let progressRoute: HTTPProgressRoute? let keepalive: RepeatedTask? } @@ -46,16 +46,16 @@ final class HTTPHandler: ChannelDuplexHandler, Sendable { } let state = NIOLockedValueBox(State()) - let config: ProxyHTTPConfiguration + let config: ServerHTTPConfiguration let controlService: HTTPControlService let responseWriter: HTTPResponseWriter let requestSecurityPolicy: HTTPRequestSecurityPolicy let scheduleResponseCompletion: @Sendable (EventLoop, @escaping @Sendable () -> Void) -> Void - let logger: Logger = Logger(label: "XcodeMCPProxy.http") + let logger: Logger = Logger(label: "XcodeMCPServer.http") init( - config: ProxyHTTPConfiguration, + config: ServerHTTPConfiguration, controlService: HTTPControlService, scheduleResponseCompletion: @escaping @Sendable ( EventLoop, @@ -66,7 +66,7 @@ final class HTTPHandler: ChannelDuplexHandler, Sendable { ) { self.config = config self.controlService = controlService - self.responseWriter = HTTPResponseWriter(logger: Logger(label: "XcodeMCPProxy.http.response")) + self.responseWriter = HTTPResponseWriter(logger: Logger(label: "XcodeMCPServer.http.response")) self.requestSecurityPolicy = HTTPRequestSecurityPolicy( configuredHost: config.listenHost, configuredPort: config.listenPort @@ -148,7 +148,7 @@ final class HTTPHandler: ChannelDuplexHandler, Sendable { } sseKeepalive?.cancel() if let sessionID { - controlService.sessions.closeStream(ProxySessionID(rawValue: sessionID), channel: context.channel) + controlService.sessions.closeStream(ServerSessionID(rawValue: sessionID), channel: context.channel) } // The runtime replies to a cancelled request at once; nothing is left to write it to. for request in activePostRequests { @@ -354,7 +354,7 @@ final class HTTPHandler: ChannelDuplexHandler, Sendable { return } - guard controlService.sessions.openStream(ProxySessionID(rawValue: sessionID), channel: context.channel) else { + guard controlService.sessions.openStream(ServerSessionID(rawValue: sessionID), channel: context.channel) else { _ = sendPlain( on: context.channel, status: .notFound, @@ -409,7 +409,7 @@ final class HTTPHandler: ChannelDuplexHandler, Sendable { else { return } - controlService.sessions.delete(ProxySessionID(rawValue: sessionID)) + controlService.sessions.delete(ServerSessionID(rawValue: sessionID)) _ = sendEmpty(on: context.channel, status: .ok, keepAlive: head.isKeepAlive, sessionID: sessionID, requestLog: requestLog) } @@ -441,7 +441,7 @@ final class HTTPHandler: ChannelDuplexHandler, Sendable { return } - let request = ProxyRuntimeRequest(data: bodyData) + let request = ServerRuntimeRequest(data: bodyData) let parsedRequestJSON = request.decodedJSON?.foundationObject if parsedRequestJSON is [Any] { _ = sendPlain( @@ -470,8 +470,8 @@ final class HTTPHandler: ChannelDuplexHandler, Sendable { let keepAlive = head.isKeepAlive let channel = context.channel let eventLoop = context.eventLoop - let sessionID: ProxySessionID - let session: any ProxyRuntimeSession + let sessionID: ServerSessionID + let session: any ServerRuntimeSession if isInitializeRequest { guard hasValidInitializeID else { // Without a request id, `initialize` cannot start a session. @@ -479,7 +479,7 @@ final class HTTPHandler: ChannelDuplexHandler, Sendable { _ = sendJSONData(on: channel, data: data, keepAlive: keepAlive, sessionID: nil, requestLog: requestLog) return } - sessionID = ProxySessionID(rawValue: UUID().uuidString) + sessionID = ServerSessionID(rawValue: UUID().uuidString) do { session = try controlService.sessions.create(sessionID) } catch { @@ -498,7 +498,7 @@ final class HTTPHandler: ChannelDuplexHandler, Sendable { else { return } - sessionID = ProxySessionID(rawValue: validated) + sessionID = ServerSessionID(rawValue: validated) // The only "session not found" for a POST is answered here, before processing starts. guard let acquired = controlService.sessions.acquire(sessionID) else { _ = sendPlain(on: channel, status: .notFound, body: "session not found", keepAlive: keepAlive, @@ -580,7 +580,7 @@ final class HTTPHandler: ChannelDuplexHandler, Sendable { } /// The protocol version a successful `initialize` reply negotiated, or `nil` for a failed one. - private static func negotiatedProtocolVersion(in reply: ProxyRuntimeReply) -> String?? { + private static func negotiatedProtocolVersion(in reply: ServerRuntimeReply) -> String?? { guard case .response(let data) = reply, let object = try? JSONRPC.Wire.object(fromData: data), let result = object["result"] as? [String: Any] else { return nil } return .some(result["protocolVersion"] as? String) @@ -619,7 +619,7 @@ final class HTTPHandler: ChannelDuplexHandler, Sendable { ) return nil } - let sessionIDValue = ProxySessionID(rawValue: sessionID) + let sessionIDValue = ServerSessionID(rawValue: sessionID) guard let phase = controlService.sessions.phase(of: sessionIDValue) else { _ = sendPlain( on: channel, diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPRequestSecurityPolicy.swift b/Sources/XcodeMCPServerHTTP/HTTP/HTTPRequestSecurityPolicy.swift similarity index 100% rename from Sources/XcodeMCPProxyHTTP/HTTP/HTTPRequestSecurityPolicy.swift rename to Sources/XcodeMCPServerHTTP/HTTP/HTTPRequestSecurityPolicy.swift diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPRequestValidator.swift b/Sources/XcodeMCPServerHTTP/HTTP/HTTPRequestValidator.swift similarity index 100% rename from Sources/XcodeMCPProxyHTTP/HTTP/HTTPRequestValidator.swift rename to Sources/XcodeMCPServerHTTP/HTTP/HTTPRequestValidator.swift diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPResponseWriter.swift b/Sources/XcodeMCPServerHTTP/HTTP/HTTPResponseWriter.swift similarity index 98% rename from Sources/XcodeMCPProxyHTTP/HTTP/HTTPResponseWriter.swift rename to Sources/XcodeMCPServerHTTP/HTTP/HTTPResponseWriter.swift index 320d0556..e04241a5 100644 --- a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPResponseWriter.swift +++ b/Sources/XcodeMCPServerHTTP/HTTP/HTTPResponseWriter.swift @@ -3,7 +3,7 @@ import Logging import NIO import NIOHTTP1 import XcodeMCPCore -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract struct HTTPResponseWriter: Sendable { private let logger: Logger diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPRoute.swift b/Sources/XcodeMCPServerHTTP/HTTP/HTTPRoute.swift similarity index 100% rename from Sources/XcodeMCPProxyHTTP/HTTP/HTTPRoute.swift rename to Sources/XcodeMCPServerHTTP/HTTP/HTTPRoute.swift diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPSessionStore.swift b/Sources/XcodeMCPServerHTTP/HTTP/HTTPSessionStore.swift similarity index 82% rename from Sources/XcodeMCPProxyHTTP/HTTP/HTTPSessionStore.swift rename to Sources/XcodeMCPServerHTTP/HTTP/HTTPSessionStore.swift index 10ac5c50..a6cbb117 100644 --- a/Sources/XcodeMCPProxyHTTP/HTTP/HTTPSessionStore.swift +++ b/Sources/XcodeMCPServerHTTP/HTTP/HTTPSessionStore.swift @@ -1,7 +1,7 @@ import Foundation import NIO import NIOConcurrencyHelpers -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract /// The gateway's MCP sessions. It decides when each one is created, in use, expired, and deleted, /// and ends the runtime's side of a session when it is deleted. @@ -13,7 +13,7 @@ final class HTTPSessionStore: Sendable { } private struct Entry: Sendable { - let session: any ProxyRuntimeSession + let session: any ServerRuntimeSession var phase: Phase = .initializing /// Requests that use the session; the `initialize` request holds the first. var leases = 1 @@ -22,7 +22,7 @@ final class HTTPSessionStore: Sendable { } private struct State: Sendable { - var entries: [ProxySessionID: Entry] = [:] + var entries: [ServerSessionID: Entry] = [:] /// Runtime resets in progress, during which no session starts. var resetsInProgress = 0 /// Counts the resets that have started. A session opened before a reset started must not @@ -31,11 +31,11 @@ final class HTTPSessionStore: Sendable { } private let state = NIOLockedValueBox(State()) - private let runtime: any ProxyRuntimeServing + private let runtime: any ServerRuntimeServing let delivery: HTTPEventDeliveryStore private let uptimeNanoseconds: @Sendable () -> UInt64 - init(runtime: any ProxyRuntimeServing, delivery: HTTPEventDeliveryStore, + init(runtime: any ServerRuntimeServing, delivery: HTTPEventDeliveryStore, uptimeNanoseconds: @escaping @Sendable () -> UInt64 = { DispatchTime.now().uptimeNanoseconds }) { self.runtime = runtime self.delivery = delivery @@ -43,11 +43,11 @@ final class HTTPSessionStore: Sendable { } /// Opens a session for an `initialize` request, which holds it until ``release(_:)``. - func create(_ id: ProxySessionID) throws -> any ProxyRuntimeSession { + func create(_ id: ServerSessionID) throws -> any ServerRuntimeSession { let generation = state.withLockedValue { $0.resetsInProgress == 0 ? $0.resetGeneration : nil } - guard let generation else { throw ProxyRuntimeUnavailable() } + guard let generation else { throw ServerRuntimeUnavailable() } delivery.register(id) - let session: any ProxyRuntimeSession + let session: any ServerRuntimeSession do { session = try runtime.openSession(id) { [delivery] data in delivery.deliver(data, to: id) } } catch { @@ -62,22 +62,22 @@ final class HTTPSessionStore: Sendable { guard created else { delivery.remove(id) session.close() - throw ProxyRuntimeUnavailable() + throw ServerRuntimeUnavailable() } return session } - func phase(of id: ProxySessionID) -> Phase? { + func phase(of id: ServerSessionID) -> Phase? { state.withLockedValue { $0.entries[id]?.phase } } - func markInitialized(_ id: ProxySessionID, protocolVersion: String?) { + func markInitialized(_ id: ServerSessionID, protocolVersion: String?) { state.withLockedValue { $0.entries[id]?.phase = .initialized(protocolVersion: protocolVersion) } } /// Lets one request use the session until ``release(_:)``. Returns `nil` for an unknown session, /// before the request is processed. - func acquire(_ id: ProxySessionID) -> (any ProxyRuntimeSession)? { + func acquire(_ id: ServerSessionID) -> (any ServerRuntimeSession)? { state.withLockedValue { state in guard var entry = state.entries[id] else { return nil } entry.leases += 1 @@ -87,7 +87,7 @@ final class HTTPSessionStore: Sendable { } } - func release(_ id: ProxySessionID) { + func release(_ id: ServerSessionID) { state.withLockedValue { state in state.entries[id]?.leases -= 1 state.entries[id]?.lastActivity = uptimeNanoseconds() @@ -95,7 +95,7 @@ final class HTTPSessionStore: Sendable { } /// Attaches a client's event stream. Returns `false` for an unknown session. - func openStream(_ id: ProxySessionID, channel: Channel) -> Bool { + func openStream(_ id: ServerSessionID, channel: Channel) -> Bool { let opened = state.withLockedValue { state in guard state.entries[id] != nil else { return false } state.entries[id]?.streams += 1 @@ -109,7 +109,7 @@ final class HTTPSessionStore: Sendable { return true } - func closeStream(_ id: ProxySessionID, channel: Channel) { + func closeStream(_ id: ServerSessionID, channel: Channel) { delivery.close(sessionID: id, channel: channel) state.withLockedValue { state in state.entries[id]?.streams -= 1 @@ -119,7 +119,7 @@ final class HTTPSessionStore: Sendable { /// Deletes a session and ends its runtime side. Returns `false` for an unknown session. @discardableResult - func delete(_ id: ProxySessionID) -> Bool { + func delete(_ id: ServerSessionID) -> Bool { guard let entry = state.withLockedValue({ $0.entries.removeValue(forKey: id) }) else { return false } end(id, entry) return true @@ -128,7 +128,7 @@ final class HTTPSessionStore: Sendable { /// Deletes sessions that no request or stream has used for `grace`. func expire(inactiveFor grace: TimeAmount) { let now = uptimeNanoseconds() - let expired = state.withLockedValue { state -> [(ProxySessionID, Entry)] in + let expired = state.withLockedValue { state -> [(ServerSessionID, Entry)] in let expired = state.entries.filter { _, entry in entry.leases == 0 && entry.streams == 0 && now >= entry.lastActivity && now - entry.lastActivity >= UInt64(max(0, grace.nanoseconds)) @@ -140,7 +140,7 @@ final class HTTPSessionStore: Sendable { } func closeAll() { - let all = state.withLockedValue { state -> [(ProxySessionID, Entry)] in + let all = state.withLockedValue { state -> [(ServerSessionID, Entry)] in defer { state.entries.removeAll() } return Array(state.entries) } @@ -159,7 +159,7 @@ final class HTTPSessionStore: Sendable { state.withLockedValue { $0.resetsInProgress -= 1 } } - private func end(_ id: ProxySessionID, _ entry: Entry) { + private func end(_ id: ServerSessionID, _ entry: Entry) { delivery.remove(id) entry.session.close() } diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/MCPResponseEmitter.swift b/Sources/XcodeMCPServerHTTP/HTTP/MCPResponseEmitter.swift similarity index 100% rename from Sources/XcodeMCPProxyHTTP/HTTP/MCPResponseEmitter.swift rename to Sources/XcodeMCPServerHTTP/HTTP/MCPResponseEmitter.swift diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/RuntimeScheduledTimeout.swift b/Sources/XcodeMCPServerHTTP/HTTP/RuntimeScheduledTimeout.swift similarity index 100% rename from Sources/XcodeMCPProxyHTTP/HTTP/RuntimeScheduledTimeout.swift rename to Sources/XcodeMCPServerHTTP/HTTP/RuntimeScheduledTimeout.swift diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/SSEHub.swift b/Sources/XcodeMCPServerHTTP/HTTP/SSEHub.swift similarity index 98% rename from Sources/XcodeMCPProxyHTTP/HTTP/SSEHub.swift rename to Sources/XcodeMCPServerHTTP/HTTP/SSEHub.swift index fde0e153..1e779a96 100644 --- a/Sources/XcodeMCPProxyHTTP/HTTP/SSEHub.swift +++ b/Sources/XcodeMCPServerHTTP/HTTP/SSEHub.swift @@ -4,7 +4,7 @@ import NIO import NIOHTTP1 import NIOConcurrencyHelpers import XcodeMCPCore -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract final class SSEHub: Sendable { enum AddResult { @@ -96,7 +96,7 @@ final class SSEHub: Sendable { } private let state = NIOLockedValueBox(State()) - private let logger: Logger = Logger(label: "XcodeMCPProxy.sse") + private let logger: Logger = Logger(label: "XcodeMCPServer.sse") var hasActiveClients: Bool { state.withLockedValue { $0.hasActiveClients() } diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/ProxyHTTPChildChannelInitializer.swift b/Sources/XcodeMCPServerHTTP/HTTP/ServerHTTPChildChannelInitializer.swift similarity index 86% rename from Sources/XcodeMCPProxyHTTP/HTTP/ProxyHTTPChildChannelInitializer.swift rename to Sources/XcodeMCPServerHTTP/HTTP/ServerHTTPChildChannelInitializer.swift index 18049cc0..a4632255 100644 --- a/Sources/XcodeMCPProxyHTTP/HTTP/ProxyHTTPChildChannelInitializer.swift +++ b/Sources/XcodeMCPServerHTTP/HTTP/ServerHTTPChildChannelInitializer.swift @@ -1,16 +1,16 @@ import Logging import NIO import NIOHTTP1 -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract -package final class ProxyHTTPChildChannelInitializer: @unchecked Sendable { - private let config: ProxyHTTPConfiguration +package final class ServerHTTPChildChannelInitializer: @unchecked Sendable { + private let config: ServerHTTPConfiguration private let controlService: HTTPControlService private let logger: Logger package init( - config: ProxyHTTPConfiguration, - runtime: any ProxyRuntimeServing, + config: ServerHTTPConfiguration, + runtime: any ServerRuntimeServing, logger: Logger ) { self.config = config diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/ProxyHTTPConfiguration.swift b/Sources/XcodeMCPServerHTTP/HTTP/ServerHTTPConfiguration.swift similarity index 93% rename from Sources/XcodeMCPProxyHTTP/HTTP/ProxyHTTPConfiguration.swift rename to Sources/XcodeMCPServerHTTP/HTTP/ServerHTTPConfiguration.swift index def57572..55ad61b2 100644 --- a/Sources/XcodeMCPProxyHTTP/HTTP/ProxyHTTPConfiguration.swift +++ b/Sources/XcodeMCPServerHTTP/HTTP/ServerHTTPConfiguration.swift @@ -1,4 +1,4 @@ -package struct ProxyHTTPConfiguration: Sendable { +package struct ServerHTTPConfiguration: Sendable { package let listenHost: String package let listenPort: Int package let maxBodyBytes: Int diff --git a/Sources/XcodeMCPProxyHTTP/HTTP/ProxyHTTPGateway.swift b/Sources/XcodeMCPServerHTTP/HTTP/ServerHTTPGateway.swift similarity index 89% rename from Sources/XcodeMCPProxyHTTP/HTTP/ProxyHTTPGateway.swift rename to Sources/XcodeMCPServerHTTP/HTTP/ServerHTTPGateway.swift index 1f69c80e..542a9f83 100644 --- a/Sources/XcodeMCPProxyHTTP/HTTP/ProxyHTTPGateway.swift +++ b/Sources/XcodeMCPServerHTTP/HTTP/ServerHTTPGateway.swift @@ -2,32 +2,32 @@ import Foundation import Logging import NIO import NIOConcurrencyHelpers -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract -package struct ProxyHTTPEndpoint: Equatable, Sendable { +package struct ServerHTTPEndpoint: Equatable, Sendable { package let host: String package let port: Int } -package protocol ProxyHTTPGatewayServing: Sendable { - func start() async throws -> ProxyHTTPEndpoint +package protocol ServerHTTPGatewayServing: Sendable { + func start() async throws -> ServerHTTPEndpoint func waitUntilShutdown() async throws func shutdown() async throws func cancelForDeinit() } -package final class ProxyHTTPGateway: ProxyHTTPGatewayServing, Sendable { +package final class ServerHTTPGateway: ServerHTTPGatewayServing, Sendable { private final class Resources: @unchecked Sendable { let group: EventLoopGroup - let acceptedChannelTracker: ProxyAcceptedChannelTracker + let acceptedChannelTracker: ServerAcceptedChannelTracker let listenChannels: [Channel] - let childInitializer: ProxyHTTPChildChannelInitializer + let childInitializer: ServerHTTPChildChannelInitializer init( group: EventLoopGroup, - acceptedChannelTracker: ProxyAcceptedChannelTracker, + acceptedChannelTracker: ServerAcceptedChannelTracker, listenChannels: [Channel], - childInitializer: ProxyHTTPChildChannelInitializer + childInitializer: ServerHTTPChildChannelInitializer ) { self.group = group self.acceptedChannelTracker = acceptedChannelTracker @@ -71,8 +71,8 @@ package final class ProxyHTTPGateway: ProxyHTTPGatewayServing, Sendable { case stopped((any Error)?) } - private let configuration: ProxyHTTPConfiguration - private let runtime: any ProxyRuntimeServing + private let configuration: ServerHTTPConfiguration + private let runtime: any ServerRuntimeServing private let logger: Logger private let cancellationAuthority: CancellationAuthority private let bind: @Sendable (ServerBootstrap, String, Int) async throws -> Channel @@ -81,8 +81,8 @@ package final class ProxyHTTPGateway: ProxyHTTPGatewayServing, Sendable { private var resources: Resources? init( - configuration: ProxyHTTPConfiguration, - runtime: any ProxyRuntimeServing, + configuration: ServerHTTPConfiguration, + runtime: any ServerRuntimeServing, logger: Logger, cancellationAuthority: CancellationAuthority, bind: @escaping @Sendable (ServerBootstrap, String, Int) async throws -> Channel, @@ -96,14 +96,14 @@ package final class ProxyHTTPGateway: ProxyHTTPGatewayServing, Sendable { self.shutdownGroup = shutdownGroup } - func start() async throws -> ProxyHTTPEndpoint { + func start() async throws -> ServerHTTPEndpoint { guard case .idle = phase else { preconditionFailure("HTTP gateway may only be started once") } let group = MultiThreadedEventLoopGroup(numberOfThreads: 1) - let tracker = ProxyAcceptedChannelTracker() - let childInitializer = ProxyHTTPChildChannelInitializer( + let tracker = ServerAcceptedChannelTracker() + let childInitializer = ServerHTTPChildChannelInitializer( config: configuration, runtime: runtime, logger: logger @@ -118,7 +118,7 @@ package final class ProxyHTTPGateway: ProxyHTTPGatewayServing, Sendable { value: 1 ) bootstrap = bootstrap.serverChannelInitializer { [logger] channel in - channel.pipeline.addHandler(ProxyAcceptedChannelHandler(tracker: tracker, logger: logger)) + channel.pipeline.addHandler(ServerAcceptedChannelHandler(tracker: tracker, logger: logger)) } bootstrap = bootstrap.childChannelInitializer { channel in childInitializer.initialize(channel) @@ -148,7 +148,7 @@ package final class ProxyHTTPGateway: ProxyHTTPGatewayServing, Sendable { self.resources = resources cancellationAuthority.install(resources) phase = .running - return ProxyHTTPEndpoint( + return ServerHTTPEndpoint( host: first.localAddress?.ipAddress ?? configuration.listenHost, port: first.localAddress?.port ?? configuration.listenPort ) @@ -264,7 +264,7 @@ package final class ProxyHTTPGateway: ProxyHTTPGatewayServing, Sendable { } details.append("HTTP resource release may be incomplete.") return NSError( - domain: "XcodeMCPProxyHTTP.Cleanup", + domain: "XcodeMCPServerHTTP.Cleanup", code: 1, userInfo: [ NSLocalizedDescriptionKey: details.joined(separator: "\n"), @@ -312,8 +312,8 @@ package final class ProxyHTTPGateway: ProxyHTTPGatewayServing, Sendable { private let cancellationAuthority: CancellationAuthority package init( - configuration: ProxyHTTPConfiguration, - runtime: any ProxyRuntimeServing, + configuration: ServerHTTPConfiguration, + runtime: any ServerRuntimeServing, logger: Logger, bind: @escaping @Sendable (ServerBootstrap, String, Int) async throws -> Channel = { try await $0.bind(host: $1, port: $2).get() @@ -338,7 +338,7 @@ package final class ProxyHTTPGateway: ProxyHTTPGatewayServing, Sendable { cancellationAuthority.cancel() } - package func start() async throws -> ProxyHTTPEndpoint { + package func start() async throws -> ServerHTTPEndpoint { try await lifecycle.start() } @@ -355,7 +355,7 @@ package final class ProxyHTTPGateway: ProxyHTTPGatewayServing, Sendable { } } -private final class ProxyAcceptedChannelTracker: @unchecked Sendable { +private final class ServerAcceptedChannelTracker: @unchecked Sendable { private let channels = NIOLockedValueBox<[ObjectIdentifier: Channel]>([:]) func register(_ channel: Channel) { @@ -371,13 +371,13 @@ private final class ProxyAcceptedChannelTracker: @unchecked Sendable { } } -private final class ProxyAcceptedChannelHandler: ChannelInboundHandler, Sendable { +private final class ServerAcceptedChannelHandler: ChannelInboundHandler, Sendable { typealias InboundIn = Channel - private let tracker: ProxyAcceptedChannelTracker + private let tracker: ServerAcceptedChannelTracker private let logger: Logger - init(tracker: ProxyAcceptedChannelTracker, logger: Logger) { + init(tracker: ServerAcceptedChannelTracker, logger: Logger) { self.tracker = tracker self.logger = logger } diff --git a/Sources/XcodeMCPProxyKit/Internal/CLI/Common/CLICommandParser.swift b/Sources/XcodeMCPServerKit/Internal/CLI/Common/CLICommandParser.swift similarity index 100% rename from Sources/XcodeMCPProxyKit/Internal/CLI/Common/CLICommandParser.swift rename to Sources/XcodeMCPServerKit/Internal/CLI/Common/CLICommandParser.swift diff --git a/Sources/XcodeMCPProxyKit/Internal/CLI/Install/ProxyInstallCommand.swift b/Sources/XcodeMCPServerKit/Internal/CLI/Install/InstallCommand.swift similarity index 76% rename from Sources/XcodeMCPProxyKit/Internal/CLI/Install/ProxyInstallCommand.swift rename to Sources/XcodeMCPServerKit/Internal/CLI/Install/InstallCommand.swift index d6da225e..2a46ecc8 100644 --- a/Sources/XcodeMCPProxyKit/Internal/CLI/Install/ProxyInstallCommand.swift +++ b/Sources/XcodeMCPServerKit/Internal/CLI/Install/InstallCommand.swift @@ -1,13 +1,13 @@ import ArgumentParser -package struct ProxyInstallCommand: ParsableCommand { +package struct InstallCommand: ParsableCommand { package init() {} package static var configuration: CommandConfiguration { CommandConfiguration( - commandName: "xcode-mcp-proxy-install", - abstract: "Install the Xcode MCP proxy executables.", - version: XcodeMCPProxyServer.productMetadata.version + commandName: "xcode-mcp-install", + abstract: "Install the Xcode MCP server executables.", + version: XcodeMCPServer.productMetadata.version ) } diff --git a/Sources/XcodeMCPProxyKit/Internal/CLI/Server/ProxyServerCommand.swift b/Sources/XcodeMCPServerKit/Internal/CLI/Server/ServerCommand.swift similarity index 90% rename from Sources/XcodeMCPProxyKit/Internal/CLI/Server/ProxyServerCommand.swift rename to Sources/XcodeMCPServerKit/Internal/CLI/Server/ServerCommand.swift index 8bc7a391..1e292255 100644 --- a/Sources/XcodeMCPProxyKit/Internal/CLI/Server/ProxyServerCommand.swift +++ b/Sources/XcodeMCPServerKit/Internal/CLI/Server/ServerCommand.swift @@ -1,18 +1,18 @@ import ArgumentParser import Foundation -package struct ProxyServerCommand: ParsableCommand { +package struct ServerCommand: ParsableCommand { package init() {} package static var configuration: CommandConfiguration { CommandConfiguration( - commandName: "xcode-mcp-proxy-server", - abstract: "Start the Streamable HTTP proxy server for Xcode MCP.", + commandName: "xcode-mcp-server", + abstract: "Start the Streamable HTTP server for Xcode MCP.", discussion: """ The server locates its native helper and selected Xcode installation automatically. MCP clients connect to its Streamable HTTP endpoint. """, - version: XcodeMCPProxyServer.productMetadata.version + version: XcodeMCPServer.productMetadata.version ) } @@ -49,7 +49,7 @@ package struct ProxyServerCommand: ParsableCommand { @Flag(help: "Serve /debug/hosts and /debug/reset on a loopback listener.") var debugEndpoints = false - @Flag(help: "Terminate an existing proxy server on the listen port before starting.") + @Flag(help: "Terminate an existing server on the listen port before starting.") var forceRestart = false @Flag(help: "Print the resolved server command without starting it.") diff --git a/Sources/XcodeMCPProxyKit/Internal/Install/ProxyProductBuilder.swift b/Sources/XcodeMCPServerKit/Internal/Install/ServerProductBuilder.swift similarity index 98% rename from Sources/XcodeMCPProxyKit/Internal/Install/ProxyProductBuilder.swift rename to Sources/XcodeMCPServerKit/Internal/Install/ServerProductBuilder.swift index 7a42bc2b..b70a6573 100644 --- a/Sources/XcodeMCPProxyKit/Internal/Install/ProxyProductBuilder.swift +++ b/Sources/XcodeMCPServerKit/Internal/Install/ServerProductBuilder.swift @@ -1,6 +1,6 @@ import Foundation -enum ProxyProductBuilder { +enum ServerProductBuilder { enum Error: Swift.Error, CustomStringConvertible, Equatable { case buildFailed case nativeHostBuildFailed(Int32) diff --git a/Sources/XcodeMCPProxyKit/Internal/Process/ExistingProxyServerProcessController.swift b/Sources/XcodeMCPServerKit/Internal/Process/ExistingServerProcessController.swift similarity index 86% rename from Sources/XcodeMCPProxyKit/Internal/Process/ExistingProxyServerProcessController.swift rename to Sources/XcodeMCPServerKit/Internal/Process/ExistingServerProcessController.swift index 95325289..993bf0a3 100644 --- a/Sources/XcodeMCPProxyKit/Internal/Process/ExistingProxyServerProcessController.swift +++ b/Sources/XcodeMCPServerKit/Internal/Process/ExistingServerProcessController.swift @@ -1,7 +1,7 @@ import XcodeMCPCore import Foundation -struct ExistingProxyServerProcessController: DependencyClient { +struct ExistingServerProcessController: DependencyClient { var terminateExistingServer: @Sendable (_ host: String, _ port: Int, _ emitWarning: (String) -> Void) -> Bool var detectExistingServerProcessIDs: @Sendable (_ host: String, _ port: Int) -> [Int] @@ -34,7 +34,7 @@ struct ExistingProxyServerProcessController: DependencyClient { ) -> Self { Self( terminateExistingServer: { host, port, emitWarning in - terminateExistingProxyServerIfNeeded( + terminateExistingServerIfNeeded( host: host, port: port, emitWarning: emitWarning, @@ -53,7 +53,7 @@ struct ExistingProxyServerProcessController: DependencyClient { ) } - private static func terminateExistingProxyServerIfNeeded( + private static func terminateExistingServerIfNeeded( host: String, port: Int, emitWarning: (String) -> Void, @@ -67,7 +67,7 @@ struct ExistingProxyServerProcessController: DependencyClient { let currentPID = currentProcessID() var didTerminate = false for processID in processIDs where processID != currentPID { - guard isProxyServerProcess(pid: processID, processControl: processControl) else { continue } + guard isServerProcess(pid: processID, processControl: processControl) else { continue } emitWarning(terminationWarning(port: port, pid: processID)) if processControl.terminate(processID: processID, clock: clock) { didTerminate = true @@ -91,18 +91,18 @@ struct ExistingProxyServerProcessController: DependencyClient { ) -> [Int] { // A cached discovery PID can be reused by a process serving a different endpoint. processControl.listeningProcessIDs(onTCPPort: port, matchingHost: host).filter { - isProxyServerProcess(pid: $0, processControl: processControl) + isServerProcess(pid: $0, processControl: processControl) } } private static func terminationWarning(port: Int, pid: Int) -> String { - "warning: port \(port) is already in use by xcode-mcp-proxy-server (pid: \(pid)); terminating it." + "warning: port \(port) is already in use by xcode-mcp-server (pid: \(pid)); terminating it." } - private static func isProxyServerProcess( + private static func isServerProcess( pid: Int, processControl: ProcessControlClient ) -> Bool { - processControl.executableName(processID: pid) == "xcode-mcp-proxy-server" + processControl.executableName(processID: pid) == "xcode-mcp-server" } } diff --git a/Sources/XcodeMCPProxyKit/Internal/Process/ProcessControlClient.swift b/Sources/XcodeMCPServerKit/Internal/Process/ProcessControlClient.swift similarity index 100% rename from Sources/XcodeMCPProxyKit/Internal/Process/ProcessControlClient.swift rename to Sources/XcodeMCPServerKit/Internal/Process/ProcessControlClient.swift diff --git a/Sources/XcodeMCPProxyKit/Internal/Support/DiscoveryClient.swift b/Sources/XcodeMCPServerKit/Internal/Support/DiscoveryClient.swift similarity index 98% rename from Sources/XcodeMCPProxyKit/Internal/Support/DiscoveryClient.swift rename to Sources/XcodeMCPServerKit/Internal/Support/DiscoveryClient.swift index 5071e8b6..ef8bf01b 100644 --- a/Sources/XcodeMCPProxyKit/Internal/Support/DiscoveryClient.swift +++ b/Sources/XcodeMCPServerKit/Internal/Support/DiscoveryClient.swift @@ -25,7 +25,7 @@ struct DiscoveryClient: DependencyClient { static let testValue = Self( defaultFileURL: { - URL(fileURLWithPath: "/tmp/XcodeMCPProxy/endpoint.json") + URL(fileURLWithPath: "/tmp/XcodeMCPServer/endpoint.json") }, read: { _ in nil }, write: { _, _ in }, diff --git a/Sources/XcodeMCPProxyKit/README.md b/Sources/XcodeMCPServerKit/README.md similarity index 86% rename from Sources/XcodeMCPProxyKit/README.md rename to Sources/XcodeMCPServerKit/README.md index 4afbeda1..444ae5d9 100644 --- a/Sources/XcodeMCPProxyKit/README.md +++ b/Sources/XcodeMCPServerKit/README.md @@ -1,11 +1,11 @@ -# XcodeMCPProxyKit +# XcodeMCPServerKit -Swift API for embedding the Xcode MCP proxy server. +Swift API for embedding the Xcode MCP server. Use the bundled executables when a library host is unnecessary: -- `xcode-mcp-proxy-server` runs the HTTP proxy. -- `xcode-mcp-proxy-install` installs the server and the signed native app. Installer internals are +- `xcode-mcp-server` runs the HTTP server. +- `xcode-mcp-install` installs the server and the signed native app. Installer internals are not a public library API. ## Server @@ -13,9 +13,9 @@ Use the bundled executables when a library host is unnecessary: Construct one server, start it once, and shut it down explicitly: ```swift -import XcodeMCPProxyKit +import XcodeMCPServerKit -let server = XcodeMCPProxyServer( +let server = XcodeMCPServer( configuration: .init( bindAddress: .localhost(port: 0), discovery: .defaultLocation @@ -42,13 +42,13 @@ and event-loop resources have stopped. A server instance is one-shot; construct a new instance after shutdown. Concurrent and repeated `shutdown()` calls return the same shutdown result. -If startup and its cleanup both fail, `XcodeMCPProxyServer.CleanupError` retains +If startup and its cleanup both fail, `XcodeMCPServer.CleanupError` retains both errors and any bound endpoint. A cleanup failure means resource release may be incomplete, even though the server lifecycle has stopped. ### Server configuration -`XcodeMCPProxyServerConfiguration` exposes the supported embedding choices: +`XcodeMCPServerConfiguration` exposes the supported embedding choices: - `bindAddress`: host and port; port `0` requests an ephemeral port. - `nativeHostBundleURL`: signed native helper app bundle, or `nil` for automatic lookup. @@ -67,7 +67,7 @@ another installation is requested. Workspace and device-session handles retain their native context without a client-side host switch. See [workspace usage](../../Docs/usage.md) for the tool contract. -Install `XcodeMCPNativeHost.app` beside the proxy executable, or supply its bundle +Install `XcodeMCPNativeHost.app` beside the server executable, or supply its bundle URL. Missing helpers or required native contracts return diagnostics. The helper owns its AppKit event loop. Workspace operations run independently of GUI Xcode and its MCP connection approval. With `.automatic` approval, a separate monitor @@ -75,7 +75,7 @@ presses `Allow` on GUI Xcode MCP connection dialogs for other agents until serve shutdown. It does not change tool routing or directly rewrite Xcode's agent permission store. -Inherited `MCP_XCODE_PID` and `MCP_XCODE_SESSION_ID` do not select a proxy backend. +Inherited `MCP_XCODE_PID` and `MCP_XCODE_SESSION_ID` do not select a server backend. For a standalone headless or generic MCP process, use `XcodeMCPKit`'s explicit `.nativeHost(...)` or `.process(...)` transport. See [native routing migration](../../Docs/migrations/native-backend.md). @@ -90,7 +90,7 @@ entry per owned headless host with its identifier, kind, state, and active request count. It does not expose traffic payloads, tool arguments, or stderr. -`XcodeMCPProxyServer.run(...)` handles `SIGINT` and `SIGTERM` while the server +`XcodeMCPServer.run(...)` handles `SIGINT` and `SIGTERM` while the server runs: the first signal shuts the server down, stopping every host process, and a second one terminates the process immediately. @@ -100,7 +100,7 @@ Swift hosts that need executable-compatible argument parsing can use the public `run(...)` facade without depending on parser or launch-plan types: ```swift -let exitCode = await XcodeMCPProxyServer.run( +let exitCode = await XcodeMCPServer.run( arguments: CommandLine.arguments, environment: ProcessInfo.processInfo.environment, stdout: { print($0) }, @@ -111,8 +111,8 @@ let exitCode = await XcodeMCPProxyServer.run( The installer is command-only and stages the signed helper beside the server binary: ```bash -xcode-mcp-proxy-install -xcode-mcp-proxy-install --dry-run +xcode-mcp-install +xcode-mcp-install --dry-run ``` See the [migration guide](../../Docs/migrations/native-backend.md) for removed diff --git a/Sources/XcodeMCPProxyKit/XcodeMCPProxyConsole.swift b/Sources/XcodeMCPServerKit/XcodeMCPConsole.swift similarity index 81% rename from Sources/XcodeMCPProxyKit/XcodeMCPProxyConsole.swift rename to Sources/XcodeMCPServerKit/XcodeMCPConsole.swift index 49401ef7..89317dad 100644 --- a/Sources/XcodeMCPProxyKit/XcodeMCPProxyConsole.swift +++ b/Sources/XcodeMCPServerKit/XcodeMCPConsole.swift @@ -1,6 +1,6 @@ import Foundation -package enum XcodeMCPProxyConsole { +package enum XcodeMCPConsole { package static func writeStandardErrorLine(_ text: String) { FileHandle.standardError.write(Data((text + "\n").utf8)) } diff --git a/Sources/XcodeMCPProxyKit/XcodeMCPProxyInstaller.swift b/Sources/XcodeMCPServerKit/XcodeMCPInstaller.swift similarity index 90% rename from Sources/XcodeMCPProxyKit/XcodeMCPProxyInstaller.swift rename to Sources/XcodeMCPServerKit/XcodeMCPInstaller.swift index 7e175bc4..188551b7 100644 --- a/Sources/XcodeMCPProxyKit/XcodeMCPProxyInstaller.swift +++ b/Sources/XcodeMCPServerKit/XcodeMCPInstaller.swift @@ -3,7 +3,7 @@ import Foundation import XcodeMCPCore /// Destination and mode settings for a source install. -package struct XcodeMCPProxyInstallerConfiguration: Equatable, Sendable { +package struct XcodeMCPInstallerConfiguration: Equatable, Sendable { /// Install prefix used when ``binaryDirectory`` is not set. package var prefix: String? @@ -25,15 +25,15 @@ package struct XcodeMCPProxyInstallerConfiguration: Equatable, Sendable { } } -/// Installer facade for Xcode MCP proxy executables. -package struct XcodeMCPProxyInstaller: Sendable { +/// Installer facade for Xcode MCP server executables. +package struct XcodeMCPInstaller: Sendable { /// Top-level action for an installer invocation. package enum LaunchAction: Equatable, Sendable { case display(String) - case install(XcodeMCPProxyInstallerConfiguration) + case install(XcodeMCPInstallerConfiguration) } - /// One proxy executable that will be copied by an install plan. + /// One server executable that will be copied by an install plan. package struct Binary: Equatable, Sendable { /// Executable file name. package let name: String @@ -105,37 +105,37 @@ package struct XcodeMCPProxyInstaller: Sendable { /// Executable product names installed by the source installer. package static let binaryNames = [ - "xcode-mcp-proxy-server", + "xcode-mcp-server", ] package static let nativeHostBundleName = NativeHostInvocation.bundleName /// Installer configuration. - package var configuration: XcodeMCPProxyInstallerConfiguration + package var configuration: XcodeMCPInstallerConfiguration /// Creates an installer facade. package init( - configuration: XcodeMCPProxyInstallerConfiguration = - XcodeMCPProxyInstallerConfiguration() + configuration: XcodeMCPInstallerConfiguration = + XcodeMCPInstallerConfiguration() ) { self.configuration = configuration } - /// CLI usage for `xcode-mcp-proxy-install`. + /// CLI usage for `xcode-mcp-install`. package static var installUsage: String { - ProxyInstallCommand.helpMessage() + InstallCommand.helpMessage() } package static func resolveLaunchAction( arguments: [String], environment: [String: String] ) throws -> LaunchAction { - switch try CLICommandParser.parse(ProxyInstallCommand.self, arguments: arguments) { + switch try CLICommandParser.parse(InstallCommand.self, arguments: arguments) { case .cleanExit(let message): return .display(message) case .command(let command): return .install( - XcodeMCPProxyInstallerConfiguration( + XcodeMCPInstallerConfiguration( prefix: command.prefix ?? environment["PREFIX"], binaryDirectory: command.bindir ?? environment["BINDIR"], dryRun: command.dryRun @@ -172,9 +172,9 @@ package struct XcodeMCPProxyInstaller: Sendable { ) } - /// Builds release products when needed and installs the proxy executables. + /// Builds release products when needed and installs the server executables. /// - /// When ``XcodeMCPProxyInstallerConfiguration/dryRun`` is true this method + /// When ``XcodeMCPInstallerConfiguration/dryRun`` is true this method /// prints the dry-run plan and does not create directories or copy files. package func install( executableURL: URL, @@ -314,8 +314,8 @@ package struct XcodeMCPProxyInstaller: Sendable { package static func buildProducts(_ products: [String], in directory: URL, nativeHostBundleURL: URL) throws { do { - try ProxyProductBuilder.buildReleaseProducts(products, in: directory, nativeHostBundleURL: nativeHostBundleURL) - } catch let error as ProxyProductBuilder.Error { + try ServerProductBuilder.buildReleaseProducts(products, in: directory, nativeHostBundleURL: nativeHostBundleURL) + } catch let error as ServerProductBuilder.Error { throw Error.message(error.description) } } @@ -342,17 +342,17 @@ package struct XcodeMCPProxyInstaller: Sendable { } -extension XcodeMCPProxyInstaller { +extension XcodeMCPInstaller { package struct Launcher { package struct Dependencies { package var executableURL: () -> URL? - package var install: (XcodeMCPProxyInstallerConfiguration, URL, (String) -> Void) throws -> Void + package var install: (XcodeMCPInstallerConfiguration, URL, (String) -> Void) throws -> Void package init( executableURL: @escaping () -> URL?, install: @escaping ( - XcodeMCPProxyInstallerConfiguration, + XcodeMCPInstallerConfiguration, URL, (String) -> Void ) throws -> Void @@ -365,7 +365,7 @@ extension XcodeMCPProxyInstaller { Self( executableURL: { Bundle.main.executableURL }, install: { configuration, executableURL, stdout in - try XcodeMCPProxyInstaller(configuration: configuration).install( + try XcodeMCPInstaller(configuration: configuration).install( executableURL: executableURL, stdout: stdout ) @@ -387,7 +387,7 @@ extension XcodeMCPProxyInstaller { stderr: (String) -> Void ) -> Int32 { do { - let action = try XcodeMCPProxyInstaller.resolveLaunchAction( + let action = try XcodeMCPInstaller.resolveLaunchAction( arguments: arguments, environment: environment ) @@ -398,7 +398,7 @@ extension XcodeMCPProxyInstaller { return 0 case .install(let configuration): guard let executableURL = dependencies.executableURL() else { - throw XcodeMCPProxyInstaller.Error.message( + throw XcodeMCPInstaller.Error.message( "failed to locate installer executable" ) } @@ -408,7 +408,7 @@ extension XcodeMCPProxyInstaller { } catch let error as CLICommandError { stderr(error.description) return error.exitCode - } catch let error as XcodeMCPProxyInstaller.Error { + } catch let error as XcodeMCPInstaller.Error { stderr("error: \(error.description)") stderr("run with --help for usage") return 1 diff --git a/Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+Launch.swift b/Sources/XcodeMCPServerKit/XcodeMCPServer+Launch.swift similarity index 81% rename from Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+Launch.swift rename to Sources/XcodeMCPServerKit/XcodeMCPServer+Launch.swift index 38e9e774..2f1e4253 100644 --- a/Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+Launch.swift +++ b/Sources/XcodeMCPServerKit/XcodeMCPServer+Launch.swift @@ -1,38 +1,38 @@ import Foundation import XcodeMCPCore -import XcodeMCPProxyRuntime +import XcodeMCPServerRuntime -package struct XcodeMCPProxyProductMetadata: Equatable, Sendable { +package struct XcodeMCPProductMetadata: Equatable, Sendable { package let name: String package let version: String - package init(name: String = "XcodeMCPProxyKit", version: String) { + package init(name: String = "XcodeMCPServerKit", version: String) { self.name = name self.version = version } } -extension XcodeMCPProxyServer { +extension XcodeMCPServer { package enum LaunchAction: Sendable { case display(String) case dryRun(String) - case start(configuration: XcodeMCPProxyServerConfiguration, forceRestart: Bool) + case start(configuration: XcodeMCPServerConfiguration, forceRestart: Bool) } - package static var productMetadata: XcodeMCPProxyProductMetadata { - XcodeMCPProxyProductMetadata(version: ProxyBuildGeneratedInfo.version) + package static var productMetadata: XcodeMCPProductMetadata { + XcodeMCPProductMetadata(version: ServerBuildGeneratedInfo.version) } package static var serverUsage: String { - ProxyServerCommand.helpMessage() + ServerCommand.helpMessage() } package static func resolveLaunchAction( arguments: [String], environment: [String: String] ) throws -> LaunchAction { - let command: ProxyServerCommand - switch try CLICommandParser.parse(ProxyServerCommand.self, arguments: arguments) { + let command: ServerCommand + switch try CLICommandParser.parse(ServerCommand.self, arguments: arguments) { case .cleanExit(let message): return .display(message) case .command(let parsedCommand): @@ -51,14 +51,14 @@ extension XcodeMCPProxyServer { } package static func bootstrapLogging(environment: [String: String]) { - ProxyLogging.bootstrap(environment: environment) + ServerLogging.bootstrap(environment: environment) } } -private extension ProxyServerCommand { - func resolveConfiguration(environment: [String: String]) throws -> XcodeMCPProxyServerConfiguration { +private extension ServerCommand { + func resolveConfiguration(environment: [String: String]) throws -> XcodeMCPServerConfiguration { let listenAddress = try resolvedListenAddress(environment: environment) - return XcodeMCPProxyServerConfiguration( + return XcodeMCPServerConfiguration( bindAddress: .init(host: listenAddress.host, port: listenAddress.port), nativeHostBundleURL: environment["XCODE_MCP_NATIVE_HOST_BUNDLE"].map { URL(fileURLWithPath: $0) }, developerDirectoryURL: environment["DEVELOPER_DIR"].flatMap { value in @@ -67,7 +67,7 @@ private extension ProxyServerCommand { sharesCompilationCache: shareCompilationCache, maxBodyBytes: maxBodyBytes ?? 1_048_576, requestTimeout: requestTimeout.map { $0.duration } - ?? XcodeMCPProxyServerConfiguration().requestTimeout, + ?? XcodeMCPServerConfiguration().requestTimeout, discovery: .file(Discovery.defaultFileURL(environment: environment)), approvalPolicy: autoApprove ? .automatic : .manual, enablesDebugEndpoints: debugEndpoints @@ -84,7 +84,7 @@ private extension ProxyServerCommand { if let value = nonEmpty(environment["LISTEN"]) { guard let address = CLIListenAddress(argument: value) else { throw CLICommandParser.validationError( - for: ProxyServerCommand.self, + for: ServerCommand.self, message: "LISTEN must be a host:port value with a port in 0...65535" ) } @@ -96,7 +96,7 @@ private extension ProxyServerCommand { if let value = nonEmpty(environment["PORT"]) { guard let port = Int(value), (0...65_535).contains(port) else { throw CLICommandParser.validationError( - for: ProxyServerCommand.self, + for: ServerCommand.self, message: "PORT must be an integer in 0...65535" ) } @@ -107,9 +107,9 @@ private extension ProxyServerCommand { return CLIListenAddress(host: environmentHost, port: environmentPort) } - func renderResolvedCommand(configuration: XcodeMCPProxyServerConfiguration) -> String { + func renderResolvedCommand(configuration: XcodeMCPServerConfiguration) -> String { var arguments = [ - "xcode-mcp-proxy-server", + "xcode-mcp-server", "--listen", "\(configuration.bindAddress.host):\(configuration.bindAddress.port)", ] diff --git a/Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+Launcher.swift b/Sources/XcodeMCPServerKit/XcodeMCPServer+Launcher.swift similarity index 91% rename from Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+Launcher.swift rename to Sources/XcodeMCPServerKit/XcodeMCPServer+Launcher.swift index d9ee613f..f4b6dbff 100644 --- a/Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+Launcher.swift +++ b/Sources/XcodeMCPServerKit/XcodeMCPServer+Launcher.swift @@ -3,16 +3,16 @@ import Dispatch import Foundation import Synchronization -extension XcodeMCPProxyServer { +extension XcodeMCPServer { package protocol LaunchServer: Sendable { - func start() async throws -> XcodeMCPProxyServer.Endpoint + func start() async throws -> XcodeMCPServer.Endpoint func waitUntilShutdown() async throws func shutdown() async throws } package struct Launcher { package struct Dependencies { - package var makeServer: (XcodeMCPProxyServerConfiguration) -> any LaunchServer + package var makeServer: (XcodeMCPServerConfiguration) -> any LaunchServer package var isAddressAlreadyInUse: (Swift.Error) -> Bool package var forceRestartExistingServer: (_ host: String, _ port: Int, _ stderr: (String) -> Void) -> Bool package var detectExistingServerProcessIDs: (_ host: String, _ port: Int) -> [Int] @@ -21,7 +21,7 @@ extension XcodeMCPProxyServer { package var observeTerminationSignals: (_ handler: @escaping @Sendable () -> Void) -> () -> Void package init( - makeServer: @escaping (XcodeMCPProxyServerConfiguration) -> any LaunchServer, + makeServer: @escaping (XcodeMCPServerConfiguration) -> any LaunchServer, isAddressAlreadyInUse: @escaping (Swift.Error) -> Bool, forceRestartExistingServer: @escaping ( @@ -40,12 +40,12 @@ extension XcodeMCPProxyServer { } package static var live: Self { - let existingServerController = ExistingProxyServerProcessController.liveValue + let existingServerController = ExistingServerProcessController.liveValue return Self( makeServer: { configuration in - XcodeMCPProxyServer(configuration: configuration) + XcodeMCPServer(configuration: configuration) }, - isAddressAlreadyInUse: XcodeMCPProxyServer.isAddressAlreadyInUse, + isAddressAlreadyInUse: XcodeMCPServer.isAddressAlreadyInUse, forceRestartExistingServer: { host, port, stderr in existingServerController.terminateExistingServer(host, port, stderr) }, @@ -70,7 +70,7 @@ extension XcodeMCPProxyServer { stderr: (String) -> Void ) async -> Int32 { do { - let action = try XcodeMCPProxyServer.resolveLaunchAction( + let action = try XcodeMCPServer.resolveLaunchAction( arguments: arguments, environment: environment ) @@ -99,7 +99,7 @@ extension XcodeMCPProxyServer { } private func startServer( - configuration: XcodeMCPProxyServerConfiguration, + configuration: XcodeMCPServerConfiguration, forceRestart: Bool, stderr: (String) -> Void ) async throws -> Int32 { @@ -131,7 +131,7 @@ extension XcodeMCPProxyServer { } if !(error is CleanupError), configuration.bindAddress.port > 0, dependencies.isAddressAlreadyInUse(error) { - let diagnostic = XcodeMCPProxyServer.PortInUseError( + let diagnostic = XcodeMCPServer.PortInUseError( host: configuration.bindAddress.host, port: configuration.bindAddress.port, processIdentifiers: dependencies.detectExistingServerProcessIDs( @@ -166,7 +166,7 @@ extension XcodeMCPProxyServer { } } -extension XcodeMCPProxyServer: XcodeMCPProxyServer.LaunchServer {} +extension XcodeMCPServer: XcodeMCPServer.LaunchServer {} /// Delivers `SIGINT` and `SIGTERM` to handlers instead of terminating the process. Observers in one /// process share the dispositions, which are replaced while any observer is registered. diff --git a/Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+PermissionAutomation.swift b/Sources/XcodeMCPServerKit/XcodeMCPServer+PermissionAutomation.swift similarity index 67% rename from Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+PermissionAutomation.swift rename to Sources/XcodeMCPServerKit/XcodeMCPServer+PermissionAutomation.swift index 57198c86..9953f20c 100644 --- a/Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+PermissionAutomation.swift +++ b/Sources/XcodeMCPServerKit/XcodeMCPServer+PermissionAutomation.swift @@ -1,16 +1,16 @@ import Logging import XcodeMCPPermissionAutomation -import XcodeMCPProxyRuntime +import XcodeMCPServerRuntime -protocol ProxyServerPermissionDialogAutoApprover: Sendable { +protocol ServerPermissionDialogAutoApprover: Sendable { func start() func cancel() func shutdown() async } -extension XcodePermissionDialogAutomation.AutoApprover: ProxyServerPermissionDialogAutoApprover { +extension XcodePermissionDialogAutomation.AutoApprover: ServerPermissionDialogAutoApprover { static func liveForAllAgents() -> Self { - let names: Set = ["XcodeMCPKit", "XcodeMCPProxyKit"] + let names: Set = ["XcodeMCPKit", "XcodeMCPServerKit"] return Self( configuration: .init( permissionDialogProcessIDs: { @@ -21,7 +21,7 @@ extension XcodePermissionDialogAutomation.AutoApprover: ProxyServerPermissionDia agentProcessIDCandidates: { descendantProcessIDCandidates() }, agentScope: .allAgents ), - logger: ProxyLogging.make("xcode.permission") + logger: ServerLogging.make("xcode.permission") ) } } diff --git a/Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+PortDiagnostics.swift b/Sources/XcodeMCPServerKit/XcodeMCPServer+PortDiagnostics.swift similarity index 77% rename from Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+PortDiagnostics.swift rename to Sources/XcodeMCPServerKit/XcodeMCPServer+PortDiagnostics.swift index 7c517ee0..a58a910b 100644 --- a/Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+PortDiagnostics.swift +++ b/Sources/XcodeMCPServerKit/XcodeMCPServer+PortDiagnostics.swift @@ -1,7 +1,7 @@ import Darwin import Foundation -extension XcodeMCPProxyServer { +extension XcodeMCPServer { package struct PortInUseError: Error, CustomStringConvertible, Equatable, Sendable { /// Requested listen host. package let host: String @@ -9,7 +9,7 @@ extension XcodeMCPProxyServer { /// Requested listen port. package let port: Int - /// Detected `xcode-mcp-proxy-server` process identifiers. + /// Detected `xcode-mcp-server` process identifiers. package let processIdentifiers: [Int] /// Creates a port-in-use diagnostic. @@ -32,19 +32,19 @@ extension XcodeMCPProxyServer { lines.reserveCapacity(8) lines.append("error: listen \(displayHost):\(port) is already in use (Address already in use).") if processIdentifiers.count == 1 { - lines.append("Detected a running xcode-mcp-proxy-server (pid: \(processIdentifiers[0])).") + lines.append("Detected a running xcode-mcp-server (pid: \(processIdentifiers[0])).") } else if processIdentifiers.count > 1 { let formatted = processIdentifiers.map(String.init).joined(separator: ", ") - lines.append("Detected running xcode-mcp-proxy-server processes (pids: \(formatted)).") + lines.append("Detected running xcode-mcp-server processes (pids: \(formatted)).") } lines.append("Terminate the existing process and try again.") lines.append( - "To force a restart, rerun with `--force-restart`; this will terminate the existing xcode-mcp-proxy-server and start a new one." + "To force a restart, rerun with `--force-restart`; this will terminate the existing xcode-mcp-server and start a new one." ) lines.append("") lines.append("Examples:") - lines.append(" pkill -x xcode-mcp-proxy-server") - lines.append(" xcode-mcp-proxy-server --force-restart") + lines.append(" pkill -x xcode-mcp-server") + lines.append(" xcode-mcp-server --force-restart") return lines.joined(separator: "\n") } } diff --git a/Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+Startup.swift b/Sources/XcodeMCPServerKit/XcodeMCPServer+Startup.swift similarity index 91% rename from Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+Startup.swift rename to Sources/XcodeMCPServerKit/XcodeMCPServer+Startup.swift index b17143eb..dd9f46c2 100644 --- a/Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+Startup.swift +++ b/Sources/XcodeMCPServerKit/XcodeMCPServer+Startup.swift @@ -1,10 +1,10 @@ -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract import Foundation import Logging -import XcodeMCPProxyHTTP -import XcodeMCPProxyRuntime +import XcodeMCPServerHTTP +import XcodeMCPServerRuntime -extension XcodeMCPProxyServer { +extension XcodeMCPServer { actor Lifecycle { private enum Phase { case idle @@ -15,16 +15,16 @@ extension XcodeMCPProxyServer { } private final class Resources: @unchecked Sendable { - let httpGateway: any ProxyHTTPGatewayServing - let runtime: any ProxyRuntimeServing + let httpGateway: any ServerHTTPGatewayServing + let runtime: any ServerRuntimeServing let endpoint: Endpoint - let autoApprover: (any ProxyServerPermissionDialogAutoApprover)? + let autoApprover: (any ServerPermissionDialogAutoApprover)? init( - httpGateway: any ProxyHTTPGatewayServing, - runtime: any ProxyRuntimeServing, + httpGateway: any ServerHTTPGatewayServing, + runtime: any ServerRuntimeServing, endpoint: Endpoint, - autoApprover: (any ProxyServerPermissionDialogAutoApprover)? + autoApprover: (any ServerPermissionDialogAutoApprover)? ) { self.httpGateway = httpGateway self.runtime = runtime @@ -39,7 +39,7 @@ extension XcodeMCPProxyServer { } } - private let configuration: XcodeMCPProxyServerConfiguration + private let configuration: XcodeMCPServerConfiguration private let dependencies: Dependencies private let logger: Logger private var phase: Phase = .idle @@ -51,7 +51,7 @@ extension XcodeMCPProxyServer { private var shutdownRequested = false init( - configuration: XcodeMCPProxyServerConfiguration, + configuration: XcodeMCPServerConfiguration, dependencies: Dependencies, logger: Logger ) { @@ -69,7 +69,7 @@ extension XcodeMCPProxyServer { } phase = .starting - let runtimeConfiguration: ProxyRuntimeConfiguration + let runtimeConfiguration: ServerRuntimeConfiguration do { runtimeConfiguration = try configuration.runtimeConfiguration() } catch { @@ -233,7 +233,7 @@ extension XcodeMCPProxyServer { configuration.listenHost == "localhost" ? "localhost" : resources.endpoint.host - let summary = XcodeMCPProxyServer.startupSummary( + let summary = XcodeMCPServer.startupSummary( displayHost: displayHost, port: resources.endpoint.port ) @@ -247,14 +247,14 @@ extension XcodeMCPProxyServer { } private static func acquire( - configuration: XcodeMCPProxyServerConfiguration, - runtimeConfiguration: ProxyRuntimeConfiguration, + configuration: XcodeMCPServerConfiguration, + runtimeConfiguration: ServerRuntimeConfiguration, dependencies: Dependencies, logger: Logger ) async throws -> Resources { let runtime = try dependencies.makeRuntime(runtimeConfiguration) let httpGateway = dependencies.makeHTTPGateway( - ProxyHTTPConfiguration( + ServerHTTPConfiguration( listenHost: configuration.listenHost, listenPort: configuration.listenPort, maxBodyBytes: configuration.maxBodyBytes, @@ -307,7 +307,7 @@ extension XcodeMCPProxyServer { } private static func writeDiscovery( - _ policy: XcodeMCPProxyServerConfiguration.Discovery, + _ policy: XcodeMCPServerConfiguration.Discovery, resolvedHost: String, port: Int, configuredHost: String, @@ -362,7 +362,7 @@ extension XcodeMCPProxyServer { } } - private static func publicHost(_ host: ProxyRuntimeSnapshot.Host) -> Status.Host { + private static func publicHost(_ host: ServerRuntimeSnapshot.Host) -> Status.Host { let state: Status.Host.State = switch host.state { case .stopped: .stopped case .starting: .starting diff --git a/Sources/XcodeMCPProxyKit/XcodeMCPProxyServer.swift b/Sources/XcodeMCPServerKit/XcodeMCPServer.swift similarity index 84% rename from Sources/XcodeMCPProxyKit/XcodeMCPProxyServer.swift rename to Sources/XcodeMCPServerKit/XcodeMCPServer.swift index 7930d0d7..beae6c7d 100644 --- a/Sources/XcodeMCPProxyKit/XcodeMCPProxyServer.swift +++ b/Sources/XcodeMCPServerKit/XcodeMCPServer.swift @@ -1,17 +1,17 @@ -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract import XcodeMCPCore import Foundation import Logging -import XcodeMCPProxyHTTP -import XcodeMCPProxyRuntime +import XcodeMCPServerHTTP +import XcodeMCPServerRuntime import XcodeMCPPermissionAutomation -/// Public configuration for an embedded Xcode MCP proxy server. +/// Public configuration for an embedded Xcode MCP server. /// /// This type is the stable server configuration surface for -/// `XcodeMCPProxyKit`. Lower-level parser, discovery, filesystem, and +/// `XcodeMCPServerKit`. Lower-level parser, discovery, filesystem, and /// session-routing types stay internal to the targets that own them. -public struct XcodeMCPProxyServerConfiguration: Equatable, Sendable { +public struct XcodeMCPServerConfiguration: Equatable, Sendable { /// Address that the Streamable HTTP server binds. public struct BindAddress: Equatable, Sendable { /// Hostname or IP address for the server socket. @@ -52,7 +52,7 @@ public struct XcodeMCPProxyServerConfiguration: Equatable, Sendable { case manual /// Automatically approve Xcode MCP connection dialogs for all agents, - /// including clients connecting to Xcode outside this proxy. + /// including clients connecting to Xcode outside this server. /// /// Requires macOS Accessibility permission for the server process. case automatic @@ -90,7 +90,7 @@ public struct XcodeMCPProxyServerConfiguration: Equatable, Sendable { /// listener. Defaults to `false`. public var enablesDebugEndpoints: Bool - /// Creates a public proxy server configuration. + /// Creates a public server configuration. /// /// - Parameters: /// - bindAddress: HTTP bind address. @@ -132,19 +132,19 @@ public struct XcodeMCPProxyServerConfiguration: Equatable, Sendable { var listenPort: Int { bindAddress.port } } -/// Embeddable Streamable HTTP proxy server for Xcode MCP. +/// Embeddable Streamable HTTP server for Xcode MCP. /// -/// `XcodeMCPProxyServer` is the library boundary used by the -/// `xcode-mcp-proxy-server` executable. Construct it with -/// ``XcodeMCPProxyServerConfiguration``, call ``start()``, then keep the process +/// `XcodeMCPServer` is the library boundary used by the +/// `xcode-mcp-server` executable. Construct it with +/// ``XcodeMCPServerConfiguration``, call ``start()``, then keep the process /// alive with ``waitUntilShutdown()`` until your /// application decides to call ``shutdown()``. Start returns the resolved /// endpoint. /// -/// The server exposes the proxy lifecycle. CLI parsing and internal session +/// The server exposes the server lifecycle. CLI parsing and internal session /// routing are intentionally handled outside this public type. -public final class XcodeMCPProxyServer: Sendable { - /// A resolved Streamable HTTP proxy endpoint. +public final class XcodeMCPServer: Sendable { + /// A resolved Streamable HTTP server endpoint. public struct Endpoint: Equatable, Sendable { /// Hostname or IP address clients should connect to. public let host: String @@ -183,14 +183,14 @@ public final class XcodeMCPProxyServer: Sendable { } } - /// Errors thrown while starting or stopping a proxy server instance. + /// Errors thrown while starting or stopping a server instance. public enum LifecycleError: Error, Equatable, Sendable { /// The configured listener could not bind to any requested address. case failedToBind /// The server instance has already been started. /// - /// Create a new ``XcodeMCPProxyServer`` instance after calling + /// Create a new ``XcodeMCPServer`` instance after calling /// ``shutdown()`` instead of starting the same instance again. case alreadyStarted @@ -293,30 +293,30 @@ public final class XcodeMCPProxyServer: Sendable { struct Dependencies: Sendable { var discoveryClient: DiscoveryClient var processID: @Sendable () -> Int - var makeRuntime: @Sendable (ProxyRuntimeConfiguration) throws -> any ProxyRuntimeServing - var makeAutoApprover: @Sendable () -> any ProxyServerPermissionDialogAutoApprover + var makeRuntime: @Sendable (ServerRuntimeConfiguration) throws -> any ServerRuntimeServing + var makeAutoApprover: @Sendable () -> any ServerPermissionDialogAutoApprover var makeHTTPGateway: @Sendable ( - ProxyHTTPConfiguration, - any ProxyRuntimeServing, + ServerHTTPConfiguration, + any ServerRuntimeServing, Logger - ) -> any ProxyHTTPGatewayServing + ) -> any ServerHTTPGatewayServing init( discoveryClient: DiscoveryClient = .liveValue, processID: @escaping @Sendable () -> Int = { Int(ProcessInfo.processInfo.processIdentifier) }, - makeRuntime: @escaping @Sendable (ProxyRuntimeConfiguration) throws -> any ProxyRuntimeServing, - makeAutoApprover: @escaping @Sendable () -> any ProxyServerPermissionDialogAutoApprover = { + makeRuntime: @escaping @Sendable (ServerRuntimeConfiguration) throws -> any ServerRuntimeServing, + makeAutoApprover: @escaping @Sendable () -> any ServerPermissionDialogAutoApprover = { XcodePermissionDialogAutomation.AutoApprover.liveForAllAgents() }, makeHTTPGateway: @escaping @Sendable ( - ProxyHTTPConfiguration, - any ProxyRuntimeServing, + ServerHTTPConfiguration, + any ServerRuntimeServing, Logger - ) -> any ProxyHTTPGatewayServing = { configuration, runtime, logger in - ProxyHTTPGateway( + ) -> any ServerHTTPGatewayServing = { configuration, runtime, logger in + ServerHTTPGateway( configuration: configuration, runtime: runtime, logger: logger @@ -347,16 +347,16 @@ public final class XcodeMCPProxyServer: Sendable { } } - let logger: Logger = ProxyLogging.make("server") + let logger: Logger = ServerLogging.make("server") let lifecycle: Lifecycle - /// Creates a proxy server with live runtime dependencies. + /// Creates a server with live runtime dependencies. /// /// - Parameter configuration: Public HTTP, native helper, discovery, and /// lifecycle settings. public init( - configuration: XcodeMCPProxyServerConfiguration = - XcodeMCPProxyServerConfiguration() + configuration: XcodeMCPServerConfiguration = + XcodeMCPServerConfiguration() ) { let dependencies = Dependencies.live self.lifecycle = Lifecycle( @@ -367,7 +367,7 @@ public final class XcodeMCPProxyServer: Sendable { } init( - configuration: XcodeMCPProxyServerConfiguration, + configuration: XcodeMCPServerConfiguration, dependencies: Dependencies ) { self.lifecycle = Lifecycle( @@ -392,7 +392,7 @@ public final class XcodeMCPProxyServer: Sendable { try await lifecycle.waitUntilShutdown() } - /// Shuts down the proxy server and its runtime resources. + /// Shuts down the server and its runtime resources. /// /// Shutdown closes listening and accepted channels, shuts down the /// native host, and terminates the event @@ -415,21 +415,21 @@ public final class XcodeMCPProxyServer: Sendable { } -extension XcodeMCPProxyServerConfiguration { - func runtimeConfiguration() throws -> ProxyRuntimeConfiguration { +extension XcodeMCPServerConfiguration { + func runtimeConfiguration() throws -> ServerRuntimeConfiguration { guard listenHost.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false else { - throw XcodeMCPProxyServer.LifecycleError.invalidConfiguration("bindAddress.host must not be empty") + throw XcodeMCPServer.LifecycleError.invalidConfiguration("bindAddress.host must not be empty") } guard (0...65_535).contains(listenPort) else { - throw XcodeMCPProxyServer.LifecycleError.invalidConfiguration("bindAddress.port must be in 0...65535") + throw XcodeMCPServer.LifecycleError.invalidConfiguration("bindAddress.port must be in 0...65535") } guard maxBodyBytes > 0 else { - throw XcodeMCPProxyServer.LifecycleError.invalidConfiguration("maxBodyBytes must be greater than zero") + throw XcodeMCPServer.LifecycleError.invalidConfiguration("maxBodyBytes must be greater than zero") } if let requestTimeout, requestTimeout <= .zero { - throw XcodeMCPProxyServer.LifecycleError.invalidConfiguration("requestTimeout must be positive; use nil to disable it") + throw XcodeMCPServer.LifecycleError.invalidConfiguration("requestTimeout must be positive; use nil to disable it") } - return ProxyRuntimeConfiguration( + return ServerRuntimeConfiguration( nativeHostBundleURL: nativeHostBundleURL, developerDirectoryURL: developerDirectoryURL, sharesCompilationCache: sharesCompilationCache, diff --git a/Sources/XcodeMCPProxyKit/XcodeMCPProxyRunners.swift b/Sources/XcodeMCPServerKit/XcodeMCPServerRunners.swift similarity index 93% rename from Sources/XcodeMCPProxyKit/XcodeMCPProxyRunners.swift rename to Sources/XcodeMCPServerKit/XcodeMCPServerRunners.swift index a3b547bc..f60f6ee7 100644 --- a/Sources/XcodeMCPProxyKit/XcodeMCPProxyRunners.swift +++ b/Sources/XcodeMCPServerKit/XcodeMCPServerRunners.swift @@ -1,7 +1,7 @@ import Foundation -extension XcodeMCPProxyServer { - /// Runs the `xcode-mcp-proxy-server` command-line facade. +extension XcodeMCPServer { + /// Runs the `xcode-mcp-server` command-line facade. /// /// This helper parses the same arguments and environment accepted by the /// executable, executes the normalized launch plan, and returns a @@ -36,7 +36,7 @@ extension XcodeMCPProxyServer { } } -extension XcodeMCPProxyInstaller { +extension XcodeMCPInstaller { package static func run( arguments: [String], environment: [String: String], diff --git a/Sources/XcodeMCPProxyRuntime/Broker/NativeBrokerTurns.swift b/Sources/XcodeMCPServerRuntime/Broker/NativeBrokerTurns.swift similarity index 100% rename from Sources/XcodeMCPProxyRuntime/Broker/NativeBrokerTurns.swift rename to Sources/XcodeMCPServerRuntime/Broker/NativeBrokerTurns.swift diff --git a/Sources/XcodeMCPProxyRuntime/Broker/NativeHostBroker.swift b/Sources/XcodeMCPServerRuntime/Broker/NativeHostBroker.swift similarity index 96% rename from Sources/XcodeMCPProxyRuntime/Broker/NativeHostBroker.swift rename to Sources/XcodeMCPServerRuntime/Broker/NativeHostBroker.swift index 7738df35..96f8ceff 100644 --- a/Sources/XcodeMCPProxyRuntime/Broker/NativeHostBroker.swift +++ b/Sources/XcodeMCPServerRuntime/Broker/NativeHostBroker.swift @@ -2,16 +2,16 @@ import Foundation import Logging import NIOConcurrencyHelpers import XcodeMCPCore -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract import XcodeMCPWire -package final class NativeHostBroker: ProxyRuntimeServing, Sendable { +package final class NativeHostBroker: ServerRuntimeServing, Sendable { typealias SessionFactory = @Sendable (NativeHostRuntime.Configuration) -> any MCPProcessSessionFactory private struct State: Sendable { var hosts: [String: NativeBrokerHost] = [:] var installations: [URL: String] = [:] - var sessions: [ProxySessionID: NativeBrokerSession] = [:] + var sessions: [ServerSessionID: NativeBrokerSession] = [:] var closing: [UUID: Task] = [:] /// Pending stops of unused headless hosts for other installations, by host identifier. var idleStops: [String: (id: UUID, task: Task)] = [:] @@ -26,7 +26,7 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable { /// Headless models whose native close is in flight. Binding, close election, and failed-close /// restoration all run under this lock, which is taken before the broker and session locks. private let closingWorkspaces = NIOLockedValueBox>([]) - private let configuration: ProxyRuntimeConfiguration + private let configuration: ServerRuntimeConfiguration private let inventory: XcodeHostInventory private let sessionFactory: SessionFactory private let guiSessionFactory: any MCPProcessSessionFactory @@ -66,7 +66,7 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable { let retainsWorkspace: Bool } - package convenience init(configuration: ProxyRuntimeConfiguration) throws { + package convenience init(configuration: ServerRuntimeConfiguration) throws { let environment = ProcessInfo.processInfo.environment try self.init(configuration: configuration, inventory: XcodeHostInventory.live(configuration: configuration)) { @@ -74,8 +74,8 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable { } } - init(configuration: ProxyRuntimeConfiguration, inventory: XcodeHostInventory, - clock: ClockClient = .liveValue, logger: Logger = ProxyLogging.make("broker"), + init(configuration: ServerRuntimeConfiguration, inventory: XcodeHostInventory, + clock: ClockClient = .liveValue, logger: Logger = ServerLogging.make("broker"), guiSessionFactory: (any MCPProcessSessionFactory)? = nil, sessionFactory: @escaping SessionFactory) throws { self.configuration = configuration @@ -106,7 +106,7 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable { handshake: Self.initializeParams, handshakeTimeout: handshakeTimeout, catalogTimeout: catalogTimeout, prewarmsCatalog: configuration.prewarmToolsList, clock: clock, - logger: ProxyLogging.make("native-host"), + logger: ServerLogging.make("native-host"), onEvent: { [weak self] event in self?.receive(event, from: id) }) let host = NativeBrokerHost(identifier: id, index: (storage.hosts.values.map(\.index).max() ?? -1) + 1, installation: installation, connection: connection) @@ -131,7 +131,7 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable { let connection = NativeHostConnection(factory: guiSessionFactory, handshake: Self.initializeParams, handshakeTimeout: handshakeTimeout, catalogTimeout: catalogTimeout, - prewarmsCatalog: false, clock: clock, logger: ProxyLogging.make("mcpbridge"), + prewarmsCatalog: false, clock: clock, logger: ServerLogging.make("mcpbridge"), onEvent: { [weak self] event in self?.receive(event, from: Self.guiHostIdentifier) }) storage.guiConnection = connection return connection @@ -153,24 +153,24 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable { } } - package func openSession(_ id: ProxySessionID, - notify: @escaping @Sendable (Data) -> Void) throws -> any ProxyRuntimeSession { + package func openSession(_ id: ServerSessionID, + notify: @escaping @Sendable (Data) -> Void) throws -> any ServerRuntimeSession { let session = NativeBrokerSession(identifier: id, notify: notify) let registered = state.withLockedValue { storage in guard !storage.stopped, storage.resetsInProgress == 0, storage.sessions[id] == nil else { return false } storage.sessions[id] = session return true } - guard registered else { throw ProxyRuntimeUnavailable() } + guard registered else { throw ServerRuntimeUnavailable() } return Session(broker: self, session: session) } /// The runtime side of an MCP session, which the gateway holds. - private struct Session: ProxyRuntimeSession { + private struct Session: ServerRuntimeSession { let broker: NativeHostBroker let session: NativeBrokerSession - func receive(_ message: ProxyRuntimeRequest) -> any ProxyRuntimeCall { + func receive(_ message: ServerRuntimeRequest) -> any ServerRuntimeCall { broker.receive(message, in: session) } @@ -178,14 +178,14 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable { } /// A call that has its reply when it is received. - private struct AnsweredCall: ProxyRuntimeCall { - let reply: ProxyRuntimeReply + private struct AnsweredCall: ServerRuntimeCall { + let reply: ServerRuntimeReply func cancel() {} } /// Admits a session's message and registers its operation before returning, so a later /// cancellation in the session finds it. - func receive(_ message: ProxyRuntimeRequest, in session: NativeBrokerSession) -> any ProxyRuntimeCall { + func receive(_ message: ServerRuntimeRequest, in session: NativeBrokerSession) -> any ServerRuntimeCall { let object = message.decodedJSON?.foundationObject as? [String: Any] let requestID = object.flatMap { JSONRPC.Message.Inspector.requestID(from: $0) } let cancelled = NativeBrokerReply.error(id: requestID, code: -32800, message: "request cancelled").clientReply @@ -283,7 +283,7 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable { return operation } - private func process(_ request: ProxyRuntimeRequest, in session: NativeBrokerSession, + private func process(_ request: ServerRuntimeRequest, in session: NativeBrokerSession, admission: Admission) async -> NativeBrokerReply { guard let json = request.decodedJSON else { return .error(id: nil, code: -32700, message: "invalid json") @@ -362,7 +362,7 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable { } } - /// The public catalog is fixed by the proxy; the default host only supplies native descriptions once. + /// The public catalog is fixed by the server; the default host only supplies native descriptions once. private func publicCatalog(session: NativeBrokerSession) async throws -> JSONValue { let (cached, epoch) = state.withLockedValue { ($0.publicCatalog, $0.catalogEpoch) } if let cached { return cached } @@ -672,10 +672,10 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable { if let gui = resources.2 { group.addTask { await gui.shutdown() } } } } - package func snapshot() -> ProxyRuntimeSnapshot { - let hosts = hosts().map { host -> ProxyRuntimeSnapshot.Host in + package func snapshot() -> ServerRuntimeSnapshot { + let hosts = hosts().map { host -> ServerRuntimeSnapshot.Host in let status = host.status - let state: ProxyRuntimeSnapshot.Host.State = switch status.phase { + let state: ServerRuntimeSnapshot.Host.State = switch status.phase { case .idle, .stopped: .stopped case .starting: .starting case .ready: .running @@ -723,7 +723,7 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable { } private extension NativeHostBroker { - private func callTool(_ request: ProxyRuntimeRequest, session: NativeBrokerSession, + private func callTool(_ request: ServerRuntimeRequest, session: NativeBrokerSession, admission: Admission) async throws -> NativeBrokerReply { guard case .object(let object)? = request.decodedJSON, case .object(let parameters)? = object["params"], @@ -845,7 +845,7 @@ private extension NativeHostBroker { return try await operation() } - private func listWorkspaces(_ request: ProxyRuntimeRequest, session: NativeBrokerSession) async throws -> JSONValue { + private func listWorkspaces(_ request: ServerRuntimeRequest, session: NativeBrokerSession) async throws -> JSONValue { let targets = hosts().filter { return $0.identifier == Self.defaultHostIdentifier || $0.status.phase == .ready } @@ -891,7 +891,7 @@ private extension NativeHostBroker { return try Self.toolResult(.object(payload), isError: !errors.isEmpty) } - private func workspaceEntries(host: NativeBrokerHost, generation: UInt64, request: ProxyRuntimeRequest, + private func workspaceEntries(host: NativeBrokerHost, generation: UInt64, request: ServerRuntimeRequest, session: NativeBrokerSession) async throws -> [NativeBrokerWorkspaceEntry] { let native = try Self.toolRequest(request, name: Self.listWorkspacesTool, arguments: [:]) @@ -915,7 +915,7 @@ private extension NativeHostBroker { } /// Opens and binds a workspace. `workspace` is nil when the host returned a tool error. - private func openWorkspace(_ arguments: [String: JSONValue], request: ProxyRuntimeRequest, + private func openWorkspace(_ arguments: [String: JSONValue], request: ServerRuntimeRequest, session: NativeBrokerSession, retainsForRequest: Bool = false) async throws -> (result: JSONValue, workspace: NativeBrokerWorkspace?) { guard let path = Self.string(arguments["path"]) else { @@ -974,7 +974,7 @@ private extension NativeHostBroker { return nil } - private func callNativeTool(_ name: String, arguments: [String: JSONValue], request: ProxyRuntimeRequest, + private func callNativeTool(_ name: String, arguments: [String: JSONValue], request: ServerRuntimeRequest, session: NativeBrokerSession, admission: Admission) async throws -> NativeBrokerReply { guard let host = state.withLockedValue({ $0.hosts[admission.hostIdentifier] }) else { throw NativeHostBrokerError("The workspace's Xcode host is unavailable") diff --git a/Sources/XcodeMCPProxyRuntime/Broker/NativeHostBrokerOperation.swift b/Sources/XcodeMCPServerRuntime/Broker/NativeHostBrokerOperation.swift similarity index 83% rename from Sources/XcodeMCPProxyRuntime/Broker/NativeHostBrokerOperation.swift rename to Sources/XcodeMCPServerRuntime/Broker/NativeHostBrokerOperation.swift index 75f17a99..906d98e3 100644 --- a/Sources/XcodeMCPProxyRuntime/Broker/NativeHostBrokerOperation.swift +++ b/Sources/XcodeMCPServerRuntime/Broker/NativeHostBrokerOperation.swift @@ -1,14 +1,14 @@ import Foundation import NIOConcurrencyHelpers import XcodeMCPCore -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract /// One admitted request. Its reply is the work's result, unless cancellation or the deadline /// interrupts the work first with its own reply. -final class NativeHostBrokerOperation: ProxyRuntimeCall { +final class NativeHostBrokerOperation: ServerRuntimeCall { private struct State: Sendable { - var reply: ProxyRuntimeReply? - var waiters: [CheckedContinuation] = [] + var reply: ServerRuntimeReply? + var waiters: [CheckedContinuation] = [] var task: Task? var timer: Task? var workFinished = false @@ -17,16 +17,16 @@ final class NativeHostBrokerOperation: ProxyRuntimeCall { private let state = NIOLockedValueBox(State()) private let workCompletion = AsyncTerminalSignal() - private let cancelledReply: ProxyRuntimeReply + private let cancelledReply: ServerRuntimeReply let requestIDKey: String? init( - cancelledReply: ProxyRuntimeReply, + cancelledReply: ServerRuntimeReply, requestIDKey: String? = nil, deadline: Date? = nil, clock: ClockClient = .liveValue, - timeoutReply: ProxyRuntimeReply? = nil, - work: @escaping @Sendable () async -> ProxyRuntimeReply + timeoutReply: ServerRuntimeReply? = nil, + work: @escaping @Sendable () async -> ServerRuntimeReply ) { self.cancelledReply = cancelledReply self.requestIDKey = requestIDKey @@ -53,10 +53,10 @@ final class NativeHostBrokerOperation: ProxyRuntimeCall { } /// The request's reply, available as soon as the work finishes or is interrupted. - var reply: ProxyRuntimeReply { + var reply: ServerRuntimeReply { get async { await withCheckedContinuation { continuation in - let reply = state.withLockedValue { state -> ProxyRuntimeReply? in + let reply = state.withLockedValue { state -> ServerRuntimeReply? in if let reply = state.reply { return reply } state.waiters.append(continuation) return nil @@ -92,7 +92,7 @@ final class NativeHostBrokerOperation: ProxyRuntimeCall { interrupt(with: cancelledReply) } - private func interrupt(with reply: ProxyRuntimeReply) { + private func interrupt(with reply: ServerRuntimeReply) { let task = state.withLockedValue { $0.task } guard finish(with: reply) else { return } // Cancelling the work task reaches the host connection, which cancels the host request. @@ -100,8 +100,8 @@ final class NativeHostBrokerOperation: ProxyRuntimeCall { } @discardableResult - private func finish(with reply: ProxyRuntimeReply) -> Bool { - let resources = state.withLockedValue { state -> ([CheckedContinuation], Task?)? in + private func finish(with reply: ServerRuntimeReply) -> Bool { + let resources = state.withLockedValue { state -> ([CheckedContinuation], Task?)? in guard state.reply == nil else { return nil } state.reply = reply state.task = nil diff --git a/Sources/XcodeMCPProxyRuntime/Broker/NativeHostBrokerScopes.swift b/Sources/XcodeMCPServerRuntime/Broker/NativeHostBrokerScopes.swift similarity index 99% rename from Sources/XcodeMCPProxyRuntime/Broker/NativeHostBrokerScopes.swift rename to Sources/XcodeMCPServerRuntime/Broker/NativeHostBrokerScopes.swift index aec4b032..21e6468f 100644 --- a/Sources/XcodeMCPProxyRuntime/Broker/NativeHostBrokerScopes.swift +++ b/Sources/XcodeMCPServerRuntime/Broker/NativeHostBrokerScopes.swift @@ -1,6 +1,6 @@ import Foundation import XcodeMCPCore -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract struct NativeBrokerWorkspace: Sendable, Equatable { let identifier: String diff --git a/Sources/XcodeMCPProxyRuntime/Broker/NativeHostBrokerSession.swift b/Sources/XcodeMCPServerRuntime/Broker/NativeHostBrokerSession.swift similarity index 96% rename from Sources/XcodeMCPProxyRuntime/Broker/NativeHostBrokerSession.swift rename to Sources/XcodeMCPServerRuntime/Broker/NativeHostBrokerSession.swift index 393691be..cc146871 100644 --- a/Sources/XcodeMCPProxyRuntime/Broker/NativeHostBrokerSession.swift +++ b/Sources/XcodeMCPServerRuntime/Broker/NativeHostBrokerSession.swift @@ -1,7 +1,7 @@ import Foundation import NIOConcurrencyHelpers import XcodeMCPCore -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract /// One Xcode installation's headless host and the connection that owns its process. final class NativeBrokerHost: Sendable { @@ -48,7 +48,7 @@ final class NativeBrokerSession: Sendable { !closed && (retainsHost(identifier) || hostRequests[identifier] != nil) } } - let identifier: ProxySessionID + let identifier: ServerSessionID /// Identifies this session to headless hosts, which keep Xcode's per-conversation state. let conversationID = UUID().uuidString /// Orders this session's operations on each headless model. @@ -58,7 +58,7 @@ final class NativeBrokerSession: Sendable { /// Receives the host notifications meant for this session. let notify: @Sendable (Data) -> Void - init(identifier: ProxySessionID, notify: @escaping @Sendable (Data) -> Void) { + init(identifier: ServerSessionID, notify: @escaping @Sendable (Data) -> Void) { self.identifier = identifier self.notify = notify state = NIOLockedValueBox(State()) diff --git a/Sources/XcodeMCPProxyRuntime/Broker/NativeHostBrokerTools.swift b/Sources/XcodeMCPServerRuntime/Broker/NativeHostBrokerTools.swift similarity index 97% rename from Sources/XcodeMCPProxyRuntime/Broker/NativeHostBrokerTools.swift rename to Sources/XcodeMCPServerRuntime/Broker/NativeHostBrokerTools.swift index da403f9a..8b15cd83 100644 --- a/Sources/XcodeMCPProxyRuntime/Broker/NativeHostBrokerTools.swift +++ b/Sources/XcodeMCPServerRuntime/Broker/NativeHostBrokerTools.swift @@ -1,7 +1,7 @@ import Foundation import XcodeMCPCore import XcodeMCPWire -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract /// A reply that the broker builds before it hands the client the request's JSON-RPC response. enum NativeBrokerReply: Sendable { @@ -18,7 +18,7 @@ enum NativeBrokerReply: Sendable { } /// The message HTTP sends to the client. - var clientReply: ProxyRuntimeReply { + var clientReply: ServerRuntimeReply { switch self { case .response(let data): return .response(data) @@ -65,7 +65,7 @@ extension NativeHostBroker { "required": .array(required.map(JSONValue.string))])]) } - static func requestID(_ request: ProxyRuntimeRequest) -> JSONRPC.ID? { + static func requestID(_ request: ServerRuntimeRequest) -> JSONRPC.ID? { (request.decodedJSON?.foundationObject as? [String: Any]).flatMap { JSONRPC.Message.Inspector.requestID(from: $0) } @@ -95,7 +95,7 @@ extension NativeHostBroker { } /// The client's request with another tool name and arguments, keeping its `id` and `_meta`. - static func toolRequest(_ request: ProxyRuntimeRequest, name: String, + static func toolRequest(_ request: ServerRuntimeRequest, name: String, arguments: [String: JSONValue]) throws -> JSONValue { guard case .object(var object)? = request.decodedJSON else { throw NativeHostBrokerError("Invalid request") } var parameters: [String: JSONValue] @@ -194,7 +194,7 @@ extension NativeHostBroker { } } - static func toolName(in request: ProxyRuntimeRequest) -> String? { + static func toolName(in request: ServerRuntimeRequest) -> String? { guard case .object(let object)? = request.decodedJSON, case .object(let parameters)? = object["params"], case .string(let name)? = parameters["name"] else { return nil } diff --git a/Sources/XcodeMCPProxyRuntime/Broker/ToolCallNormalizer.swift b/Sources/XcodeMCPServerRuntime/Broker/ToolCallNormalizer.swift similarity index 100% rename from Sources/XcodeMCPProxyRuntime/Broker/ToolCallNormalizer.swift rename to Sources/XcodeMCPServerRuntime/Broker/ToolCallNormalizer.swift diff --git a/Sources/XcodeMCPProxyRuntime/Broker/ToolCatalogStartupLogFormatter.swift b/Sources/XcodeMCPServerRuntime/Broker/ToolCatalogStartupLogFormatter.swift similarity index 100% rename from Sources/XcodeMCPProxyRuntime/Broker/ToolCatalogStartupLogFormatter.swift rename to Sources/XcodeMCPServerRuntime/Broker/ToolCatalogStartupLogFormatter.swift diff --git a/Sources/XcodeMCPProxyRuntime/Broker/XcodeToolCatalog.swift b/Sources/XcodeMCPServerRuntime/Broker/XcodeToolCatalog.swift similarity index 100% rename from Sources/XcodeMCPProxyRuntime/Broker/XcodeToolCatalog.swift rename to Sources/XcodeMCPServerRuntime/Broker/XcodeToolCatalog.swift diff --git a/Sources/XcodeMCPProxyRuntime/Configuration/ProxyRuntimeConfiguration.swift b/Sources/XcodeMCPServerRuntime/Configuration/ServerRuntimeConfiguration.swift similarity index 94% rename from Sources/XcodeMCPProxyRuntime/Configuration/ProxyRuntimeConfiguration.swift rename to Sources/XcodeMCPServerRuntime/Configuration/ServerRuntimeConfiguration.swift index 465fa357..58ed63b0 100644 --- a/Sources/XcodeMCPProxyRuntime/Configuration/ProxyRuntimeConfiguration.swift +++ b/Sources/XcodeMCPServerRuntime/Configuration/ServerRuntimeConfiguration.swift @@ -1,6 +1,6 @@ import Foundation -package struct ProxyRuntimeConfiguration: Sendable { +package struct ServerRuntimeConfiguration: Sendable { package var nativeHostBundleURL: URL? package var developerDirectoryURL: URL? package var sharesCompilationCache: Bool diff --git a/Sources/XcodeMCPProxyRuntime/Host/HostStderrLogFilter.swift b/Sources/XcodeMCPServerRuntime/Host/HostStderrLogFilter.swift similarity index 100% rename from Sources/XcodeMCPProxyRuntime/Host/HostStderrLogFilter.swift rename to Sources/XcodeMCPServerRuntime/Host/HostStderrLogFilter.swift diff --git a/Sources/XcodeMCPProxyRuntime/Host/NativeHostConnection.swift b/Sources/XcodeMCPServerRuntime/Host/NativeHostConnection.swift similarity index 98% rename from Sources/XcodeMCPProxyRuntime/Host/NativeHostConnection.swift rename to Sources/XcodeMCPServerRuntime/Host/NativeHostConnection.swift index 85445698..1bef2f3e 100644 --- a/Sources/XcodeMCPProxyRuntime/Host/NativeHostConnection.swift +++ b/Sources/XcodeMCPServerRuntime/Host/NativeHostConnection.swift @@ -3,7 +3,7 @@ import Logging import NIOConcurrencyHelpers import Synchronization import XcodeMCPCore -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract /// Why a host request ended without a host response. enum NativeHostConnectionError: Error, CustomStringConvertible { @@ -46,7 +46,7 @@ actor NativeHostConnection { enum Event: Sendable { /// A host notification for `owner`, or for every user of the host when `owner` is `nil`. - case notification(owner: ProxySessionID?, data: Data) + case notification(owner: ServerSessionID?, data: Data) case processEnded(generation: UInt64) } @@ -68,7 +68,7 @@ actor NativeHostConnection { private struct Pending { let generation: UInt64 - let owner: ProxySessionID? + let owner: ServerSessionID? let originalID: JSONValue let progress: ProgressTokenMapping? var continuation: CheckedContinuation? @@ -128,7 +128,7 @@ actor NativeHostConnection { /// Sends a request object and returns the host's response, which has a result or an error, /// with the request's original `id`. Cancelling the caller sends `notifications/cancelled`. - func send(_ request: JSONValue, owner: ProxySessionID?, generation expected: UInt64?) async throws -> Data { + func send(_ request: JSONValue, owner: ServerSessionID?, generation expected: UInt64?) async throws -> Data { let process = try await runningProcess() if let expected, process.generation != expected { throw NativeHostConnectionError.expired } return try await exchange(request, owner: owner, on: process) @@ -319,7 +319,7 @@ actor NativeHostConnection { // MARK: - Requests - private func exchange(_ request: JSONValue, owner: ProxySessionID?, on process: Process) async throws -> Data { + private func exchange(_ request: JSONValue, owner: ServerSessionID?, on process: Process) async throws -> Data { guard case .object(var object) = request, let originalID = object["id"] else { throw NativeHostConnectionError.unavailable("invalid host request") } diff --git a/Sources/XcodeMCPProxyRuntime/Host/NativeHostRuntime.swift b/Sources/XcodeMCPServerRuntime/Host/NativeHostRuntime.swift similarity index 99% rename from Sources/XcodeMCPProxyRuntime/Host/NativeHostRuntime.swift rename to Sources/XcodeMCPServerRuntime/Host/NativeHostRuntime.swift index af905916..a9724b47 100644 --- a/Sources/XcodeMCPProxyRuntime/Host/NativeHostRuntime.swift +++ b/Sources/XcodeMCPServerRuntime/Host/NativeHostRuntime.swift @@ -68,7 +68,7 @@ enum NativeHostRuntime { static func buildServiceEnvironment( baseEnvironment: [String: String], processRunner: any ProcessRunning = ProcessRunner(), - logger: Logger = ProxyLogging.make("native-host") + logger: Logger = ServerLogging.make("native-host") ) async throws -> [String: String] { let keys = [ "SWBBUILDSERVICE_PATH", "XCBBUILDSERVICE_PATH", diff --git a/Sources/XcodeMCPProxyRuntime/Host/XcodeHostInventory.swift b/Sources/XcodeMCPServerRuntime/Host/XcodeHostInventory.swift similarity index 93% rename from Sources/XcodeMCPProxyRuntime/Host/XcodeHostInventory.swift rename to Sources/XcodeMCPServerRuntime/Host/XcodeHostInventory.swift index f2da789a..edd18e67 100644 --- a/Sources/XcodeMCPProxyRuntime/Host/XcodeHostInventory.swift +++ b/Sources/XcodeMCPServerRuntime/Host/XcodeHostInventory.swift @@ -26,11 +26,11 @@ struct XcodeHostInventory: Sendable { } static func live( - configuration: ProxyRuntimeConfiguration, + configuration: ServerRuntimeConfiguration, environment: [String: String] = ProcessInfo.processInfo.environment ) throws -> Self { let discovery = XcodeInstallationDiscovery.live - let logger = ProxyLogging.make("installation") + let logger = ServerLogging.make("installation") let installation = try discovery.resolve(preferred: configuration.developerDirectoryURL, environment: environment) { logger.notice("\($0)") } diff --git a/Sources/XcodeMCPProxyRuntime/Support/ProxyLogging.swift b/Sources/XcodeMCPServerRuntime/Support/ServerLogging.swift similarity index 97% rename from Sources/XcodeMCPProxyRuntime/Support/ProxyLogging.swift rename to Sources/XcodeMCPServerRuntime/Support/ServerLogging.swift index c6da808b..8635e514 100644 --- a/Sources/XcodeMCPProxyRuntime/Support/ProxyLogging.swift +++ b/Sources/XcodeMCPServerRuntime/Support/ServerLogging.swift @@ -3,9 +3,9 @@ import Logging import NIOConcurrencyHelpers import XcodeMCPCore -package enum ProxyLogging { +package enum ServerLogging { private static let bootstrapState = NIOLockedValueBox(false) - private static let labelPrefix = "XcodeMCPProxy" + private static let labelPrefix = "XcodeMCPServer" /// Call from the host application to opt into StreamLogHandler-based logging. /// Do not call this if swift-log is already bootstrapped elsewhere. diff --git a/Sources/XcodeMCPProxyRuntimeContract/ProxyRuntimeServing.swift b/Sources/XcodeMCPServerRuntimeContract/ServerRuntimeServing.swift similarity index 78% rename from Sources/XcodeMCPProxyRuntimeContract/ProxyRuntimeServing.swift rename to Sources/XcodeMCPServerRuntimeContract/ServerRuntimeServing.swift index beb0419b..07b59375 100644 --- a/Sources/XcodeMCPProxyRuntimeContract/ProxyRuntimeServing.swift +++ b/Sources/XcodeMCPServerRuntimeContract/ServerRuntimeServing.swift @@ -1,17 +1,17 @@ import Foundation import XcodeMCPCore -package struct ProxySessionID: Hashable, Sendable { +package struct ServerSessionID: Hashable, Sendable { package let rawValue: String package init(rawValue: String) { - precondition(rawValue.isEmpty == false, "proxy session ID must not be empty") + precondition(rawValue.isEmpty == false, "server session ID must not be empty") self.rawValue = rawValue } } /// One JSON-RPC message from a client. -package struct ProxyRuntimeRequest: Sendable { +package struct ServerRuntimeRequest: Sendable { package let data: Data package let decodedJSON: JSONValue? @@ -27,14 +27,14 @@ package struct ProxyRuntimeRequest: Sendable { } /// The runtime's answer to a client message. HTTP chooses the status and headers. -package enum ProxyRuntimeReply: Sendable { +package enum ServerRuntimeReply: Sendable { /// One JSON-RPC response object, carrying a result or an error. case response(Data) /// A client notification or response, which has no reply. case accepted } -package struct ProxyRuntimeSnapshot: Sendable { +package struct ServerRuntimeSnapshot: Sendable { /// One owned headless host for an Xcode installation. package struct Host: Equatable, Sendable { package enum State: Equatable, Sendable { @@ -67,37 +67,37 @@ package struct ProxyRuntimeSnapshot: Sendable { } /// A client message that the runtime has received. -package protocol ProxyRuntimeCall: Sendable { +package protocol ServerRuntimeCall: Sendable { /// The message's reply, once the runtime has handled it. - var reply: ProxyRuntimeReply { get async } + var reply: ServerRuntimeReply { get async } /// Cancels the request, which then replies without waiting for its host. func cancel() } /// The runtime side of one MCP session, which the HTTP gateway creates, uses, and ends. -package protocol ProxyRuntimeSession: Sendable { +package protocol ServerRuntimeSession: Sendable { /// Receives one client message. A session receives its messages in call order, so a /// cancellation finds every request received before it. - func receive(_ message: ProxyRuntimeRequest) -> any ProxyRuntimeCall + func receive(_ message: ServerRuntimeRequest) -> any ServerRuntimeCall /// Ends the session: cancels its requests and releases what it references. Later calls do nothing. func close() } /// The runtime cannot open sessions while it stops or resets. -package struct ProxyRuntimeUnavailable: Error { +package struct ServerRuntimeUnavailable: Error { package init() {} } -package protocol ProxyRuntimeServing: Sendable { +package protocol ServerRuntimeServing: Sendable { func start() func cancelForDeinit() func shutdown() async /// Opens a session. `notify` receives the host notifications meant for it, such as progress /// for its requests. - func openSession(_ id: ProxySessionID, notify: @escaping @Sendable (Data) -> Void) throws -> any ProxyRuntimeSession - func snapshot() -> ProxyRuntimeSnapshot + func openSession(_ id: ServerSessionID, notify: @escaping @Sendable (Data) -> Void) throws -> any ServerRuntimeSession + func snapshot() -> ServerRuntimeSnapshot func debugSnapshotData(includeSensitivePayloads: Bool) -> Data? func reset() async } diff --git a/Sources/XcodeMCPProxyToolVerifier/PreviewCapture.swift b/Sources/XcodeMCPToolVerifier/PreviewCapture.swift similarity index 100% rename from Sources/XcodeMCPProxyToolVerifier/PreviewCapture.swift rename to Sources/XcodeMCPToolVerifier/PreviewCapture.swift diff --git a/Sources/XcodeMCPProxyToolVerifier/PreviewComparison.swift b/Sources/XcodeMCPToolVerifier/PreviewComparison.swift similarity index 100% rename from Sources/XcodeMCPProxyToolVerifier/PreviewComparison.swift rename to Sources/XcodeMCPToolVerifier/PreviewComparison.swift diff --git a/Sources/XcodeMCPProxyToolVerifier/PreviewFixture.swift b/Sources/XcodeMCPToolVerifier/PreviewFixture.swift similarity index 100% rename from Sources/XcodeMCPProxyToolVerifier/PreviewFixture.swift rename to Sources/XcodeMCPToolVerifier/PreviewFixture.swift diff --git a/Sources/XcodeMCPProxyToolVerifier/PreviewVerifierCommand.swift b/Sources/XcodeMCPToolVerifier/PreviewVerifierCommand.swift similarity index 96% rename from Sources/XcodeMCPProxyToolVerifier/PreviewVerifierCommand.swift rename to Sources/XcodeMCPToolVerifier/PreviewVerifierCommand.swift index 732fb9fb..4ee63e4d 100644 --- a/Sources/XcodeMCPProxyToolVerifier/PreviewVerifierCommand.swift +++ b/Sources/XcodeMCPToolVerifier/PreviewVerifierCommand.swift @@ -148,14 +148,14 @@ enum PreviewVerifierCommand { static let usage = """ Usage: - xcode-mcp-proxy-tool-verifier previews list - xcode-mcp-proxy-tool-verifier previews prepare --fixture NAME --output DIRECTORY + xcode-mcp-tool-verifier previews list + xcode-mcp-tool-verifier previews prepare --fixture NAME --output DIRECTORY [--device-name NAME] [--build-settings JSON_FILE] - xcode-mcp-proxy-tool-verifier previews capture --fixture DIRECTORY --case NAME + xcode-mcp-tool-verifier previews capture --fixture DIRECTORY --case NAME --developer-dir PATH --destination TITLE --output DIRECTORY [--backend headless|native] [--native-host APP] [--xcode-pid PID] [--timeout SECONDS] [--sequence-edit JSON_FILE] - xcode-mcp-proxy-tool-verifier previews compare --native CAPTURE --headless CAPTURE --output DIRECTORY + xcode-mcp-tool-verifier previews compare --native CAPTURE --headless CAPTURE --output DIRECTORY prepare copies a tracked project and its source variant. build-settings JSON is target name -> configuration name -> setting name -> string value. @@ -173,7 +173,7 @@ enum PreviewVerifierCommand { struct PreviewVerifierOptions { let action: String let values: [String: String] - private let defaultOutput = URL(filePath: "ProxyToolVerifierOutput/Preview-\(UUID().uuidString)", directoryHint: .isDirectory) + private let defaultOutput = URL(filePath: "ToolVerifierOutput/Preview-\(UUID().uuidString)", directoryHint: .isDirectory) init(_ arguments: [String]) throws { if arguments.isEmpty || arguments.contains("--help") || arguments.contains("-h") { diff --git a/Sources/XcodeMCPProxyToolVerifier/README.md b/Sources/XcodeMCPToolVerifier/README.md similarity index 85% rename from Sources/XcodeMCPProxyToolVerifier/README.md rename to Sources/XcodeMCPToolVerifier/README.md index d41d64d6..f40daac1 100644 --- a/Sources/XcodeMCPProxyToolVerifier/README.md +++ b/Sources/XcodeMCPToolVerifier/README.md @@ -1,9 +1,9 @@ -# XcodeMCPProxyToolVerifier +# XcodeMCPToolVerifier -Live verifier for a locally built proxy and its signed headless native helper: +Live verifier for a locally built server and its signed headless native helper: ```sh -swift run xcode-mcp-proxy-tool-verifier +swift run xcode-mcp-tool-verifier ``` The default catalog run copies the tracked fixture to its output directory and explicitly opens @@ -11,10 +11,10 @@ that saved workspace through the native host. It does not open Xcode windows. ## Run ownership -The verifier builds the local debug proxy and uses `scripts/build-native-host.sh` +The verifier builds the local debug server and uses `scripts/build-native-host.sh` to create the signed app beside the executable. It starts a verifier-only listener and isolates discovery, logs, reports, and cache files under -`ProxyToolVerifierOutput/`, which is ignored by Git. +`ToolVerifierOutput/`, which is ignored by Git. The tracked `Fixtures/ProxyToolVerifierFixture` supplies an app, scheme, test target, SwiftUI preview, and String Catalog. The verifier mutates only its @@ -26,8 +26,8 @@ its owned server and helpers. ## Catalog and verification coverage Every run records the complete live catalog in -`ProxyToolVerifierOutput/tool-catalog.json` and operation results in -`ProxyToolVerifierOutput/report.json`. The catalog describes the proxy's public +`ToolVerifierOutput/tool-catalog.json` and operation results in +`ToolVerifierOutput/report.json`. The catalog describes the server's public operations. Tool-specific argument plans describe verifier coverage; a listed operation can still be unsupported by the fixture's backend. @@ -47,8 +47,8 @@ selected scheme, destination, and test plan. ## Options ```sh -swift run xcode-mcp-proxy-tool-verifier --port 18765 --request-timeout 600 -swift run xcode-mcp-proxy-tool-verifier --keep-server +swift run xcode-mcp-tool-verifier --port 18765 --request-timeout 600 +swift run xcode-mcp-tool-verifier --keep-server ``` Use `--run-destination` with a display title from `XcodeListRunDestinations` to @@ -57,7 +57,7 @@ an owned Simulator UUID for device-interaction session preparation. The caller creates and removes that Simulator. For example: ```sh -swift run xcode-mcp-proxy-tool-verifier \ +swift run xcode-mcp-tool-verifier \ --run-destination "Verifier iPhone" --device-identifier "$verifier_device_id" ``` @@ -65,7 +65,7 @@ The verifier stops fixture operations if scheme, destination, or test-plan selection fails. Project and target creation runs after build, runtime, and device checks so a new target's automatic scheme cannot change those checks. -The default catalog run uses the proxy's default headless host. It does not +The default catalog run uses the server's default headless host. It does not verify GUI workspaces, other installations, or concurrent execution across hosts. Removed options are listed in the [migration guide](../../Docs/migrations/native-backend.md). @@ -76,9 +76,9 @@ Apple's native `RenderPreview` with the headless renderer. Run them from the repository root with Swift 6.3 or later. The fixtures cover arm64 execution. ```sh -swift run xcode-mcp-proxy-tool-verifier previews list -swift run xcode-mcp-proxy-tool-verifier previews prepare \ - --fixture platform --output ProxyToolVerifierOutput/platform +swift run xcode-mcp-tool-verifier previews list +swift run xcode-mcp-tool-verifier previews prepare \ + --fixture platform --output ToolVerifierOutput/platform ``` | Fixture | Contents | @@ -107,19 +107,19 @@ Choose an installed Xcode and a destination title reported by ```sh developer_dir=/Applications/Xcode.app/Contents/Developer -swift run xcode-mcp-proxy-tool-verifier previews capture \ - --fixture ProxyToolVerifierOutput/platform --case mac-appkit-controller \ +swift run xcode-mcp-tool-verifier previews capture \ + --fixture ToolVerifierOutput/platform --case mac-appkit-controller \ --developer-dir "$developer_dir" --destination "My Mac" \ - --backend headless --output ProxyToolVerifierOutput/headless + --backend headless --output ToolVerifierOutput/headless -swift run xcode-mcp-proxy-tool-verifier previews capture \ - --fixture ProxyToolVerifierOutput/platform --case mac-appkit-controller \ +swift run xcode-mcp-tool-verifier previews capture \ + --fixture ToolVerifierOutput/platform --case mac-appkit-controller \ --developer-dir "$developer_dir" --destination "My Mac" \ - --backend native --xcode-pid "$xcode_pid" --output ProxyToolVerifierOutput/native + --backend native --xcode-pid "$xcode_pid" --output ToolVerifierOutput/native -swift run xcode-mcp-proxy-tool-verifier previews compare \ - --native ProxyToolVerifierOutput/native --headless ProxyToolVerifierOutput/headless \ - --output ProxyToolVerifierOutput/comparison +swift run xcode-mcp-tool-verifier previews compare \ + --native ToolVerifierOutput/native --headless ToolVerifierOutput/headless \ + --output ToolVerifierOutput/comparison ``` Set `xcode_pid` to the running process for the selected Xcode. Native capture opens @@ -152,7 +152,7 @@ text replacement for the case's source file: ``` ```sh -swift run xcode-mcp-proxy-tool-verifier previews capture \ +swift run xcode-mcp-tool-verifier previews capture \ --fixture "$HOME/Dev/work/preview-latency/general" --case uiview \ --developer-dir "$developer_dir" --destination "$destination" \ --sequence-edit /path/to/edit.json --native-host /path/to/XcodeMCPNativeHost.app \ @@ -186,10 +186,10 @@ Physical probes need a connected eligible device and locally configured signing. Supply the source device name when preparing the project: ```sh -swift run xcode-mcp-proxy-tool-verifier previews prepare \ +swift run xcode-mcp-tool-verifier previews prepare \ --fixture physical --device-name "Your iPhone" \ - --build-settings ProxyToolVerifierOutput/local-signing.json \ - --output ProxyToolVerifierOutput/physical + --build-settings ToolVerifierOutput/local-signing.json \ + --output ToolVerifierOutput/physical ``` The build-settings file maps target names to configuration names and string diff --git a/Sources/XcodeMCPProxyToolVerifier/XcodeMCPProxyToolVerifier.swift b/Sources/XcodeMCPToolVerifier/XcodeMCPToolVerifier.swift similarity index 95% rename from Sources/XcodeMCPProxyToolVerifier/XcodeMCPProxyToolVerifier.swift rename to Sources/XcodeMCPToolVerifier/XcodeMCPToolVerifier.swift index de79d9ff..7906a4e2 100644 --- a/Sources/XcodeMCPProxyToolVerifier/XcodeMCPProxyToolVerifier.swift +++ b/Sources/XcodeMCPToolVerifier/XcodeMCPToolVerifier.swift @@ -1,14 +1,14 @@ import Foundation import XcodeMCPKit -package enum ProxyToolVerifierCommand { +package enum ToolVerifierCommand { package static func run(arguments: [String]) async -> Int32 { do { if arguments.first == "previews" { return try await PreviewVerifierCommand.run(arguments: Array(arguments.dropFirst())) } let options = try VerifierOptions(arguments: arguments) - let runner = ProxyToolVerifier(options: options) + let runner = ToolVerifier(options: options) let hasFailures = try await runner.run() return hasFailures ? 1 : 0 } catch { @@ -22,7 +22,7 @@ struct VerifierOptions { var host = "127.0.0.1" var port = 18_765 var requestTimeoutSeconds = 600 - var outputDirectory = URL(fileURLWithPath: "ProxyToolVerifierOutput", isDirectory: true) + var outputDirectory = URL(fileURLWithPath: "ToolVerifierOutput", isDirectory: true) var keepServer = false var runDestination: String? var deviceIdentifier: String? @@ -67,15 +67,15 @@ struct VerifierOptions { static let usage = """ Usage: - swift run xcode-mcp-proxy-tool-verifier [options] - swift run xcode-mcp-proxy-tool-verifier previews --help + swift run xcode-mcp-tool-verifier [options] + swift run xcode-mcp-tool-verifier previews --help Options: - --host host Listen host for the debug proxy server. Default: 127.0.0.1 + --host host Listen host for the debug server. Default: 127.0.0.1 --port port Dedicated verifier port. Default: 18765 --request-timeout seconds XcodeMCP request timeout. Default: 600 - --output path Git-ignored verifier output directory. Default: ProxyToolVerifierOutput - --keep-server Leave the debug proxy server running. + --output path Git-ignored verifier output directory. Default: ToolVerifierOutput + --keep-server Leave the debug server running. --run-destination name Use this native destination display title for fixture operations. --device-identifier UUID Use this owned device for device-interaction verification. -v, --verbose Print tool arguments and response summaries. @@ -95,7 +95,7 @@ struct VerifierOptions { } } -struct ProxyToolVerifier { +struct ToolVerifier { let options: VerifierOptions let fileManager = FileManager.default @@ -106,16 +106,16 @@ struct ProxyToolVerifier { try prepareOutputDirectory(outputRoot) try prepareFixture(fixture) - try buildDebugProxyServer(in: repoRoot) + try buildDebugServer(in: repoRoot) try runProcess(executable: "/bin/bash", arguments: ["scripts/build-native-host.sh", "--output", ".build/debug/XcodeMCPNativeHost.app"], currentDirectory: repoRoot) - let server = try startDebugProxyServer(repoRoot: repoRoot, outputRoot: outputRoot) + let server = try startDebugServer(repoRoot: repoRoot, outputRoot: outputRoot) defer { if options.keepServer == false { server.terminate() } } - let client = try await connectToProxy(server: server) + let client = try await connectToServer(server: server) do { let result = try await verify( client: client, @@ -301,14 +301,14 @@ struct ProxyToolVerifier { return record } - private func connectToProxy(server: RunningProcess) async throws -> XcodeMCP { - try await waitForProxyListener(server: server) + private func connectToServer(server: RunningProcess) async throws -> XcodeMCP { + try await waitForServerListener(server: server) var lastError: (any Error)? for attempt in 0..<90 { guard server.isRunning else { throw VerifierFailure( - "debug proxy server exited before MCP initialization with status " + "debug server exited before MCP initialization with status " + "\(server.terminationStatus)" ) } @@ -316,7 +316,7 @@ struct ProxyToolVerifier { return try await XcodeMCP( configuration: .init( transport: .server(at: options.endpoint), - clientName: "XcodeMCPProxyToolVerifier", + clientName: "XcodeMCPToolVerifier", clientVersion: "dev", requestTimeout: .seconds(options.requestTimeoutSeconds) ) @@ -333,13 +333,13 @@ struct ProxyToolVerifier { } } throw VerifierFailure( - "proxy did not complete MCP initialization at " + "server did not complete MCP initialization at " + "\(options.endpoint.absoluteString): " + "\(lastError.map(errorDescription) ?? "unknown error")" ) } - private func waitForProxyListener(server: RunningProcess) async throws { + private func waitForServerListener(server: RunningProcess) async throws { let configuration = URLSessionConfiguration.ephemeral configuration.waitsForConnectivity = false configuration.timeoutIntervalForRequest = 1 @@ -353,7 +353,7 @@ struct ProxyToolVerifier { while clock.now < deadline { guard server.isRunning else { throw VerifierFailure( - "debug proxy server exited before becoming ready with status " + "debug server exited before becoming ready with status " + "\(server.terminationStatus)" ) } @@ -368,7 +368,7 @@ struct ProxyToolVerifier { } } throw VerifierFailure( - "proxy listener did not become ready at \(options.endpoint.absoluteString)" + "server listener did not become ready at \(options.endpoint.absoluteString)" ) } @@ -397,22 +397,22 @@ struct ProxyToolVerifier { } } - private func buildDebugProxyServer(in repoRoot: URL) throws { - print("Building debug xcode-mcp-proxy-server...") + private func buildDebugServer(in repoRoot: URL) throws { + print("Building debug xcode-mcp-server...") try runProcess( executable: "/usr/bin/swift", - arguments: ["build", "--configuration", "debug", "--product", "xcode-mcp-proxy-server"], + arguments: ["build", "--configuration", "debug", "--product", "xcode-mcp-server"], currentDirectory: repoRoot ) } - private func startDebugProxyServer(repoRoot: URL, outputRoot: URL) throws -> RunningProcess { - let binary = repoRoot.appendingPathComponent(".build/debug/xcode-mcp-proxy-server") + private func startDebugServer(repoRoot: URL, outputRoot: URL) throws -> RunningProcess { + let binary = repoRoot.appendingPathComponent(".build/debug/xcode-mcp-server") guard fileManager.isExecutableFile(atPath: binary.path) else { - throw VerifierFailure("debug proxy server binary is missing: \(binary.path)") + throw VerifierFailure("debug server binary is missing: \(binary.path)") } try assertTCPPortAvailable(host: options.host, port: options.port) - let logURL = outputRoot.appendingPathComponent("proxy-server.log") + let logURL = outputRoot.appendingPathComponent("server.log") fileManager.createFile(atPath: logURL.path, contents: nil) let logHandle = try FileHandle(forWritingTo: logURL) let process = Process() @@ -423,7 +423,7 @@ struct ProxyToolVerifier { ] process.arguments = arguments var environment = ProcessInfo.processInfo.environment - environment["XCODE_MCP_PROXY_CACHE_ROOT"] = outputRoot.appendingPathComponent("cache").path + environment["XCODE_MCP_SERVER_CACHE_ROOT"] = outputRoot.appendingPathComponent("cache").path process.environment = environment process.standardOutput = logHandle process.standardError = logHandle @@ -436,11 +436,11 @@ struct ProxyToolVerifier { guard process.isRunning else { try? logHandle.close() throw VerifierFailure( - "debug proxy server exited immediately with status \(process.terminationStatus)" + "debug server exited immediately with status \(process.terminationStatus)" ) } - print("Started debug proxy server: \(options.endpoint.absoluteString)") - print("Proxy log: \(logURL.path)") + print("Started debug server: \(options.endpoint.absoluteString)") + print("Server log: \(logURL.path)") return RunningProcess(process: process, logHandle: logHandle) } @@ -630,7 +630,7 @@ private struct VerificationState { var testIdentifier = "ProxyToolVerifierFixtureTests/testMessage()" var testPlanName: String? var createdScratchPath: String? - var interactionSessionIdentifier = "Proxy Tool Verifier \(UUID().uuidString)" + var interactionSessionIdentifier = "XcodeMCPKit Tool Verifier \(UUID().uuidString)" var interactionSessionKey: String? var interactionSessionOpenedByVerifier = false var interactionSessionEndAttempted = false @@ -738,7 +738,7 @@ private struct VerificationState { case "AddInfoPlist": return try withWorkspaceScope(toolName, ["targetName": .string("ProxyToolVerifierFixture"), "infoPlistKey": .string("CFBundleDisplayName"), "infoPlistValueType": .string("string"), - "infoPlistValue": .string("Proxy Tool Verifier")]) + "infoPlistValue": .string("XcodeMCPKit Tool Verifier")]) case "UpdateTargetBuildSetting": return try withWorkspaceScope(toolName, ["targetName": .string("ProxyToolVerifierFixture"), "buildSettingName": .string("SWIFT_VERSION"), @@ -750,14 +750,14 @@ private struct VerificationState { return try withWorkspaceScope(toolName, ["testPlanName": .string(testPlanName)]) case "XcodeNewTarget": return try withWorkspaceScope(toolName, ["templateIdentifier": .string("com.apple.dt.unit.iosFramework"), - "productName": .string("ProxyVerifierExtraFramework"), + "productName": .string("ToolVerifierExtraFramework"), "organizationIdentifier": .string("dev.xcodemcp"), "options": .object(["languageChoice": "Swift", "testingSystem": "None", "hasDocumentation": "false"])]) case "XcodeNewProject": let destination = fixture.outputRoot.appendingPathComponent("GeneratedProjects-\(UUID().uuidString)", isDirectory: true) try FileManager.default.createDirectory(at: destination, withIntermediateDirectories: false) return ["templateIdentifier": .string("com.apple.dt.unit.commandLineTool"), - "productName": .string("ProxyVerifierGeneratedCLI"), + "productName": .string("ToolVerifierGeneratedCLI"), "destinationPath": .string(destination.path), "organizationIdentifier": .string("dev.xcodemcp"), "options": .object(["languageChoice": "Swift"])] @@ -804,7 +804,7 @@ private struct VerificationState { case "GetFieldPerformanceIssueLogs": return try withWorkspaceScope(toolName, [ "app_version": .string("1.0"), - "signature_name": .string("ProxyVerifierPerformanceSignature"), + "signature_name": .string("ToolVerifierPerformanceSignature"), "diagnostic_type": .string("hangs"), "bundle_id": .string("dev.xcodemcp.ProxyToolVerifierFixture"), "platform": .string("iOS"), @@ -852,7 +852,7 @@ private struct VerificationState { case "RunCodeSnippet": return try withWorkspaceScope(toolName, [ "sourceFilePath": .string(navPath("VerifierCore.swift")), - "purpose": .string("Proxy verifier snippet"), + "purpose": .string("Tool verifier snippet"), "codeSnippet": .string(#"print(VerifierCore.message())"#), "timeout": .integer(120), ]) @@ -892,7 +892,7 @@ private struct VerificationState { return try withWorkspaceScope(toolName, [ "targetName": .string("ProxyToolVerifierFixture"), "filePath": .string(navPath("VerifierCore.swift")), - "compilerFlags": .string("-DPROXY_TOOL_VERIFIER"), + "compilerFlags": .string("-DTOOL_VERIFIER"), "appendValue": .bool(false), ]) case "XcodeGlob": @@ -960,7 +960,7 @@ private struct VerificationState { case "XcodeWrite": return try withWorkspaceScope(toolName, [ "filePath": .string(scratchPath("probe.txt")), - "content": .string("proxy verifier initial content\n"), + "content": .string("Tool verifier initial content\n"), ]) default: return nil diff --git a/Sources/XcodeMCPProxyToolVerifierCLI/XcodeMCPProxyToolVerifierCLI.swift b/Sources/XcodeMCPToolVerifierCLI/XcodeMCPToolVerifierCLI.swift similarity index 57% rename from Sources/XcodeMCPProxyToolVerifierCLI/XcodeMCPProxyToolVerifierCLI.swift rename to Sources/XcodeMCPToolVerifierCLI/XcodeMCPToolVerifierCLI.swift index 528aa41f..80037ea5 100644 --- a/Sources/XcodeMCPProxyToolVerifierCLI/XcodeMCPProxyToolVerifierCLI.swift +++ b/Sources/XcodeMCPToolVerifierCLI/XcodeMCPToolVerifierCLI.swift @@ -1,10 +1,10 @@ import Foundation -import XcodeMCPProxyToolVerifier +import XcodeMCPToolVerifier @main -struct XcodeMCPProxyToolVerifierCLI { +struct XcodeMCPToolVerifierCLI { static func main() async { - let status = await ProxyToolVerifierCommand.run( + let status = await ToolVerifierCommand.run( arguments: Array(CommandLine.arguments.dropFirst()) ) Foundation.exit(status) diff --git a/Tests/ProxyLiveMCPBridgeTests/LiveMCPBridgeTests.swift b/Tests/LiveMCPBridgeTests/LiveMCPBridgeTests.swift similarity index 95% rename from Tests/ProxyLiveMCPBridgeTests/LiveMCPBridgeTests.swift rename to Tests/LiveMCPBridgeTests/LiveMCPBridgeTests.swift index 1944f01f..2ed2cd83 100644 --- a/Tests/ProxyLiveMCPBridgeTests/LiveMCPBridgeTests.swift +++ b/Tests/LiveMCPBridgeTests/LiveMCPBridgeTests.swift @@ -1,7 +1,7 @@ import Foundation import Testing import XcodeMCPKit -import XcodeMCPProxyKit +import XcodeMCPServerKit @Suite(.serialized, .enabled(if: ProcessInfo.processInfo.environment["XCODE_MCP_RUN_NATIVE_TESTS"] == "1")) struct NativeHostLiveTests { @@ -76,8 +76,8 @@ struct NativeHostLiveTests { } } - @Test func installedProxyPublishesTheNativeCatalogWithoutServiceSetup() async throws { - let server = XcodeMCPProxyServer(configuration: .init(bindAddress: .localhost(port: 0), + @Test func installedServerPublishesTheNativeCatalogWithoutServiceSetup() async throws { + let server = XcodeMCPServer(configuration: .init(bindAddress: .localhost(port: 0), discovery: .disabled)) let endpoint = try await server.start() do { @@ -103,7 +103,7 @@ struct NativeHostLiveTests { } catch { do { try await server.shutdown() } catch let cleanupError { - Issue.record("Proxy cleanup also failed: \(cleanupError)") + Issue.record("Server cleanup also failed: \(cleanupError)") } throw error } diff --git a/Tests/ProxyIntegrationTests/XcodeMCPProxyServerBuildInfoTests.swift b/Tests/ProxyIntegrationTests/XcodeMCPProxyServerBuildInfoTests.swift deleted file mode 100644 index 0834946f..00000000 --- a/Tests/ProxyIntegrationTests/XcodeMCPProxyServerBuildInfoTests.swift +++ /dev/null @@ -1,20 +0,0 @@ -import XcodeMCPProxyRuntimeContract -@testable import XcodeMCPCore -import Testing -import XcodeMCPKit -@testable import XcodeMCPProxyKit -import XcodeMCPProxyRuntime - -@Suite -struct XcodeMCPProxyServerBuildInfoTests { - @Test func startupSummaryDescribesHeadlessOperation() { - let summary = XcodeMCPProxyServer.startupSummary(displayHost: "localhost", port: 8765) - #expect(summary == """ - XcodeMCPProxyKit \(XcodeMCPProxyServer.productMetadata.version) - - Server - URL: http://localhost:8765/mcp - Xcode mode: headless (saved project files) - """) - } -} diff --git a/Tests/PublicProductContractTests/PublicProductContractTests.swift b/Tests/PublicProductContractTests/PublicProductContractTests.swift index 4d951ead..81d6af2b 100644 --- a/Tests/PublicProductContractTests/PublicProductContractTests.swift +++ b/Tests/PublicProductContractTests/PublicProductContractTests.swift @@ -22,7 +22,7 @@ struct PublicProductContractTests { try makeFixturePackage(at: fixtureURL, repositoryRoot: repositoryRoot) - for target in ["XcodeMCPKitClient", "XcodeMCPKitTestingClient", "XcodeMCPProxyKitClient", "XcodeMCPProxyKitOnlyClient"] { + for target in ["XcodeMCPKitClient", "XcodeMCPKitTestingClient", "XcodeMCPServerKitClient", "XcodeMCPServerKitOnlyClient"] { let result = try runSwiftBuild( packageURL: fixtureURL, logURL: fixtureURL.appendingPathComponent("\(target)-swift-build.log"), @@ -61,8 +61,8 @@ struct PublicProductContractTests { private func makeFixturePackage(at packageURL: URL, repositoryRoot: URL) throws { let fixtureTargets = [ "XcodeMCPKitClient", - "XcodeMCPProxyKitClient", - "XcodeMCPProxyKitOnlyClient", + "XcodeMCPServerKitClient", + "XcodeMCPServerKitOnlyClient", "XcodeMCPKitTestingClient", ] + lowLevelImportChecks.map(\.targetName) + removedSurfaceChecks.map(\.targetName) @@ -83,12 +83,12 @@ struct PublicProductContractTests { to: packageURL.appendingPathComponent("Sources/XcodeMCPKitClient/Contract.swift") ) try writeIfChanged( - xcodeMCPProxyKitClientSource, - to: packageURL.appendingPathComponent("Sources/XcodeMCPProxyKitClient/Contract.swift") + xcodeMCPServerKitClientSource, + to: packageURL.appendingPathComponent("Sources/XcodeMCPServerKitClient/Contract.swift") ) try writeIfChanged( - xcodeMCPProxyKitOnlyClientSource, - to: packageURL.appendingPathComponent("Sources/XcodeMCPProxyKitOnlyClient/Contract.swift") + xcodeMCPServerKitOnlyClientSource, + to: packageURL.appendingPathComponent("Sources/XcodeMCPServerKitOnlyClient/Contract.swift") ) try writeIfChanged( xcodeMCPKitTestingClientSource, @@ -151,10 +151,10 @@ struct PublicProductContractTests { ] ), .target( - name: "XcodeMCPProxyKitClient", + name: "XcodeMCPServerKitClient", dependencies: [ .product(name: "XcodeMCPKit", package: "XcodeMCPKit"), - .product(name: "XcodeMCPProxyKit", package: "XcodeMCPKit") + .product(name: "XcodeMCPServerKit", package: "XcodeMCPKit") ], swiftSettings: [ .swiftLanguageMode(.v6), @@ -162,9 +162,9 @@ struct PublicProductContractTests { ] ), .target( - name: "XcodeMCPProxyKitOnlyClient", + name: "XcodeMCPServerKitOnlyClient", dependencies: [ - .product(name: "XcodeMCPProxyKit", package: "XcodeMCPKit") + .product(name: "XcodeMCPServerKit", package: "XcodeMCPKit") ], swiftSettings: [ .swiftLanguageMode(.v6), @@ -172,9 +172,9 @@ struct PublicProductContractTests { ] ), .target( - name: "XcodeMCPProxyKitClientImportsTestSupport", + name: "XcodeMCPServerKitClientImportsTestSupport", dependencies: [ - .product(name: "XcodeMCPProxyKit", package: "XcodeMCPKit") + .product(name: "XcodeMCPServerKit", package: "XcodeMCPKit") ], swiftSettings: [ .swiftLanguageMode(.v6), @@ -212,9 +212,9 @@ struct PublicProductContractTests { ] ), .target( - name: "XcodeMCPProxyKitClientUsesRemovedAdapterEndpointFamily", + name: "XcodeMCPServerKitClientUsesRemovedAdapterEndpointFamily", dependencies: [ - .product(name: "XcodeMCPProxyKit", package: "XcodeMCPKit") + .product(name: "XcodeMCPServerKit", package: "XcodeMCPKit") ], swiftSettings: [ .swiftLanguageMode(.v6), @@ -222,9 +222,9 @@ struct PublicProductContractTests { ] ), .target( - name: "XcodeMCPProxyKitClientUsesRemovedAdapterLaunchPlanFamily", + name: "XcodeMCPServerKitClientUsesRemovedAdapterLaunchPlanFamily", dependencies: [ - .product(name: "XcodeMCPProxyKit", package: "XcodeMCPKit") + .product(name: "XcodeMCPServerKit", package: "XcodeMCPKit") ], swiftSettings: [ .swiftLanguageMode(.v6), @@ -232,9 +232,9 @@ struct PublicProductContractTests { ] ), .target( - name: "XcodeMCPProxyKitClientUsesRemovedServerSurface", + name: "XcodeMCPServerKitClientUsesRemovedServerSurface", dependencies: [ - .product(name: "XcodeMCPProxyKit", package: "XcodeMCPKit") + .product(name: "XcodeMCPServerKit", package: "XcodeMCPKit") ], swiftSettings: [ .swiftLanguageMode(.v6), @@ -242,9 +242,9 @@ struct PublicProductContractTests { ] ), .target( - name: "XcodeMCPProxyKitClientUsesRemovedInstallerSurface", + name: "XcodeMCPServerKitClientUsesRemovedInstallerSurface", dependencies: [ - .product(name: "XcodeMCPProxyKit", package: "XcodeMCPKit") + .product(name: "XcodeMCPServerKit", package: "XcodeMCPKit") ], swiftSettings: [ .swiftLanguageMode(.v6), @@ -644,7 +644,7 @@ private struct POSIXCommandError: Error, CustomStringConvertible { } private let lowLevelImportChecks: [(targetName: String, moduleName: String)] = [ - ("XcodeMCPProxyKitClientImportsTestSupport", "XcodeMCPProxyTestSupport"), + ("XcodeMCPServerKitClientImportsTestSupport", "XcodeMCPServerTestSupport"), ] private let removedSurfaceChecks: [( @@ -696,10 +696,10 @@ private let removedSurfaceChecks: [( ] ), ( - "XcodeMCPProxyKitClientUsesRemovedAdapterEndpointFamily", + "XcodeMCPServerKitClientUsesRemovedAdapterEndpointFamily", """ import Foundation - import XcodeMCPProxyKit + import XcodeMCPServerKit func compileOnlyRemovedAdapterEndpointFamily() throws { let options = XcodeMCPProxyAdapterEndpointResolutionOptions() @@ -719,9 +719,9 @@ private let removedSurfaceChecks: [( ] ), ( - "XcodeMCPProxyKitClientUsesRemovedAdapterLaunchPlanFamily", + "XcodeMCPServerKitClientUsesRemovedAdapterLaunchPlanFamily", """ - import XcodeMCPProxyKit + import XcodeMCPServerKit func compileOnlyRemovedAdapterLaunchPlanFamily() throws { _ = XcodeMCPProxyStdioAdapter.LaunchAction.start @@ -740,12 +740,12 @@ private let removedSurfaceChecks: [( ] ), ( - "XcodeMCPProxyKitClientUsesRemovedServerSurface", + "XcodeMCPServerKitClientUsesRemovedServerSurface", """ - import XcodeMCPProxyKit + import XcodeMCPServerKit - func compileOnlyRemovedServerSurface(_ server: XcodeMCPProxyServer) async throws { - _ = XcodeMCPProxyServer.productMetadata + func compileOnlyRemovedServerSurface(_ server: XcodeMCPServer) async throws { + _ = XcodeMCPServer.productMetadata _ = try await server.startAndWriteDiscovery() } """, @@ -756,18 +756,18 @@ private let removedSurfaceChecks: [( ] ), ( - "XcodeMCPProxyKitClientUsesRemovedInstallerSurface", + "XcodeMCPServerKitClientUsesRemovedInstallerSurface", """ - import XcodeMCPProxyKit + import XcodeMCPServerKit func compileOnlyRemovedInstallerSurface() { - _ = XcodeMCPProxyInstaller() - _ = XcodeMCPProxyInstallerConfiguration() + _ = XcodeMCPInstaller() + _ = XcodeMCPInstallerConfiguration() } """, [ - "cannot find 'XcodeMCPProxyInstaller' in scope", - "cannot find 'XcodeMCPProxyInstallerConfiguration' in scope", + "cannot find 'XcodeMCPInstaller' in scope", + "cannot find 'XcodeMCPInstallerConfiguration' in scope", ] ), ] @@ -847,7 +847,7 @@ func compileOnlyClientDomainSurface() throws { let standardDiscoveryConfig = XcodeMCPConfiguration( transport: .server( environment: [ - "XCODE_MCP_PROXY_DISCOVERY_FILE": "/tmp/xcode-mcp/proxy-endpoint.json", + "XCODE_MCP_SERVER_DISCOVERY_FILE": "/tmp/xcode-mcp/server-endpoint.json", ] ) ) @@ -1051,12 +1051,12 @@ struct ClientSmoke { } """ -private let xcodeMCPProxyKitOnlyClientSource = """ -import XcodeMCPProxyKit +private let xcodeMCPServerKitOnlyClientSource = """ +import XcodeMCPServerKit -func compileOnlyProxyProductOnlySurface() { - let config = XcodeMCPProxyServerConfiguration() - let server = XcodeMCPProxyServer(configuration: config) +func compileOnlyServerProductOnlySurface() { + let config = XcodeMCPServerConfiguration() + let server = XcodeMCPServer(configuration: config) _ = ( config, @@ -1065,13 +1065,13 @@ func compileOnlyProxyProductOnlySurface() { } """ -private let xcodeMCPProxyKitClientSource = """ +private let xcodeMCPServerKitClientSource = """ import Foundation import XcodeMCPKit -import XcodeMCPProxyKit +import XcodeMCPServerKit -func compileOnlyProxyConfigurationSurface() { - let config = XcodeMCPProxyServerConfiguration( +func compileOnlyServerConfigurationSurface() { + let config = XcodeMCPServerConfiguration( bindAddress: .init(host: "127.0.0.1", port: 0), nativeHostBundleURL: URL(fileURLWithPath: "/tmp/XcodeMCPNativeHost.app"), developerDirectoryURL: URL(fileURLWithPath: "/Applications/Xcode.app/Contents/Developer"), @@ -1081,17 +1081,17 @@ func compileOnlyProxyConfigurationSurface() { approvalPolicy: .automatic, prewarmToolsList: false ) - let server = XcodeMCPProxyServer(configuration: config) + let server = XcodeMCPServer(configuration: config) _ = (config, server) } -func compileOnlyProxyLaunchSurface() async throws { +func compileOnlyServerLaunchSurface() async throws { let runnerStdout: @Sendable (String) -> Void = { _ in } let runnerStderr: @Sendable (String) -> Void = { _ in } - let serverExitCode = await XcodeMCPProxyServer.run( + let serverExitCode = await XcodeMCPServer.run( arguments: [ - "xcode-mcp-proxy-server", + "xcode-mcp-server", "--version", ], environment: [:], @@ -1101,7 +1101,7 @@ func compileOnlyProxyLaunchSurface() async throws { _ = serverExitCode } -func compileOnlyProxyLifecycleSurface(server: XcodeMCPProxyServer) async throws { +func compileOnlyServerLifecycleSurface(server: XcodeMCPServer) async throws { let address = try await server.start() let status = await server.snapshot() try await server.waitUntilShutdown() diff --git a/Tests/ProxyCLITests/CLIUsageContractTests.swift b/Tests/ServerCLITests/CLIUsageContractTests.swift similarity index 80% rename from Tests/ProxyCLITests/CLIUsageContractTests.swift rename to Tests/ServerCLITests/CLIUsageContractTests.swift index c88b7071..365b6edb 100644 --- a/Tests/ProxyCLITests/CLIUsageContractTests.swift +++ b/Tests/ServerCLITests/CLIUsageContractTests.swift @@ -1,12 +1,12 @@ import Testing -@testable import XcodeMCPProxyKit +@testable import XcodeMCPServerKit @Suite struct CLIUsageContractTests { @Test func serverHelpIsGeneratedFromTheTypedCommandSurface() { - let help = XcodeMCPProxyServer.serverUsage + let help = XcodeMCPServer.serverUsage - #expect(help.contains("USAGE: xcode-mcp-proxy-server")) + #expect(help.contains("USAGE: xcode-mcp-server")) for option in [ "--listen ", "--host ", @@ -32,8 +32,8 @@ struct CLIUsageContractTests { } @Test func installerHelpComesFromItsCommandDefinition() { - let installerHelp = XcodeMCPProxyInstaller.installUsage - #expect(installerHelp.contains("USAGE: xcode-mcp-proxy-install")) + let installerHelp = XcodeMCPInstaller.installUsage + #expect(installerHelp.contains("USAGE: xcode-mcp-install")) #expect(installerHelp.contains("--bindir ")) #expect(installerHelp.contains("--prefix ")) #expect(installerHelp.contains("--dry-run")) diff --git a/Tests/ProxyCLITests/CommandIntegrationSupport.swift b/Tests/ServerCLITests/CommandIntegrationSupport.swift similarity index 100% rename from Tests/ProxyCLITests/CommandIntegrationSupport.swift rename to Tests/ServerCLITests/CommandIntegrationSupport.swift diff --git a/Tests/ProxyCLITests/CommandTestSupport.swift b/Tests/ServerCLITests/CommandTestSupport.swift similarity index 95% rename from Tests/ProxyCLITests/CommandTestSupport.swift rename to Tests/ServerCLITests/CommandTestSupport.swift index 57016932..2cc691c6 100644 --- a/Tests/ProxyCLITests/CommandTestSupport.swift +++ b/Tests/ServerCLITests/CommandTestSupport.swift @@ -1,4 +1,4 @@ -@testable import XcodeMCPProxyKit +@testable import XcodeMCPServerKit import Foundation final class CapturedLines: @unchecked Sendable { diff --git a/Tests/ProxyCLITests/InstallerFacadeIntegrationTests.swift b/Tests/ServerCLITests/InstallerFacadeIntegrationTests.swift similarity index 84% rename from Tests/ProxyCLITests/InstallerFacadeIntegrationTests.swift rename to Tests/ServerCLITests/InstallerFacadeIntegrationTests.swift index 85603467..6e8ac488 100644 --- a/Tests/ProxyCLITests/InstallerFacadeIntegrationTests.swift +++ b/Tests/ServerCLITests/InstallerFacadeIntegrationTests.swift @@ -1,7 +1,7 @@ import Darwin import Foundation import Testing -@testable import XcodeMCPProxyKit +@testable import XcodeMCPServerKit @Suite(.serialized) struct InstallerFacadeIntegrationTests { @@ -11,20 +11,20 @@ struct InstallerFacadeIntegrationTests { let output = CapturedLines() let bindir = tempDir.url.appendingPathComponent("bin", isDirectory: true) - try XcodeMCPProxyInstaller( + try XcodeMCPInstaller( configuration: .init(prefix: nil, binaryDirectory: bindir.path, dryRun: true) ).install( - executableURL: tempDir.url.appendingPathComponent("xcode-mcp-proxy-install"), + executableURL: tempDir.url.appendingPathComponent("xcode-mcp-install"), fileManager: .default, buildProducts: { _, _, _ in }, stdout: { output.append($0) } ) - let expectedServer = bindir.appendingPathComponent("xcode-mcp-proxy-server").path + let expectedServer = bindir.appendingPathComponent("xcode-mcp-server").path #expect(output.snapshot() == [ "Would create: \(bindir.path)", "Would install: \(expectedServer)", - "Would install: \(bindir.appendingPathComponent(XcodeMCPProxyInstaller.nativeHostBundleName).path)", + "Would install: \(bindir.appendingPathComponent(XcodeMCPInstaller.nativeHostBundleName).path)", ]) } @@ -34,15 +34,15 @@ struct InstallerFacadeIntegrationTests { let installDir = try TemporaryDirectory() defer { installDir.cleanup() } - let installerURL = sourceDir.url.appendingPathComponent("xcode-mcp-proxy-install") - let serverURL = sourceDir.url.appendingPathComponent("xcode-mcp-proxy-server") + let installerURL = sourceDir.url.appendingPathComponent("xcode-mcp-install") + let serverURL = sourceDir.url.appendingPathComponent("xcode-mcp-server") try Data("installer".utf8).write(to: installerURL) try Data("server".utf8).write(to: serverURL) try writeNativeHostFixture(in: sourceDir.url, output: "native") let output = CapturedLines() let buildCalls = Counter() - try XcodeMCPProxyInstaller( + try XcodeMCPInstaller( configuration: .init(prefix: nil, binaryDirectory: installDir.url.path, dryRun: false) ).install( executableURL: installerURL, @@ -57,7 +57,7 @@ struct InstallerFacadeIntegrationTests { #expect(buildCalls.value == 0) #expect( try String( - contentsOf: installDir.url.appendingPathComponent("xcode-mcp-proxy-server"), + contentsOf: installDir.url.appendingPathComponent("xcode-mcp-server"), encoding: .utf8 ) == "server" ) @@ -74,13 +74,13 @@ struct InstallerFacadeIntegrationTests { try install(from: source.url, to: destination.url) - for name in XcodeMCPProxyInstaller.binaryNames { + for name in XcodeMCPInstaller.binaryNames { let executable = destination.url.appendingPathComponent(name) #expect(try runExecutable(executable) == "new") #expect(try FileManager.default.attributesOfItem(atPath: executable.path)[.posixPermissions] as? Int == 0o755) } #expect(try FileManager.default.contentsOfDirectory(atPath: destination.url.path).sorted() - == (XcodeMCPProxyInstaller.binaryNames + [XcodeMCPProxyInstaller.nativeHostBundleName]).sorted()) + == (XcodeMCPInstaller.binaryNames + [XcodeMCPInstaller.nativeHostBundleName]).sorted()) } @Test(arguments: [false, true]) @@ -97,7 +97,7 @@ struct InstallerFacadeIntegrationTests { try install(from: source.url, to: destination) - for name in XcodeMCPProxyInstaller.binaryNames { + for name in XcodeMCPInstaller.binaryNames { #expect(try runExecutable(source.url.appendingPathComponent(name)) == "source") } } @@ -111,7 +111,7 @@ struct InstallerFacadeIntegrationTests { defer { originals.cleanup() } try writeExecutables(in: originals.url, output: "original") try writeNativeHostFixture(in: source.url, output: "original") - for name in XcodeMCPProxyInstaller.binaryNames { + for name in XcodeMCPInstaller.binaryNames { let original = originals.url.appendingPathComponent(name) try FileManager.default.createSymbolicLink( at: source.url.appendingPathComponent(name), @@ -125,7 +125,7 @@ struct InstallerFacadeIntegrationTests { try install(from: source.url, to: destination.url) - for name in XcodeMCPProxyInstaller.binaryNames { + for name in XcodeMCPInstaller.binaryNames { #expect(try runExecutable(originals.url.appendingPathComponent(name)) == "original") #expect(try runExecutable(destination.url.appendingPathComponent(name)) == "original") #expect(try FileManager.default.attributesOfItem( @@ -141,19 +141,19 @@ struct InstallerFacadeIntegrationTests { defer { destination.cleanup() } try writeExecutables(in: source.url, output: "new") try writeExecutables(in: destination.url, output: "old") - let fileManager = FailingInstallFileManager(failCopyNamed: "xcode-mcp-proxy-server") + let fileManager = FailingInstallFileManager(failCopyNamed: "xcode-mcp-server") - let error = try #require(throws: XcodeMCPProxyInstaller.Error.self) { + let error = try #require(throws: XcodeMCPInstaller.Error.self) { try install(from: source.url, to: destination.url, fileManager: fileManager) } #expect(error.description.contains("injected copy failure")) #expect(error.description.contains("Installed: none")) - for name in XcodeMCPProxyInstaller.binaryNames { + for name in XcodeMCPInstaller.binaryNames { #expect(try runExecutable(destination.url.appendingPathComponent(name)) == "old") } #expect(try FileManager.default.contentsOfDirectory(atPath: destination.url.path).sorted() - == (XcodeMCPProxyInstaller.binaryNames + [XcodeMCPProxyInstaller.nativeHostBundleName]).sorted()) + == (XcodeMCPInstaller.binaryNames + [XcodeMCPInstaller.nativeHostBundleName]).sorted()) } @Test(arguments: [false, true]) @@ -163,26 +163,26 @@ struct InstallerFacadeIntegrationTests { let destination = try TemporaryDirectory() defer { destination.cleanup() } try writeExecutables(in: source.url, output: "new") - let server = destination.url.appendingPathComponent("xcode-mcp-proxy-server") - let bundle = destination.url.appendingPathComponent(XcodeMCPProxyInstaller.nativeHostBundleName) + let server = destination.url.appendingPathComponent("xcode-mcp-server") + let bundle = destination.url.appendingPathComponent(XcodeMCPInstaller.nativeHostBundleName) let output = CapturedLines() - let error = try #require(throws: XcodeMCPProxyInstaller.Error.self) { - try XcodeMCPProxyInstaller(configuration: .init(binaryDirectory: destination.url.path)).install( - executableURL: source.url.appendingPathComponent("xcode-mcp-proxy-install"), + let error = try #require(throws: XcodeMCPInstaller.Error.self) { + try XcodeMCPInstaller(configuration: .init(binaryDirectory: destination.url.path)).install( + executableURL: source.url.appendingPathComponent("xcode-mcp-install"), fileManager: FailingInstallFileManager(failCleanup: failCleanup), buildProducts: { _, _, _ in }, verifyNativeHostBundle: verifyNativeHostFixture, - replaceNativeHostBundle: { _, _ in throw XcodeMCPProxyInstaller.Error.message("injected bundle failure") }, + replaceNativeHostBundle: { _, _ in throw XcodeMCPInstaller.Error.message("injected bundle failure") }, stdout: { output.append($0) } ) } - #expect(error.description.contains("Failed to install \(XcodeMCPProxyInstaller.nativeHostBundleName)")) + #expect(error.description.contains("Failed to install \(XcodeMCPInstaller.nativeHostBundleName)")) #expect(error.description.contains("Installed: \(server.path)\nNot installed: \(bundle.path)")) #expect(error.description.contains("injected cleanup failure") == failCleanup) #expect(try runExecutable(server) == "new") - #expect(output.snapshot() == ["Installed xcode-mcp-proxy-server to \(server.path)"]) + #expect(output.snapshot() == ["Installed xcode-mcp-server to \(server.path)"]) let stagingDirectories = try FileManager.default.contentsOfDirectory( at: destination.url, includingPropertiesForKeys: nil @@ -204,11 +204,11 @@ struct InstallerFacadeIntegrationTests { try FileManager.default.createDirectory(at: products, withIntermediateDirectories: true) try writeExecutables(in: products, output: "source") var buildCalled = false - try XcodeMCPProxyInstaller(configuration: .init(binaryDirectory: destination.url.path)).install( - executableURL: products.appendingPathComponent("xcode-mcp-proxy-install"), + try XcodeMCPInstaller(configuration: .init(binaryDirectory: destination.url.path)).install( + executableURL: products.appendingPathComponent("xcode-mcp-install"), buildProducts: { names, root, nativeBundle in buildCalled = true - #expect(names == XcodeMCPProxyInstaller.binaryNames) + #expect(names == XcodeMCPInstaller.binaryNames) #expect(root == repository.url) #expect(nativeBundle.deletingLastPathComponent().lastPathComponent.hasPrefix(".xcode-mcp-install-")) try writeNativeHostFixture(in: nativeBundle.deletingLastPathComponent(), output: "built native helper") @@ -228,12 +228,12 @@ struct InstallerFacadeIntegrationTests { defer { destination.cleanup() } try writeExecutables(in: source.url, output: "new") try writeExecutables(in: destination.url, output: "old") - try FileManager.default.removeItem(at: source.url.appendingPathComponent(XcodeMCPProxyInstaller.nativeHostBundleName)) - let failure = try #require(throws: XcodeMCPProxyInstaller.Error.self) { + try FileManager.default.removeItem(at: source.url.appendingPathComponent(XcodeMCPInstaller.nativeHostBundleName)) + let failure = try #require(throws: XcodeMCPInstaller.Error.self) { try install(from: source.url, to: destination.url) } #expect(failure.description.contains("Installed: none")) - for name in XcodeMCPProxyInstaller.binaryNames { + for name in XcodeMCPInstaller.binaryNames { #expect(try runExecutable(destination.url.appendingPathComponent(name)) == "old") } #expect(try nativeFixtureContent(in: destination.url) == "old") @@ -246,14 +246,14 @@ struct InstallerFacadeIntegrationTests { defer { destination.cleanup() } try writeExecutables(in: source.url, output: "new") try writeExecutables(in: destination.url, output: "old") - let obsolete = destination.url.appendingPathComponent(XcodeMCPProxyInstaller.nativeHostBundleName) + let obsolete = destination.url.appendingPathComponent(XcodeMCPInstaller.nativeHostBundleName) .appendingPathComponent("obsolete") try Data("old contents".utf8).write(to: obsolete) try install(from: source.url, to: destination.url) #expect(try nativeFixtureContent(in: destination.url) == "new") #expect(!FileManager.default.fileExists(atPath: obsolete.path)) #expect(try FileManager.default.contentsOfDirectory(atPath: destination.url.path).sorted() - == (XcodeMCPProxyInstaller.binaryNames + [XcodeMCPProxyInstaller.nativeHostBundleName]).sorted()) + == (XcodeMCPInstaller.binaryNames + [XcodeMCPInstaller.nativeHostBundleName]).sorted()) } @Test func nativeSwapFailurePreservesTheOldBundleAndReportsInstalledExecutables() throws { @@ -263,9 +263,9 @@ struct InstallerFacadeIntegrationTests { defer { destination.cleanup() } try writeExecutables(in: source.url, output: "new") try writeExecutables(in: destination.url, output: "old") - let failure = try #require(throws: XcodeMCPProxyInstaller.Error.self) { - try XcodeMCPProxyInstaller(configuration: .init(binaryDirectory: destination.url.path)).install( - executableURL: source.url.appendingPathComponent("xcode-mcp-proxy-install"), + let failure = try #require(throws: XcodeMCPInstaller.Error.self) { + try XcodeMCPInstaller(configuration: .init(binaryDirectory: destination.url.path)).install( + executableURL: source.url.appendingPathComponent("xcode-mcp-install"), buildProducts: { _, _, _ in }, verifyNativeHostBundle: verifyNativeHostFixture, replaceNativeHostBundle: { _, _ in throw NSError(domain: NSPOSIXErrorDomain, code: Int(EACCES)) }, @@ -273,9 +273,9 @@ struct InstallerFacadeIntegrationTests { ) } #expect(failure.description.contains("Failed to install XcodeMCPNativeHost.app")) - #expect(failure.description.contains("Not installed: \(destination.url.appendingPathComponent(XcodeMCPProxyInstaller.nativeHostBundleName).path)")) + #expect(failure.description.contains("Not installed: \(destination.url.appendingPathComponent(XcodeMCPInstaller.nativeHostBundleName).path)")) #expect(try nativeFixtureContent(in: destination.url) == "old") - for name in XcodeMCPProxyInstaller.binaryNames { + for name in XcodeMCPInstaller.binaryNames { #expect(try runExecutable(destination.url.appendingPathComponent(name)) == "new") } } @@ -287,18 +287,18 @@ struct InstallerFacadeIntegrationTests { defer { destination.cleanup() } try writeExecutables(in: source.url, output: "new") try writeExecutables(in: destination.url, output: "old") - let failure = try #require(throws: XcodeMCPProxyInstaller.Error.self) { - try XcodeMCPProxyInstaller(configuration: .init(binaryDirectory: destination.url.path)).install( - executableURL: source.url.appendingPathComponent("xcode-mcp-proxy-install"), + let failure = try #require(throws: XcodeMCPInstaller.Error.self) { + try XcodeMCPInstaller(configuration: .init(binaryDirectory: destination.url.path)).install( + executableURL: source.url.appendingPathComponent("xcode-mcp-install"), buildProducts: { _, _, _ in }, - verifyNativeHostBundle: { _ in throw XcodeMCPProxyInstaller.Error.message("injected signature failure") }, + verifyNativeHostBundle: { _ in throw XcodeMCPInstaller.Error.message("injected signature failure") }, stdout: { _ in } ) } #expect(failure.description.contains("injected signature failure")) #expect(failure.description.contains("Installed: none")) #expect(try nativeFixtureContent(in: destination.url) == "old") - for name in XcodeMCPProxyInstaller.binaryNames { + for name in XcodeMCPInstaller.binaryNames { #expect(try runExecutable(destination.url.appendingPathComponent(name)) == "old") } } @@ -310,7 +310,7 @@ struct InstallerFacadeIntegrationTests { defer { destination.cleanup() } try writeExecutables(in: source.url, output: "new") try writeExecutables(in: destination.url, output: "old") - let failure = try #require(throws: XcodeMCPProxyInstaller.Error.self) { + let failure = try #require(throws: XcodeMCPInstaller.Error.self) { try install(from: source.url, to: destination.url, fileManager: FailingInstallFileManager(failCleanup: true)) } @@ -329,7 +329,7 @@ struct InstallerFacadeIntegrationTests { defer { destination.cleanup() } try writeExecutables(in: source.url, output: "new") - let error = try #require(throws: XcodeMCPProxyInstaller.Error.self) { + let error = try #require(throws: XcodeMCPInstaller.Error.self) { try install( from: source.url, to: destination.url, @@ -340,7 +340,7 @@ struct InstallerFacadeIntegrationTests { #expect(error.description.contains("injected cleanup failure")) #expect(error.description.contains("Not installed: none")) #expect(!error.description.contains("Failed to install")) - for name in XcodeMCPProxyInstaller.binaryNames { + for name in XcodeMCPInstaller.binaryNames { #expect(try runExecutable(destination.url.appendingPathComponent(name)) == "new") } } @@ -352,8 +352,8 @@ private func install( fileManager: FileManager = .default, stdout: (String) -> Void = { _ in } ) throws { - try XcodeMCPProxyInstaller(configuration: .init(binaryDirectory: destination.path)).install( - executableURL: source.appendingPathComponent("xcode-mcp-proxy-install"), + try XcodeMCPInstaller(configuration: .init(binaryDirectory: destination.path)).install( + executableURL: source.appendingPathComponent("xcode-mcp-install"), fileManager: fileManager, buildProducts: { _, _, _ in }, verifyNativeHostBundle: verifyNativeHostFixture, @@ -363,7 +363,7 @@ private func install( private func writeExecutables(in directory: URL, output: String, permissions: Int = 0o755) throws { try writeNativeHostFixture(in: directory, output: output) - for name in XcodeMCPProxyInstaller.binaryNames { + for name in XcodeMCPInstaller.binaryNames { let executable = directory.appendingPathComponent(name) try Data("#!/bin/sh\nprintf '%s' '\(output)'\n".utf8).write(to: executable) try FileManager.default.setAttributes([.posixPermissions: permissions], ofItemAtPath: executable.path) @@ -371,7 +371,7 @@ private func writeExecutables(in directory: URL, output: String, permissions: In } private func writeNativeHostFixture(in directory: URL, output: String) throws { - let bundle = directory.appendingPathComponent(XcodeMCPProxyInstaller.nativeHostBundleName) + let bundle = directory.appendingPathComponent(XcodeMCPInstaller.nativeHostBundleName) let macOS = bundle.appendingPathComponent("Contents/MacOS") try FileManager.default.createDirectory(at: macOS, withIntermediateDirectories: true) try Data(output.utf8).write(to: macOS.appendingPathComponent("xcode-mcp-native-host")) @@ -382,7 +382,7 @@ private func writeNativeHostFixture(in directory: URL, output: String) throws { } private func nativeFixtureContent(in directory: URL) throws -> String { - try String(contentsOf: directory.appendingPathComponent(XcodeMCPProxyInstaller.nativeHostBundleName) + try String(contentsOf: directory.appendingPathComponent(XcodeMCPInstaller.nativeHostBundleName) .appendingPathComponent("Contents/MacOS/xcode-mcp-native-host"), encoding: .utf8) } @@ -417,14 +417,14 @@ private final class FailingInstallFileManager: FileManager, @unchecked Sendable override func copyItem(at source: URL, to destination: URL) throws { if source.lastPathComponent == failCopyNamed { try Data("partial copy".utf8).write(to: destination) - throw XcodeMCPProxyInstaller.Error.message("injected copy failure") + throw XcodeMCPInstaller.Error.message("injected copy failure") } try super.copyItem(at: source, to: destination) } override func removeItem(at url: URL) throws { if failCleanup, url.lastPathComponent.hasPrefix(".xcode-mcp-install-") { - throw XcodeMCPProxyInstaller.Error.message("injected cleanup failure") + throw XcodeMCPInstaller.Error.message("injected cleanup failure") } try super.removeItem(at: url) } diff --git a/Tests/ProxyCLITests/InstallerFacadeTests.swift b/Tests/ServerCLITests/InstallerFacadeTests.swift similarity index 77% rename from Tests/ProxyCLITests/InstallerFacadeTests.swift rename to Tests/ServerCLITests/InstallerFacadeTests.swift index 44f54f77..7f8b258c 100644 --- a/Tests/ProxyCLITests/InstallerFacadeTests.swift +++ b/Tests/ServerCLITests/InstallerFacadeTests.swift @@ -1,20 +1,20 @@ import Foundation import Testing -@testable import XcodeMCPProxyKit +@testable import XcodeMCPServerKit @Suite struct InstallerFacadeTests { @Test func installerRunnerPrintsVersion() { - let result = runInstaller(arguments: ["xcode-mcp-proxy-install", "--version"]) + let result = runInstaller(arguments: ["xcode-mcp-install", "--version"]) #expect(result.exitCode == 0) - #expect(result.stdout == [XcodeMCPProxyServer.productMetadata.version]) + #expect(result.stdout == [XcodeMCPServer.productMetadata.version]) #expect(result.stderr.isEmpty) } @Test func installerRunnerDoesNotReinterpretAnOptionValueAsVersion() { let result = runInstaller( - arguments: ["xcode-mcp-proxy-install", "--bindir", "--version"] + arguments: ["xcode-mcp-install", "--bindir", "--version"] ) #expect(result.exitCode == 64) @@ -23,18 +23,18 @@ struct InstallerFacadeTests { } @Test func installerRunnerPrintsGeneratedHelp() throws { - let result = runInstaller(arguments: ["xcode-mcp-proxy-install", "--help"]) + let result = runInstaller(arguments: ["xcode-mcp-install", "--help"]) #expect(result.exitCode == 0) #expect(result.stderr.isEmpty) let line = try #require(result.stdout.first) - #expect(line.contains("USAGE: xcode-mcp-proxy-install")) + #expect(line.contains("USAGE: xcode-mcp-install")) } @Test func installerLaunchPlanParsesOptionsAndPrefersBindir() throws { - let action = try XcodeMCPProxyInstaller.resolveLaunchAction( + let action = try XcodeMCPInstaller.resolveLaunchAction( arguments: [ - "xcode-mcp-proxy-install", + "xcode-mcp-install", "--prefix", "/tmp/prefix", "--bindir", "/tmp/bin", "--dry-run", @@ -50,7 +50,7 @@ struct InstallerFacadeTests { #expect(options.binaryDirectory == "/tmp/bin") #expect(options.dryRun == true) #expect( - XcodeMCPProxyInstaller.resolveBinDirectory( + XcodeMCPInstaller.resolveBinDirectory( prefix: options.prefix, binaryDirectory: options.binaryDirectory ).path == "/tmp/bin" @@ -59,7 +59,7 @@ struct InstallerFacadeTests { @Test func installerFacadeExpandsHomeRelativePaths() throws { let home = NSHomeDirectory() - let resolved = XcodeMCPProxyInstaller.resolveBinDirectory( + let resolved = XcodeMCPInstaller.resolveBinDirectory( prefix: "~/custom", binaryDirectory: nil ) @@ -68,8 +68,8 @@ struct InstallerFacadeTests { } @Test func installerFacadeFindsRepositoryRootFromBuildProducts() throws { - let executableURL = URL(fileURLWithPath: "/tmp/repo/.build/debug/xcode-mcp-proxy-install") - let root = XcodeMCPProxyInstaller.repositoryRoot(from: executableURL) + let executableURL = URL(fileURLWithPath: "/tmp/repo/.build/debug/xcode-mcp-install") + let root = XcodeMCPInstaller.repositoryRoot(from: executableURL) #expect(root?.path == "/tmp/repo") } @@ -80,13 +80,13 @@ struct InstallerFacadeTests { try FileManager.default.createDirectory(at: tempDir, withIntermediateDirectories: true) defer { try? FileManager.default.removeItem(at: tempDir) } - let executableURL = tempDir.appendingPathComponent("xcode-mcp-proxy-install") + let executableURL = tempDir.appendingPathComponent("xcode-mcp-install") - let bundle = tempDir.appendingPathComponent(XcodeMCPProxyInstaller.nativeHostBundleName) + let bundle = tempDir.appendingPathComponent(XcodeMCPInstaller.nativeHostBundleName) try FileManager.default.createDirectory(at: bundle, withIntermediateDirectories: true) - #expect(throws: XcodeMCPProxyInstaller.Error.self) { - try XcodeMCPProxyInstaller( + #expect(throws: XcodeMCPInstaller.Error.self) { + try XcodeMCPInstaller( configuration: .init(prefix: nil, binaryDirectory: tempDir.path, dryRun: false) ).install( executableURL: executableURL, @@ -101,7 +101,7 @@ struct InstallerFacadeTests { @Test func installerRunnerRejectsMissingOptionValues() { let result = runInstaller( arguments: [ - "xcode-mcp-proxy-install", + "xcode-mcp-install", "--bindir", ] ) @@ -114,7 +114,7 @@ struct InstallerFacadeTests { @Test func installerRunnerRejectsUnknownOptions() { let result = runInstaller( arguments: [ - "xcode-mcp-proxy-install", + "xcode-mcp-install", "--unknown", ] ) @@ -125,8 +125,8 @@ struct InstallerFacadeTests { } @Test func installerPlanUsesBinaryListAndBindirPriority() throws { - let executableURL = URL(fileURLWithPath: "/tmp/repo/.build/release/xcode-mcp-proxy-install") - let installer = XcodeMCPProxyInstaller( + let executableURL = URL(fileURLWithPath: "/tmp/repo/.build/release/xcode-mcp-install") + let installer = XcodeMCPInstaller( configuration: .init(prefix: "/tmp/prefix", binaryDirectory: "/tmp/bin", dryRun: true) ) let plan = installer.plan(executableURL: executableURL) @@ -135,9 +135,9 @@ struct InstallerFacadeTests { #expect(plan.dryRun) #expect(plan.nativeHostBundle.sourceURL.path == "/tmp/repo/.build/release/XcodeMCPNativeHost.app") #expect(plan.nativeHostBundle.destinationURL.path == "/tmp/bin/XcodeMCPNativeHost.app") - #expect(plan.binaries.map(\.name) == XcodeMCPProxyInstaller.binaryNames) + #expect(plan.binaries.map(\.name) == XcodeMCPInstaller.binaryNames) #expect( - plan.binaries.map(\.destinationURL.lastPathComponent) == ["xcode-mcp-proxy-server"]) + plan.binaries.map(\.destinationURL.lastPathComponent) == ["xcode-mcp-server"]) } } @@ -147,7 +147,7 @@ private func runInstaller( ) -> (exitCode: Int32, stdout: [String], stderr: [String]) { let output = CapturedLines() let errors = CapturedLines() - let exitCode = XcodeMCPProxyInstaller.run( + let exitCode = XcodeMCPInstaller.run( arguments: arguments, environment: environment, stdout: { output.append($0) }, diff --git a/Tests/ProxyCLITests/ProcessControlClientTests.swift b/Tests/ServerCLITests/ProcessControlClientTests.swift similarity index 99% rename from Tests/ProxyCLITests/ProcessControlClientTests.swift rename to Tests/ServerCLITests/ProcessControlClientTests.swift index df8e1398..388be617 100644 --- a/Tests/ProxyCLITests/ProcessControlClientTests.swift +++ b/Tests/ServerCLITests/ProcessControlClientTests.swift @@ -1,5 +1,5 @@ import XcodeMCPCore -@testable import XcodeMCPProxyKit +@testable import XcodeMCPServerKit import Darwin import Foundation import Testing @@ -132,7 +132,7 @@ struct ProcessControlClientTests { @Test func executableNameUsesFirstCommandTokenFromPSOutput() throws { let commandRecorder = CommandRecorder( outputs: [ - "/bin/ps|-ww -p 123 -o command=": "/tmp/xcode-mcp-proxy-server --flag\nignored\n", + "/bin/ps|-ww -p 123 -o command=": "/tmp/xcode-mcp-server --flag\nignored\n", ] ) let client = ProcessControlClient( @@ -143,7 +143,7 @@ struct ProcessControlClientTests { } ) - #expect(client.executableName(processID: 123) == "xcode-mcp-proxy-server") + #expect(client.executableName(processID: 123) == "xcode-mcp-server") #expect( commandRecorder.snapshot() == [ CommandInvocation(launchPath: "/bin/ps", arguments: ["-ww", "-p", "123", "-o", "command="]), diff --git a/Tests/ProxyCLITests/PublicRunnerTests.swift b/Tests/ServerCLITests/PublicRunnerTests.swift similarity index 66% rename from Tests/ProxyCLITests/PublicRunnerTests.swift rename to Tests/ServerCLITests/PublicRunnerTests.swift index c2b3edbc..6fad46b7 100644 --- a/Tests/ProxyCLITests/PublicRunnerTests.swift +++ b/Tests/ServerCLITests/PublicRunnerTests.swift @@ -3,28 +3,28 @@ import Foundation import Darwin import Testing import XcodeMCPKit -import XcodeMCPProxyKit +import XcodeMCPServerKit @Suite struct PublicRunnerTests { @Test func requestTimeoutDefaultsAllowFiveMinutePreviews() { #expect(XcodeMCPConfiguration().requestTimeout == .seconds(600)) - #expect(XcodeMCPProxyServerConfiguration().requestTimeout == nil) + #expect(XcodeMCPServerConfiguration().requestTimeout == nil) } @Test func serverRunnerPrintsVersionThroughPublicAPI() async throws { let output = CapturedLines() let errors = CapturedLines() - let exitCode = await XcodeMCPProxyServer.run( - arguments: ["xcode-mcp-proxy-server", "--version"], + let exitCode = await XcodeMCPServer.run( + arguments: ["xcode-mcp-server", "--version"], environment: [:], stdout: { output.append($0) }, stderr: { errors.append($0) } ) #expect(exitCode == 0) - #expect(output.snapshot() == [XcodeMCPProxyServer.productMetadata.version]) + #expect(output.snapshot() == [XcodeMCPServer.productMetadata.version]) #expect(errors.snapshot().isEmpty) } @@ -32,15 +32,15 @@ struct PublicRunnerTests { let output = CapturedLines() let errors = CapturedLines() - let exitCode = XcodeMCPProxyInstaller.run( - arguments: ["xcode-mcp-proxy-install", "--version"], + let exitCode = XcodeMCPInstaller.run( + arguments: ["xcode-mcp-install", "--version"], environment: [:], stdout: { output.append($0) }, stderr: { errors.append($0) } ) #expect(exitCode == 0) - #expect(output.snapshot() == [XcodeMCPProxyServer.productMetadata.version]) + #expect(output.snapshot() == [XcodeMCPServer.productMetadata.version]) #expect(errors.snapshot().isEmpty) } } diff --git a/Tests/ProxyCLITests/ServerCommandTests.swift b/Tests/ServerCLITests/ServerCommandTests.swift similarity index 84% rename from Tests/ProxyCLITests/ServerCommandTests.swift rename to Tests/ServerCLITests/ServerCommandTests.swift index f1c89bf2..27902ed7 100644 --- a/Tests/ProxyCLITests/ServerCommandTests.swift +++ b/Tests/ServerCLITests/ServerCommandTests.swift @@ -1,6 +1,6 @@ import Foundation import Testing -@testable import XcodeMCPProxyKit +@testable import XcodeMCPServerKit @Suite struct ServerCommandTests { @@ -15,7 +15,7 @@ struct ServerCommandTests { #expect(!(try config.runtimeConfiguration()).sharesCompilationCache) #expect(config.maxBodyBytes == 1_048_576) #expect(config.requestTimeout == nil) - #expect(config.requestTimeout == XcodeMCPProxyServerConfiguration().requestTimeout) + #expect(config.requestTimeout == XcodeMCPServerConfiguration().requestTimeout) } @Test func serverCommandMapsTypedOptionsToConfiguration() throws { @@ -64,7 +64,7 @@ struct ServerCommandTests { #expect(throws: CLICommandError.self) { _ = try resolvedConfiguration(arguments: [option, "value"]) } - #expect(!XcodeMCPProxyServer.serverUsage.contains(option + " ")) + #expect(!XcodeMCPServer.serverUsage.contains(option + " ")) } @Test func nativeSelectionIsPreservedFromTheLaunchEnvironment() throws { @@ -97,30 +97,30 @@ struct ServerCommandTests { } @Test func dryRunUsesAutomaticNativeSelection() throws { - let action = try XcodeMCPProxyServer.resolveLaunchAction( - arguments: ["xcode-mcp-proxy-server", "--dry-run"], + let action = try XcodeMCPServer.resolveLaunchAction( + arguments: ["xcode-mcp-server", "--dry-run"], environment: ["DEVELOPER_DIR": "/Applications/Selected Xcode.app"] ) guard case .dryRun(let command) = action else { Issue.record("expected dry run"); return } - #expect(command == "xcode-mcp-proxy-server --listen localhost:8765") + #expect(command == "xcode-mcp-server --listen localhost:8765") } @Test func dryRunPreservesCompilationCacheSharing() throws { - let action = try XcodeMCPProxyServer.resolveLaunchAction( - arguments: ["xcode-mcp-proxy-server", "--share-compilation-cache", "--dry-run"], + let action = try XcodeMCPServer.resolveLaunchAction( + arguments: ["xcode-mcp-server", "--share-compilation-cache", "--dry-run"], environment: [:] ) guard case .dryRun(let command) = action else { Issue.record("expected dry run"); return } - #expect(command == "xcode-mcp-proxy-server --listen localhost:8765 --share-compilation-cache") + #expect(command == "xcode-mcp-server --listen localhost:8765 --share-compilation-cache") } @Test func dryRunPreservesAutomaticApproval() throws { - let action = try XcodeMCPProxyServer.resolveLaunchAction( - arguments: ["xcode-mcp-proxy-server", "--auto-approve", "--dry-run"], + let action = try XcodeMCPServer.resolveLaunchAction( + arguments: ["xcode-mcp-server", "--auto-approve", "--dry-run"], environment: [:] ) guard case .dryRun(let command) = action else { Issue.record("expected dry run"); return } - #expect(command == "xcode-mcp-proxy-server --listen localhost:8765 --auto-approve") + #expect(command == "xcode-mcp-server --listen localhost:8765 --auto-approve") } @Test func serverCommandRejectsConflictingAddressOptions() { @@ -156,9 +156,9 @@ struct ServerCommandTests { private func resolvedConfiguration( arguments: [String] = [], environment: [String: String] = [:] -) throws -> XcodeMCPProxyServerConfiguration { - let action = try XcodeMCPProxyServer.resolveLaunchAction( - arguments: ["xcode-mcp-proxy-server"] + arguments, environment: environment +) throws -> XcodeMCPServerConfiguration { + let action = try XcodeMCPServer.resolveLaunchAction( + arguments: ["xcode-mcp-server"] + arguments, environment: environment ) guard case .start(let configuration, _) = action else { throw UnexpectedServerCommandAction() } return configuration diff --git a/Tests/ProxyCLITests/ServerLauncherIntegrationTests.swift b/Tests/ServerCLITests/ServerLauncherIntegrationTests.swift similarity index 73% rename from Tests/ProxyCLITests/ServerLauncherIntegrationTests.swift rename to Tests/ServerCLITests/ServerLauncherIntegrationTests.swift index 1f79e7f8..729b2b79 100644 --- a/Tests/ProxyCLITests/ServerLauncherIntegrationTests.swift +++ b/Tests/ServerCLITests/ServerLauncherIntegrationTests.swift @@ -1,14 +1,14 @@ import Foundation import Testing -@testable import XcodeMCPProxyKit +@testable import XcodeMCPServerKit @Suite(.serialized) struct ServerLauncherIntegrationTests { @Test func serverRunnerDryRunUsesEnvironmentDerivedDefaults() async throws { let output = CapturedLines() let errors = CapturedLines() - let exitCode = await XcodeMCPProxyServer.run( - arguments: ["xcode-mcp-proxy-server", "--dry-run"], + let exitCode = await XcodeMCPServer.run( + arguments: ["xcode-mcp-server", "--dry-run"], environment: [ "LISTEN": "127.0.0.1:7777", ], @@ -21,13 +21,13 @@ struct ServerLauncherIntegrationTests { let line = try #require(output.snapshot().first) #expect( line == - "xcode-mcp-proxy-server --listen 127.0.0.1:7777" + "xcode-mcp-server --listen 127.0.0.1:7777" ) } - @Test func serverLauncherStartsInjectedProxyServer() async throws { + @Test func serverLauncherStartsInjectedServer() async throws { let restarted = CapturedLines() - let fakeServer = IntegrationRecordingProxyServer() + let fakeServer = IntegrationRecordingServer() let launcher = makeIntegrationServerLauncher( forceRestartExistingServer: { host, port, _ in restarted.append("\(host):\(port)") @@ -41,7 +41,7 @@ struct ServerLauncherIntegrationTests { let exitCode = await launcher.run( arguments: [ - "xcode-mcp-proxy-server", + "xcode-mcp-server", "--listen", "127.0.0.1:8766", "--request-timeout", "12", "--force-restart", @@ -66,12 +66,12 @@ private func makeIntegrationServerLauncher( forceRestartExistingServer: @escaping (_ host: String, _ port: Int, _ stderr: (String) -> Void) -> Bool = { _, _, _ in false }, - makeServer: @escaping (XcodeMCPProxyServerConfiguration) -> - any XcodeMCPProxyServer.LaunchServer = { _ in - IntegrationRecordingProxyServer() + makeServer: @escaping (XcodeMCPServerConfiguration) -> + any XcodeMCPServer.LaunchServer = { _ in + IntegrationRecordingServer() } -) -> XcodeMCPProxyServer.Launcher { - XcodeMCPProxyServer.Launcher( +) -> XcodeMCPServer.Launcher { + XcodeMCPServer.Launcher( dependencies: .init( makeServer: makeServer, isAddressAlreadyInUse: { _ in false }, @@ -81,23 +81,23 @@ private func makeIntegrationServerLauncher( ) } -private final class IntegrationRecordingProxyServer: @unchecked Sendable, XcodeMCPProxyServer.LaunchServer { +private final class IntegrationRecordingServer: @unchecked Sendable, XcodeMCPServer.LaunchServer { private let lock = NSLock() - private var config: XcodeMCPProxyServerConfiguration? + private var config: XcodeMCPServerConfiguration? private var started = 0 private var waited = 0 - func record(config: XcodeMCPProxyServerConfiguration) { + func record(config: XcodeMCPServerConfiguration) { withLock { self.config = config } } - func start() async throws -> XcodeMCPProxyServer.Endpoint { + func start() async throws -> XcodeMCPServer.Endpoint { withLock { started += 1 } - return XcodeMCPProxyServer.Endpoint(host: "127.0.0.1", port: 8766) + return XcodeMCPServer.Endpoint(host: "127.0.0.1", port: 8766) } func waitUntilShutdown() async throws { @@ -106,7 +106,7 @@ private final class IntegrationRecordingProxyServer: @unchecked Sendable, XcodeM func shutdown() async throws {} - func recordedConfig() -> XcodeMCPProxyServerConfiguration? { + func recordedConfig() -> XcodeMCPServerConfiguration? { withLock { config } } diff --git a/Tests/ProxyCLITests/ServerRunnerTests.swift b/Tests/ServerCLITests/ServerRunnerTests.swift similarity index 82% rename from Tests/ProxyCLITests/ServerRunnerTests.swift rename to Tests/ServerCLITests/ServerRunnerTests.swift index 1176a194..cc41bc8c 100644 --- a/Tests/ProxyCLITests/ServerRunnerTests.swift +++ b/Tests/ServerCLITests/ServerRunnerTests.swift @@ -2,15 +2,15 @@ import XcodeMCPCore import Foundation import Testing import XcodeMCPKit -@testable import XcodeMCPProxyKit -@testable import XcodeMCPProxyRuntime +@testable import XcodeMCPServerKit +@testable import XcodeMCPServerRuntime @Suite struct ServerRunnerTests { @Test func serverLaunchPlanNormalizesServerArguments() throws { - let action = try XcodeMCPProxyServer.resolveLaunchAction( + let action = try XcodeMCPServer.resolveLaunchAction( arguments: [ - "xcode-mcp-proxy-server", + "xcode-mcp-server", "--listen", "127.0.0.1:9000", "--force-restart", @@ -25,8 +25,8 @@ struct ServerRunnerTests { } @Test func serverLaunchPlanNormalizesEnvironmentDefaults() throws { - let action = try XcodeMCPProxyServer.resolveLaunchAction( - arguments: ["xcode-mcp-proxy-server"], + let action = try XcodeMCPServer.resolveLaunchAction( + arguments: ["xcode-mcp-server"], environment: [ "HOST": "127.0.0.1", "PORT": "9999", @@ -47,14 +47,14 @@ struct ServerRunnerTests { try Data("#!/bin/sh\nexit 0\n".utf8).write(to: executable) try FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: executable.path) let developerDirectory = "/Applications/Injected Xcode.app/Contents/Developer" - let fakeServer = RecordingProxyServer() + let fakeServer = RecordingServer() let launcher = makeServerLauncher(makeServer: { configuration in fakeServer.record(config: configuration) return fakeServer }) let exitCode = await launcher.run( - arguments: ["xcode-mcp-proxy-server"], + arguments: ["xcode-mcp-server"], environment: [ "DEVELOPER_DIR": developerDirectory, "XCODE_MCP_NATIVE_HOST_BUNDLE": bundle.path, @@ -81,8 +81,8 @@ struct ServerRunnerTests { } @Test func serverLaunchPlanIgnoresRemovedXcodePIDEnvironment() throws { - let action = try XcodeMCPProxyServer.resolveLaunchAction( - arguments: ["xcode-mcp-proxy-server"], + let action = try XcodeMCPServer.resolveLaunchAction( + arguments: ["xcode-mcp-server"], environment: [ "HOST": "127.0.0.1", "PORT": "9999", @@ -97,9 +97,9 @@ struct ServerRunnerTests { } @Test func serverLaunchNormalizesOnlyZeroTimeoutToNil() throws { - let disabled = try XcodeMCPProxyServer.resolveLaunchAction( + let disabled = try XcodeMCPServer.resolveLaunchAction( arguments: [ - "xcode-mcp-proxy-server", + "xcode-mcp-server", "--request-timeout", "0", ], environment: [:] @@ -109,9 +109,9 @@ struct ServerRunnerTests { for invalid in ["-1", "nan", "inf", "not-a-number"] { #expect(throws: CLICommandError.self) { - _ = try XcodeMCPProxyServer.resolveLaunchAction( + _ = try XcodeMCPServer.resolveLaunchAction( arguments: [ - "xcode-mcp-proxy-server", + "xcode-mcp-server", "--request-timeout", invalid, ], environment: [:] @@ -122,16 +122,16 @@ struct ServerRunnerTests { @Test func serverRunnerPrintsVersion() async throws { let result = await runServer( - arguments: ["xcode-mcp-proxy-server", "--version"] + arguments: ["xcode-mcp-server", "--version"] ) #expect(result.exitCode == 0) - #expect(result.stdout == [XcodeMCPProxyServer.productMetadata.version]) + #expect(result.stdout == [XcodeMCPServer.productMetadata.version]) #expect(result.stderr.isEmpty) } @Test func serverRunnerDoesNotReinterpretAnOptionValueAsVersion() async throws { - let result = await runServer(arguments: ["xcode-mcp-proxy-server", "--listen", "--version"]) + let result = await runServer(arguments: ["xcode-mcp-server", "--listen", "--version"]) #expect(result.exitCode == 64) #expect(result.stdout.isEmpty) @@ -139,18 +139,18 @@ struct ServerRunnerTests { } @Test func serverRunnerPrintsGeneratedHelp() async throws { - let result = await runServer(arguments: ["xcode-mcp-proxy-server", "--help"]) + let result = await runServer(arguments: ["xcode-mcp-server", "--help"]) #expect(result.exitCode == 0) #expect(result.stderr.isEmpty) let line = try #require(result.stdout.first) - #expect(line.contains("USAGE: xcode-mcp-proxy-server")) + #expect(line.contains("USAGE: xcode-mcp-server")) } @Test func serverRunnerRejectsUnsupportedOptionsThroughArgumentParser() async { for option in ["--lazy-init", "--xcode-pid", "--url", "--stdio"] { let result = await runServer( - arguments: ["xcode-mcp-proxy-server", option] + arguments: ["xcode-mcp-server", option] ) #expect(result.exitCode == 64) @@ -161,7 +161,7 @@ struct ServerRunnerTests { @Test func serverLauncherInvokesForceRestartBeforeStartingInjectedServer() async throws { let restarted = CapturedLines() - let fakeServer = RecordingProxyServer() + let fakeServer = RecordingServer() let launcher = makeServerLauncher( forceRestartExistingServer: { host, port, _ in restarted.append("\(host):\(port)") @@ -175,7 +175,7 @@ struct ServerRunnerTests { let exitCode = await launcher.run( arguments: [ - "xcode-mcp-proxy-server", + "xcode-mcp-server", "--listen", "127.0.0.1:9000", "--force-restart", ], @@ -206,14 +206,14 @@ struct ServerRunnerTests { ) async throws { let effects = CapturedLines() let errors = CapturedLines() - let fakeServer = RecordingProxyServer() + let fakeServer = RecordingServer() let launcher = makeServerLauncher( forceRestartExistingServer: { _, _, _ in effects.append("terminate"); return true }, makeServer: { _ in effects.append("makeServer"); return fakeServer }, detectExistingServerProcessIDs: { _, _ in effects.append("lookup"); return [123] } ) let exitCode = await launcher.run( - arguments: ["xcode-mcp-proxy-server"] + input.arguments + ["--force-restart"], + arguments: ["xcode-mcp-server"] + input.arguments + ["--force-restart"], environment: input.environment, stdout: { _ in }, stderr: { errors.append($0) } ) @@ -229,7 +229,7 @@ struct ServerRunnerTests { ]) func publicDryRunRejectsInvalidStartupConfiguration(arguments: [String]) async throws { let result = await runServer(arguments: - ["xcode-mcp-proxy-server"] + arguments + ["--force-restart", "--dry-run"]) + ["xcode-mcp-server"] + arguments + ["--force-restart", "--dry-run"]) #expect(result.exitCode != 0) #expect(result.stdout.isEmpty) #expect(result.stderr.count == 1) @@ -238,7 +238,7 @@ struct ServerRunnerTests { @Test func serverLauncherEmitsForceRestartWarnings() async throws { let restarted = CapturedLines() let warnings = CapturedLines() - let fakeServer = RecordingProxyServer() + let fakeServer = RecordingServer() let launcher = makeServerLauncher( forceRestartExistingServer: { host, port, emitWarning in restarted.append("\(host):\(port)") @@ -253,7 +253,7 @@ struct ServerRunnerTests { let exitCode = await launcher.run( arguments: [ - "xcode-mcp-proxy-server", + "xcode-mcp-server", "--listen", "127.0.0.1:9001", "--force-restart", ], @@ -268,17 +268,17 @@ struct ServerRunnerTests { #expect(fakeServer.startCount() == 1) } - @Test func serverLauncherReportsPortInUseThroughProxyKitDiagnostic() async throws { + @Test func serverLauncherReportsPortInUseThroughServerKitDiagnostic() async throws { let errors = CapturedLines() let launcher = makeServerLauncher( - makeServer: { _ in FailingProxyServer(error: AddressAlreadyInUseError()) }, + makeServer: { _ in FailingServer(error: AddressAlreadyInUseError()) }, isAddressAlreadyInUse: { _ in true }, detectExistingServerProcessIDs: { _, _ in [321] } ) let exitCode = await launcher.run( arguments: [ - "xcode-mcp-proxy-server", + "xcode-mcp-server", "--listen", "127.0.0.1:9002", ], environment: [:], @@ -294,7 +294,7 @@ struct ServerRunnerTests { #expect(diagnostic.contains("--force-restart")) } - @Test func forceRestartLeavesNonProxyListenerRunningAndReportsPortInUse() async throws { + @Test func forceRestartLeavesNonServerListenerRunningAndReportsPortInUse() async throws { let processControl = ProcessControlClient( runCommand: { path, arguments in switch (path, arguments) { @@ -308,21 +308,21 @@ struct ServerRunnerTests { } }, sendSignal: { _, _ in - Issue.record("non-proxy listener must not receive signals") + Issue.record("non-server listener must not receive signals") return ProcessSignalResult(result: 0, errnoValue: 0) } ) - let controller = ExistingProxyServerProcessController.live(processControl: processControl) + let controller = ExistingServerProcessController.live(processControl: processControl) let errors = CapturedLines() let launcher = makeServerLauncher( forceRestartExistingServer: controller.terminateExistingServer, - makeServer: { _ in FailingProxyServer(error: AddressAlreadyInUseError()) }, + makeServer: { _ in FailingServer(error: AddressAlreadyInUseError()) }, isAddressAlreadyInUse: { _ in true }, detectExistingServerProcessIDs: controller.detectExistingServerProcessIDs ) let exitCode = await launcher.run( - arguments: ["xcode-mcp-proxy-server", "--listen", "127.0.0.1:9002", "--force-restart"], + arguments: ["xcode-mcp-server", "--listen", "127.0.0.1:9002", "--force-restart"], environment: [:], stdout: { _ in }, stderr: { errors.append($0) } @@ -337,12 +337,12 @@ struct ServerRunnerTests { @Test(arguments: [false, true]) func serverLauncherPreservesWaitAndShutdownFailures(waitFails: Bool) async throws { - let server = ShutdownFailingProxyServer(waitFails: waitFails) + let server = ShutdownFailingServer(waitFails: waitFails) let errors = CapturedLines() let launcher = makeServerLauncher(makeServer: { _ in server }) let exitCode = await launcher.run( - arguments: ["xcode-mcp-proxy-server", "--listen", "127.0.0.1:9002"], + arguments: ["xcode-mcp-server", "--listen", "127.0.0.1:9002"], environment: [:], stdout: { _ in }, stderr: { errors.append($0) } @@ -358,10 +358,10 @@ struct ServerRunnerTests { @Test(.timeLimit(.minutes(1))) func aTerminationSignalShutsTheServerDown() async throws { - let server = SignalStoppedProxyServer() + let server = SignalStoppedServer() let handlers = LockedBox<[@Sendable () -> Void]>([]) let observing = LockedBox(false) - let launcher = XcodeMCPProxyServer.Launcher(dependencies: .init( + let launcher = XcodeMCPServer.Launcher(dependencies: .init( makeServer: { _ in server }, isAddressAlreadyInUse: { _ in false }, observeTerminationSignals: { handler in @@ -372,7 +372,7 @@ struct ServerRunnerTests { )) let running = Task { - await launcher.run(arguments: ["xcode-mcp-proxy-server", "--listen", "127.0.0.1:9003"], + await launcher.run(arguments: ["xcode-mcp-server", "--listen", "127.0.0.1:9003"], environment: [:], stdout: { _ in }, stderr: { _ in }) } while handlers.snapshot().isEmpty { await Task.yield() } @@ -386,10 +386,10 @@ struct ServerRunnerTests { /// A failed cleanup still fails the run. @Test(.timeLimit(.minutes(1)), arguments: [false, true]) func aTerminationSignalDuringStartupShutsTheServerDown(cleanupFails: Bool) async throws { - let server = StartBlockingProxyServer(cleanupFails: cleanupFails) + let server = StartBlockingServer(cleanupFails: cleanupFails) let errors = CapturedLines() let handlers = LockedBox<[@Sendable () -> Void]>([]) - let launcher = XcodeMCPProxyServer.Launcher(dependencies: .init( + let launcher = XcodeMCPServer.Launcher(dependencies: .init( makeServer: { _ in server }, isAddressAlreadyInUse: { _ in false }, observeTerminationSignals: { handler in @@ -399,7 +399,7 @@ struct ServerRunnerTests { )) let running = Task { - await launcher.run(arguments: ["xcode-mcp-proxy-server", "--listen", "127.0.0.1:9004"], + await launcher.run(arguments: ["xcode-mcp-server", "--listen", "127.0.0.1:9004"], environment: [:], stdout: { _ in }, stderr: { errors.append($0) }) } while handlers.snapshot().isEmpty || !server.isStarting { await Task.yield() } @@ -411,19 +411,19 @@ struct ServerRunnerTests { } @Test func startupCleanupFailureIsNotReplacedByPortInUseDiagnostic() async throws { - let error = XcodeMCPProxyServer.CleanupError( + let error = XcodeMCPServer.CleanupError( operationError: AddressAlreadyInUseError(), cleanupError: LaunchCleanupFailure.expected, endpoint: nil ) let errors = CapturedLines() let launcher = makeServerLauncher( - makeServer: { _ in FailingProxyServer(error: error) }, + makeServer: { _ in FailingServer(error: error) }, isAddressAlreadyInUse: { _ in true } ) let exitCode = await launcher.run( - arguments: ["xcode-mcp-proxy-server"], + arguments: ["xcode-mcp-server"], environment: [:], stdout: { _ in }, stderr: { errors.append($0) } @@ -437,7 +437,7 @@ struct ServerRunnerTests { @Test func serverRunnerDryRunPrintsResolvedCommandFromLaunchPlan() async throws { let result = await runServer( - arguments: ["xcode-mcp-proxy-server", "--dry-run"], + arguments: ["xcode-mcp-server", "--dry-run"], environment: [ "HOST": "127.0.0.1", "PORT": "9999", @@ -455,15 +455,15 @@ struct ServerRunnerTests { @Test func serverRunnerRejectsRemovedXcodeMode() async { - let result = await runServer(arguments: ["xcode-mcp-proxy-server", "--xcode-mode", "headless", "--dry-run"]) + let result = await runServer(arguments: ["xcode-mcp-server", "--xcode-mode", "headless", "--dry-run"]) #expect(result.exitCode != 0) #expect(result.stderr.joined().contains("xcode-mode")) } @Test func serverLaunchPlanHonorsDryRunEnvironment() throws { for value in ["1", "true", "TRUE", "yes", "on", " ON "] { - let action = try XcodeMCPProxyServer.resolveLaunchAction( - arguments: ["xcode-mcp-proxy-server"], + let action = try XcodeMCPServer.resolveLaunchAction( + arguments: ["xcode-mcp-server"], environment: ["DRY_RUN": value] ) @@ -477,7 +477,7 @@ struct ServerRunnerTests { @Test func serverRunnerPreservesExplicitHelpBeforeLaterParseErrors() async throws { let result = await runServer( arguments: [ - "xcode-mcp-proxy-server", + "xcode-mcp-server", "--help", "--url", ] @@ -495,7 +495,7 @@ private func runServer( ) async -> (exitCode: Int32, stdout: [String], stderr: [String]) { let output = CapturedLines() let errors = CapturedLines() - let exitCode = await XcodeMCPProxyServer.run( + let exitCode = await XcodeMCPServer.run( arguments: arguments, environment: environment, stdout: { output.append($0) }, @@ -561,14 +561,14 @@ private func makeServerLauncher( _, _, _ in false }, makeServer: - @escaping (XcodeMCPProxyServerConfiguration) -> - any XcodeMCPProxyServer.LaunchServer = { _ in - RecordingProxyServer() + @escaping (XcodeMCPServerConfiguration) -> + any XcodeMCPServer.LaunchServer = { _ in + RecordingServer() }, isAddressAlreadyInUse: @escaping (Swift.Error) -> Bool = { _ in false }, detectExistingServerProcessIDs: @escaping (_ host: String, _ port: Int) -> [Int] = { _, _ in [] } -) -> XcodeMCPProxyServer.Launcher { - XcodeMCPProxyServer.Launcher( +) -> XcodeMCPServer.Launcher { + XcodeMCPServer.Launcher( dependencies: .init( makeServer: makeServer, isAddressAlreadyInUse: isAddressAlreadyInUse, @@ -579,8 +579,8 @@ private func makeServerLauncher( } private func startPayload( - _ action: XcodeMCPProxyServer.LaunchAction -) throws -> (XcodeMCPProxyServerConfiguration, Bool) { + _ action: XcodeMCPServer.LaunchAction +) throws -> (XcodeMCPServerConfiguration, Bool) { guard case .start(let configuration, let forceRestart) = action else { throw UnexpectedServerLaunchAction() } @@ -601,14 +601,14 @@ private enum LaunchWaitFailure: Error, CustomStringConvertible { var description: String { "listener wait failed" } } -private final class ShutdownFailingProxyServer: XcodeMCPProxyServer.LaunchServer { +private final class ShutdownFailingServer: XcodeMCPServer.LaunchServer { private let waitFails: Bool private let shutdowns = LockedBox(0) init(waitFails: Bool) { self.waitFails = waitFails } var shutdownCount: Int { shutdowns.snapshot() } - func start() async throws -> XcodeMCPProxyServer.Endpoint { + func start() async throws -> XcodeMCPServer.Endpoint { .init(host: "127.0.0.1", port: 9002) } @@ -623,7 +623,7 @@ private final class ShutdownFailingProxyServer: XcodeMCPProxyServer.LaunchServer } /// Starts only after it is shut down, which ends the start with an error. -private final class StartBlockingProxyServer: XcodeMCPProxyServer.LaunchServer { +private final class StartBlockingServer: XcodeMCPServer.LaunchServer { private let stops = AsyncStream.makeStream() private let state = LockedBox((starting: false, shutdowns: 0)) private let cleanupFails: Bool @@ -633,10 +633,10 @@ private final class StartBlockingProxyServer: XcodeMCPProxyServer.LaunchServer { var isStarting: Bool { state.snapshot().starting } var shutdownCount: Int { state.snapshot().shutdowns } - func start() async throws -> XcodeMCPProxyServer.Endpoint { + func start() async throws -> XcodeMCPServer.Endpoint { state.withValue { $0.starting = true } for await _ in stops.stream {} - throw XcodeMCPProxyServer.LifecycleError.shutdownInProgress + throw XcodeMCPServer.LifecycleError.shutdownInProgress } func waitUntilShutdown() async throws { @@ -651,13 +651,13 @@ private final class StartBlockingProxyServer: XcodeMCPProxyServer.LaunchServer { } /// Waits until it is shut down. -private final class SignalStoppedProxyServer: XcodeMCPProxyServer.LaunchServer { +private final class SignalStoppedServer: XcodeMCPServer.LaunchServer { private let stops = AsyncStream.makeStream() private let shutdowns = LockedBox(0) var shutdownCount: Int { shutdowns.snapshot() } - func start() async throws -> XcodeMCPProxyServer.Endpoint { + func start() async throws -> XcodeMCPServer.Endpoint { .init(host: "127.0.0.1", port: 9003) } @@ -671,14 +671,14 @@ private final class SignalStoppedProxyServer: XcodeMCPProxyServer.LaunchServer { } } -private final class FailingProxyServer: XcodeMCPProxyServer.LaunchServer { +private final class FailingServer: XcodeMCPServer.LaunchServer { private let error: any Error init(error: any Error) { self.error = error } - func start() async throws -> XcodeMCPProxyServer.Endpoint { + func start() async throws -> XcodeMCPServer.Endpoint { throw error } @@ -689,22 +689,22 @@ private final class FailingProxyServer: XcodeMCPProxyServer.LaunchServer { func shutdown() async throws {} } -private final class RecordingProxyServer: XcodeMCPProxyServer.LaunchServer { +private final class RecordingServer: XcodeMCPServer.LaunchServer { private let state = LockedBox( - (config: Optional.none, startCount: 0, waitCount: 0) + (config: Optional.none, startCount: 0, waitCount: 0) ) - func record(config: XcodeMCPProxyServerConfiguration) { + func record(config: XcodeMCPServerConfiguration) { state.withValue { value in value.config = config } } - func start() async throws -> XcodeMCPProxyServer.Endpoint { + func start() async throws -> XcodeMCPServer.Endpoint { state.withValue { value in value.startCount += 1 } - return XcodeMCPProxyServer.Endpoint(host: "127.0.0.1", port: 8765) + return XcodeMCPServer.Endpoint(host: "127.0.0.1", port: 8765) } func waitUntilShutdown() async throws { @@ -715,7 +715,7 @@ private final class RecordingProxyServer: XcodeMCPProxyServer.LaunchServer { func shutdown() async throws {} - func recordedConfig() -> XcodeMCPProxyServerConfiguration? { + func recordedConfig() -> XcodeMCPServerConfiguration? { state.snapshot().config } diff --git a/Tests/ProxyIntegrationTests/AsyncTestSupportCancellationTests.swift b/Tests/ServerIntegrationTests/AsyncTestSupportCancellationTests.swift similarity index 98% rename from Tests/ProxyIntegrationTests/AsyncTestSupportCancellationTests.swift rename to Tests/ServerIntegrationTests/AsyncTestSupportCancellationTests.swift index b9942af8..e4cc3263 100644 --- a/Tests/ProxyIntegrationTests/AsyncTestSupportCancellationTests.swift +++ b/Tests/ServerIntegrationTests/AsyncTestSupportCancellationTests.swift @@ -1,5 +1,5 @@ import Testing -import XcodeMCPProxyTestSupport +import XcodeMCPServerTestSupport @Suite(.asyncTestCleanup) struct AsyncTestSupportCancellationTests { diff --git a/Tests/ProxyIntegrationTests/ConfigurationRuntimeTests.swift b/Tests/ServerIntegrationTests/ConfigurationRuntimeTests.swift similarity index 83% rename from Tests/ProxyIntegrationTests/ConfigurationRuntimeTests.swift rename to Tests/ServerIntegrationTests/ConfigurationRuntimeTests.swift index 9a103d61..a843894f 100644 --- a/Tests/ProxyIntegrationTests/ConfigurationRuntimeTests.swift +++ b/Tests/ServerIntegrationTests/ConfigurationRuntimeTests.swift @@ -1,17 +1,17 @@ import Foundation import Testing import XcodeMCPCore -import XcodeMCPProxyRuntimeContract -import XcodeMCPProxyTestSupport -@testable import XcodeMCPProxyRuntime -@testable import XcodeMCPProxyKit -@testable import XcodeMCPProxyRuntimeTestSupport +import XcodeMCPServerRuntimeContract +import XcodeMCPServerTestSupport +@testable import XcodeMCPServerRuntime +@testable import XcodeMCPServerKit +@testable import XcodeMCPServerRuntimeTestSupport @Suite(.serialized, .asyncTestCleanup) struct ConfigurationRuntimeTests { /// Starts the default host and returns the `initialize` parameters it received. private func hostInitializeParameters( - _ configuration: XcodeMCPProxyServerConfiguration, + _ configuration: XcodeMCPServerConfiguration, beforeStart: (NativeHostBroker) async throws -> Void = { _ in } ) async throws -> [String: Any] { let factory = FakeHostSessionFactory() @@ -34,10 +34,10 @@ struct ConfigurationRuntimeTests { return try #require(params.foundationObject as? [String: Any]) } - @Test func hostReceivesTheProxyHandshakeRatherThanTheClientParameters() async throws { - let params = try await hostInitializeParameters(XcodeMCPProxyServerConfiguration( + @Test func hostReceivesTheServerHandshakeRatherThanTheClientParameters() async throws { + let params = try await hostInitializeParameters(XcodeMCPServerConfiguration( requestTimeout: .seconds(5), prewarmToolsList: false)) { broker in - let request = try ProxyRuntimeRequest(json: .object([ + let request = try ServerRuntimeRequest(json: .object([ "jsonrpc": .string("2.0"), "id": .number(.int(1)), "method": .string("initialize"), "params": .object([ "protocolVersion": .string("2099-01-01"), @@ -45,7 +45,7 @@ struct ConfigurationRuntimeTests { "clientInfo": .object(["name": .string("downstream-client"), "version": .string("9.9")]), ]), ])) - let session = try broker.openSession(ProxySessionID(rawValue: "downstream")) { _ in } + let session = try broker.openSession(ServerSessionID(rawValue: "downstream")) { _ in } _ = await session.receive(request).reply session.close() } diff --git a/Tests/ProxyIntegrationTests/DiscoveryTests.swift b/Tests/ServerIntegrationTests/DiscoveryTests.swift similarity index 98% rename from Tests/ProxyIntegrationTests/DiscoveryTests.swift rename to Tests/ServerIntegrationTests/DiscoveryTests.swift index 83dfd3cd..380f50f0 100644 --- a/Tests/ProxyIntegrationTests/DiscoveryTests.swift +++ b/Tests/ServerIntegrationTests/DiscoveryTests.swift @@ -2,7 +2,7 @@ import Foundation import Testing import XcodeMCPKit -@testable import XcodeMCPProxyKit +@testable import XcodeMCPServerKit @Suite diff --git a/Tests/ProxyIntegrationTests/DocumentationSearchRoutingTests.swift b/Tests/ServerIntegrationTests/DocumentationSearchRoutingTests.swift similarity index 97% rename from Tests/ProxyIntegrationTests/DocumentationSearchRoutingTests.swift rename to Tests/ServerIntegrationTests/DocumentationSearchRoutingTests.swift index 06b0b889..2af3e0b9 100644 --- a/Tests/ProxyIntegrationTests/DocumentationSearchRoutingTests.swift +++ b/Tests/ServerIntegrationTests/DocumentationSearchRoutingTests.swift @@ -1,4 +1,4 @@ -@testable import XcodeMCPProxyRuntimeTestSupport +@testable import XcodeMCPServerRuntimeTestSupport @testable import XcodeMCPCore import Foundation import NIO @@ -7,9 +7,9 @@ import NIOEmbedded import NIOHTTP1 import Testing import XcodeMCPKit -@testable import XcodeMCPProxyHTTP -@testable import XcodeMCPProxyRuntime -import XcodeMCPProxyTestSupport +@testable import XcodeMCPServerHTTP +@testable import XcodeMCPServerRuntime +import XcodeMCPServerTestSupport extension HTTPHandlerTests { @Test func httpDocumentationSearchIsForwardedToNativeHost() async throws { diff --git a/Tests/ProxyIntegrationTests/HTTPConcurrencyTests.swift b/Tests/ServerIntegrationTests/HTTPConcurrencyTests.swift similarity index 99% rename from Tests/ProxyIntegrationTests/HTTPConcurrencyTests.swift rename to Tests/ServerIntegrationTests/HTTPConcurrencyTests.swift index d83e0b56..95a63589 100644 --- a/Tests/ProxyIntegrationTests/HTTPConcurrencyTests.swift +++ b/Tests/ServerIntegrationTests/HTTPConcurrencyTests.swift @@ -1,5 +1,5 @@ -@testable import XcodeMCPProxyRuntimeTestSupport -import XcodeMCPProxyRuntimeContract +@testable import XcodeMCPServerRuntimeTestSupport +import XcodeMCPServerRuntimeContract @testable import XcodeMCPCore import Foundation import NIO @@ -7,9 +7,9 @@ import NIOConcurrencyHelpers import NIOHTTP1 import Testing import XcodeMCPKit -@testable import XcodeMCPProxyHTTP -@testable import XcodeMCPProxyRuntime -import XcodeMCPProxyTestSupport +@testable import XcodeMCPServerHTTP +@testable import XcodeMCPServerRuntime +import XcodeMCPServerTestSupport @Suite(.serialized, .asyncTestCleanup) struct HTTPConcurrencyTests { @@ -557,7 +557,7 @@ struct HTTPConcurrencyTests { timeout: .seconds(2) ) { try await server.controlService.waitForSSEClient( - sessionID: ProxySessionID(rawValue: sessionID) + sessionID: ServerSessionID(rawValue: sessionID) ) } @@ -665,7 +665,7 @@ private func initializePayload(id: Int) -> [String: Any] { "protocolVersion": "2025-06-18", "capabilities": [String: Any](), "clientInfo": [ - "name": "xcode-mcp-proxy-concurrency-tests", + "name": "xcode-mcp-server-concurrency-tests", "version": "0.0", ], ], diff --git a/Tests/ProxyIntegrationTests/HTTPHandlerTestSupport.swift b/Tests/ServerIntegrationTests/HTTPHandlerTestSupport.swift similarity index 97% rename from Tests/ProxyIntegrationTests/HTTPHandlerTestSupport.swift rename to Tests/ServerIntegrationTests/HTTPHandlerTestSupport.swift index d5cd2117..698f501d 100644 --- a/Tests/ProxyIntegrationTests/HTTPHandlerTestSupport.swift +++ b/Tests/ServerIntegrationTests/HTTPHandlerTestSupport.swift @@ -1,5 +1,5 @@ -import XcodeMCPProxyRuntimeContract -@testable import XcodeMCPProxyRuntimeTestSupport +import XcodeMCPServerRuntimeContract +@testable import XcodeMCPServerRuntimeTestSupport @testable import XcodeMCPCore import Foundation import NIO @@ -8,16 +8,16 @@ import NIOEmbedded import NIOHTTP1 import Testing import XcodeMCPKit -@testable import XcodeMCPProxyHTTP -@testable import XcodeMCPProxyRuntime -import XcodeMCPProxyTestSupport +@testable import XcodeMCPServerHTTP +@testable import XcodeMCPServerRuntime +import XcodeMCPServerTestSupport enum HTTPTestError: Error { case missingResponseHead } struct HTTPTestConfiguration: Sendable { - var runtime: ProxyRuntimeConfiguration + var runtime: ServerRuntimeConfiguration var listenHost: String var listenPort: Int var maxBodyBytes: Int @@ -90,7 +90,7 @@ final class HTTPTestRuntime: Sendable { var startedHostCount: Int { hosts.sessions.withLockedValue { $0.count } } func hasSession(_ id: String) -> Bool { - controlService.sessions.phase(of: ProxySessionID(rawValue: id)) != nil + controlService.sessions.phase(of: ServerSessionID(rawValue: id)) != nil } /// Waits until the hosts have received `count` tool calls. @@ -129,7 +129,7 @@ func makeHTTPConfig( requestTimeout: Duration? = .seconds(1) ) -> HTTPTestConfiguration { HTTPTestConfiguration( - runtime: ProxyRuntimeConfiguration( + runtime: ServerRuntimeConfiguration( maxMessageBytes: maxBodyBytes, requestTimeout: requestTimeout ), @@ -170,7 +170,7 @@ func addHTTPHandler( scheduleResponseCompletion: (@Sendable (EventLoop, @escaping @Sendable () -> Void) -> Void)? = nil ) async throws { - let httpConfig = ProxyHTTPConfiguration( + let httpConfig = ServerHTTPConfiguration( listenHost: config.listenHost, listenPort: config.listenPort, maxBodyBytes: config.maxBodyBytes, @@ -317,10 +317,10 @@ struct TestHTTPHandlerServer { .serverChannelOption(ChannelOptions.backlog, value: 256) .serverChannelOption(ChannelOptions.socketOption(.so_reuseaddr), value: 1) .childChannelInitializer { channel in - ProxyHTTPChildChannelInitializer.configure( + ServerHTTPChildChannelInitializer.configure( channel.pipeline, handler: HTTPHandler( - config: ProxyHTTPConfiguration( + config: ServerHTTPConfiguration( listenHost: config.listenHost, listenPort: config.listenPort, maxBodyBytes: config.maxBodyBytes, diff --git a/Tests/ProxyIntegrationTests/HTTPHandlerTests.swift b/Tests/ServerIntegrationTests/HTTPHandlerTests.swift similarity index 99% rename from Tests/ProxyIntegrationTests/HTTPHandlerTests.swift rename to Tests/ServerIntegrationTests/HTTPHandlerTests.swift index f67a996d..db8bf411 100644 --- a/Tests/ProxyIntegrationTests/HTTPHandlerTests.swift +++ b/Tests/ServerIntegrationTests/HTTPHandlerTests.swift @@ -1,4 +1,4 @@ -@testable import XcodeMCPProxyRuntimeTestSupport +@testable import XcodeMCPServerRuntimeTestSupport @testable import XcodeMCPCore import Foundation import NIO @@ -7,10 +7,10 @@ import NIOEmbedded import NIOHTTP1 import Testing import XcodeMCPKit -@testable import XcodeMCPProxyHTTP -@testable import XcodeMCPProxyRuntime -import XcodeMCPProxyRuntimeContract -import XcodeMCPProxyTestSupport +@testable import XcodeMCPServerHTTP +@testable import XcodeMCPServerRuntime +import XcodeMCPServerRuntimeContract +import XcodeMCPServerTestSupport @Suite(.serialized, .asyncTestCleanup) struct HTTPHandlerTests { @@ -1045,7 +1045,7 @@ struct HTTPHandlerTests { "protocolVersion": "2025-06-18", "capabilities": [String: Any](), "clientInfo": [ - "name": "xcode-mcp-proxy-tests", + "name": "xcode-mcp-server-tests", "version": "0.0", ], ], @@ -1074,7 +1074,7 @@ struct HTTPHandlerTests { let result = responseObject?["result"] as? [String: Any] #expect(result?["protocolVersion"] as? String == MCP.ProtocolVersion.current) #expect( - runtime.controlService.sessions.phase(of: ProxySessionID(rawValue: sessionID)) + runtime.controlService.sessions.phase(of: ServerSessionID(rawValue: sessionID)) == .initialized(protocolVersion: MCP.ProtocolVersion.current) ) // The broker answers initialize itself; no host process starts for it. @@ -1112,7 +1112,7 @@ struct HTTPHandlerTests { #expect((error["code"] as? NSNumber)?.intValue == -32001) #expect(error["message"] as? String == "host unavailable") #expect( - runtime.controlService.sessions.phase(of: ProxySessionID(rawValue: sessionID)) + runtime.controlService.sessions.phase(of: ServerSessionID(rawValue: sessionID)) == .initialized(protocolVersion: MCP.ProtocolVersion.current) ) @@ -1140,7 +1140,7 @@ struct HTTPHandlerTests { let sessionID = try await initializeHTTPChannel(channel) let payload: [String: Any] = [ "jsonrpc": "2.0", - "id": "xcode-mcp-proxy.server-request.999", + "id": "xcode-mcp-server.server-request.999", "result": ["ok": true], ] try await postJSON(payload, sessionID: sessionID, to: channel) @@ -1190,7 +1190,7 @@ struct HTTPHandlerTests { "protocolVersion": "2025-06-18", "capabilities": [String: Any](), "clientInfo": [ - "name": "xcode-mcp-proxy-tests", + "name": "xcode-mcp-server-tests", "version": "0.0", ], ], @@ -1224,7 +1224,7 @@ struct HTTPHandlerTests { "protocolVersion": "2025-06-18", "capabilities": [String: Any](), "clientInfo": [ - "name": "xcode-mcp-proxy-tests", + "name": "xcode-mcp-server-tests", "version": "0.0", ], ], @@ -1264,7 +1264,7 @@ struct HTTPHandlerTests { "protocolVersion": "2025-06-18", "capabilities": [String: Any](), "clientInfo": [ - "name": "xcode-mcp-proxy-tests", + "name": "xcode-mcp-server-tests", "version": "0.0", ], ], @@ -1589,7 +1589,7 @@ struct HTTPHandlerTests { #expect(runtime.host?.requests("tools/list").count == 1) } - @Test func httpToolsListPublishesTheProxyDescriptionOfNativeTools() async throws { + @Test func httpToolsListPublishesTheServerDescriptionOfNativeTools() async throws { let nativeTools = JSONValue.object(["tools": .array([ .object([ "name": .string("XcodeRefreshCodeIssuesInFile"), diff --git a/Tests/ServerIntegrationTests/XcodeMCPServerBuildInfoTests.swift b/Tests/ServerIntegrationTests/XcodeMCPServerBuildInfoTests.swift new file mode 100644 index 00000000..1c3dc4d9 --- /dev/null +++ b/Tests/ServerIntegrationTests/XcodeMCPServerBuildInfoTests.swift @@ -0,0 +1,20 @@ +import XcodeMCPServerRuntimeContract +@testable import XcodeMCPCore +import Testing +import XcodeMCPKit +@testable import XcodeMCPServerKit +import XcodeMCPServerRuntime + +@Suite +struct XcodeMCPServerBuildInfoTests { + @Test func startupSummaryDescribesHeadlessOperation() { + let summary = XcodeMCPServer.startupSummary(displayHost: "localhost", port: 8765) + #expect(summary == """ + XcodeMCPServerKit \(XcodeMCPServer.productMetadata.version) + + Server + URL: http://localhost:8765/mcp + Xcode mode: headless (saved project files) + """) + } +} diff --git a/Tests/ProxyIntegrationTests/XcodeMCPProxyServerTests.swift b/Tests/ServerIntegrationTests/XcodeMCPServerTests.swift similarity index 88% rename from Tests/ProxyIntegrationTests/XcodeMCPProxyServerTests.swift rename to Tests/ServerIntegrationTests/XcodeMCPServerTests.swift index 30f27fc8..3b4f1b35 100644 --- a/Tests/ProxyIntegrationTests/XcodeMCPProxyServerTests.swift +++ b/Tests/ServerIntegrationTests/XcodeMCPServerTests.swift @@ -1,20 +1,20 @@ -import XcodeMCPProxyRuntimeContract +import XcodeMCPServerRuntimeContract @testable import XcodeMCPCore import Dispatch import Foundation import NIO import NIOConcurrencyHelpers import XcodeMCPKit -@testable import XcodeMCPProxyHTTP -@testable import XcodeMCPProxyKit -@testable import XcodeMCPProxyRuntime -@testable import XcodeMCPProxyRuntimeTestSupport +@testable import XcodeMCPServerHTTP +@testable import XcodeMCPServerKit +@testable import XcodeMCPServerRuntime +@testable import XcodeMCPServerRuntimeTestSupport import Testing -import XcodeMCPProxyTestSupport +import XcodeMCPServerTestSupport -struct XcodeMCPProxyServerTests { +struct XcodeMCPServerTests { @Test func endpointURLBracketsIPv6LiteralHosts() { - let endpoint = XcodeMCPProxyServer.Endpoint(host: "::1", port: 8765) + let endpoint = XcodeMCPServer.Endpoint(host: "::1", port: 8765) #expect(endpoint.host == "::1") #expect(endpoint.port == 8765) @@ -22,12 +22,12 @@ struct XcodeMCPProxyServerTests { } @Test func endpointURLPreservesNonIPv6Hosts() { - let endpoint = XcodeMCPProxyServer.Endpoint(host: "127.0.0.1", port: 8765) + let endpoint = XcodeMCPServer.Endpoint(host: "127.0.0.1", port: 8765) #expect(endpoint.url.absoluteString == "http://127.0.0.1:8765/mcp") } - @Test func existingServerControllerDetectsOnlyListeningProxyServerProcesses() throws { + @Test func existingServerControllerDetectsOnlyListeningServerProcesses() throws { let processControl = ProcessControlClient( runCommand: { launchPath, arguments in switch (launchPath, arguments) { @@ -41,7 +41,7 @@ struct XcodeMCPProxyServerTests { n127.0.0.1:8765 """ case ("/bin/ps", ["-ww", "-p", "456", "-o", "command="]): - return "/usr/local/bin/xcode-mcp-proxy-server --listen localhost:8765\n" + return "/usr/local/bin/xcode-mcp-server --listen localhost:8765\n" case ("/bin/ps", ["-ww", "-p", "789", "-o", "command="]): return "/usr/bin/python3 other-server.py\n" default: @@ -54,7 +54,7 @@ struct XcodeMCPProxyServerTests { return ProcessSignalResult(result: -1, errnoValue: ESRCH) } ) - let controller = ExistingProxyServerProcessController.live( + let controller = ExistingServerProcessController.live( currentProcessID: { 999 }, processControl: processControl ) @@ -65,7 +65,7 @@ struct XcodeMCPProxyServerTests { @Test(arguments: ["localhost", "my-mac.local"]) func forceRestartTerminatesOnlyTheRequestedEndpointOwners(host: String) { let processes = RestartProcessFixture() - let controller = ExistingProxyServerProcessController.live( + let controller = ExistingServerProcessController.live( clock: processes.clock, currentProcessID: { 999 }, processControl: processes.client @@ -82,7 +82,7 @@ struct XcodeMCPProxyServerTests { @Test func forceRestartRechecksLaterPIDAfterEarlierTermination() { let processes = RestartProcessFixture(reuseSecondPIDOnTermination: true) - let controller = ExistingProxyServerProcessController.live( + let controller = ExistingServerProcessController.live( clock: processes.clock, currentProcessID: { 999 }, processControl: processes.client @@ -98,7 +98,7 @@ struct XcodeMCPProxyServerTests { } @Test func portInUseDiagnosticFormatsMessage() throws { - let message = XcodeMCPProxyServer.PortInUseError( + let message = XcodeMCPServer.PortInUseError( host: "::1", port: 8765, processIdentifiers: [111, 222] @@ -119,13 +119,13 @@ struct XcodeMCPProxyServerTests { let blockedPort = try #require(blocker.localAddress?.port) let runtime = StartupTestRuntime() - let config = XcodeMCPProxyServerConfiguration( + let config = XcodeMCPServerConfiguration( bindAddress: .init(host: "127.0.0.1", port: blockedPort), maxBodyBytes: 1_048_576, requestTimeout: .seconds(300) ) - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: config, dependencies: .init( discoveryClient: .testValue, @@ -146,11 +146,11 @@ struct XcodeMCPProxyServerTests { } @Test func nativeStartupPreservesInstallationSelection() async throws { - let runtimeConfiguration = NIOLockedValueBox(nil) + let runtimeConfiguration = NIOLockedValueBox(nil) let runtime = StartupTestRuntime() let bundleURL = URL(fileURLWithPath: "/fixtures/XcodeMCPNativeHost.app") let developerURL = URL(fileURLWithPath: "/fixtures/Xcode.app/Contents/Developer") - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: .init( bindAddress: .init(host: "127.0.0.1", port: 0), nativeHostBundleURL: bundleURL, @@ -175,7 +175,7 @@ struct XcodeMCPProxyServerTests { @Test func unavailableNativeHelperFailsStartupBeforeBindingTheEndpoint() async throws { let missingBundle = FileManager.default.temporaryDirectory .appendingPathComponent("missing-native-host-\(UUID().uuidString).app") - let server = XcodeMCPProxyServer(configuration: .init( + let server = XcodeMCPServer(configuration: .init( bindAddress: .localhost(port: 0), nativeHostBundleURL: missingBundle, discovery: .disabled )) await #expect(throws: MCPRuntimeError.self) { _ = try await server.start() } @@ -187,14 +187,14 @@ struct XcodeMCPProxyServerTests { } @Test(arguments: [ - XcodeMCPProxyServerConfiguration.ApprovalPolicy.manual, .automatic, + XcodeMCPServerConfiguration.ApprovalPolicy.manual, .automatic, ]) func automaticApprovalFollowsTheServerLifetime( - policy: XcodeMCPProxyServerConfiguration.ApprovalPolicy + policy: XcodeMCPServerConfiguration.ApprovalPolicy ) async throws { let approver = RecordingPermissionDialogAutoApprover() let creations = NIOLockedValueBox(0) - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: .init( bindAddress: .localhost(port: 0), discovery: .disabled, approvalPolicy: policy ), @@ -219,13 +219,13 @@ struct XcodeMCPProxyServerTests { @Test func startRejectsRepeatedStartsOnSameServerInstance() async throws { let hosts = FakeHostSessionFactory() - let config = XcodeMCPProxyServerConfiguration( + let config = XcodeMCPServerConfiguration( bindAddress: .init(host: "127.0.0.1", port: 0), maxBodyBytes: 1_048_576, requestTimeout: .seconds(300) ) - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: config, dependencies: .init( discoveryClient: .testValue, @@ -238,7 +238,7 @@ struct XcodeMCPProxyServerTests { let endpoint = try await server.start() #expect(endpoint.port > 0) - await #expect(throws: XcodeMCPProxyServer.LifecycleError.alreadyStarted) { + await #expect(throws: XcodeMCPServer.LifecycleError.alreadyStarted) { _ = try await server.start() } @@ -253,7 +253,7 @@ struct XcodeMCPProxyServerTests { @Test func unstartedServerDoesNotCreateHTTPGateway() async throws { let gatewayCreationCount = NIOLockedValueBox(0) - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: .init(discovery: .disabled), dependencies: .init( makeRuntime: { _ in @@ -275,7 +275,7 @@ struct XcodeMCPProxyServerTests { @Test func startedServerDeinitCancelsTheRuntimeHostProcess() async throws { let hosts = FakeHostSessionFactory() let approver = RecordingPermissionDialogAutoApprover() - var server: XcodeMCPProxyServer? = XcodeMCPProxyServer( + var server: XcodeMCPServer? = XcodeMCPServer( configuration: .init( bindAddress: .init(host: "127.0.0.1", port: 0), discovery: .disabled, @@ -308,7 +308,7 @@ struct XcodeMCPProxyServerTests { @Test func zeroRequestTimeoutFailsBeforeResourceAcquisition() async throws { let gatewayCreationCount = NIOLockedValueBox(0) - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: .init( requestTimeout: .zero, discovery: .disabled @@ -324,7 +324,7 @@ struct XcodeMCPProxyServerTests { ) ) - await #expect(throws: XcodeMCPProxyServer.LifecycleError.self) { + await #expect(throws: XcodeMCPServer.LifecycleError.self) { _ = try await server.start() } #expect(gatewayCreationCount.withLockedValue { $0 } == 0) @@ -338,7 +338,7 @@ struct XcodeMCPProxyServerTests { throw DiscoveryWriteFailure.expected } let runtime = StartupTestRuntime() - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: .init( bindAddress: .init(host: "127.0.0.1", port: 0), discovery: .file(URL(fileURLWithPath: "/unused/discovery.json")) @@ -373,7 +373,7 @@ struct XcodeMCPProxyServerTests { if discoveryFails { discovery.write = { _, _ in throw DiscoveryWriteFailure.expected } } - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: .init(), dependencies: .init( discoveryClient: discovery, @@ -397,7 +397,7 @@ struct XcodeMCPProxyServerTests { let waiterError = await #expect(throws: (any Error).self) { try await waiter.value } for error in [startError, firstError, secondError, waiterError] { if discoveryFails { - let failure = try #require(error as? XcodeMCPProxyServer.CleanupError) + let failure = try #require(error as? XcodeMCPServer.CleanupError) #expect(failure.operationError as? DiscoveryWriteFailure == .expected) #expect(failure.cleanupError as? GatewayShutdownFailure == .expected) #expect(failure.endpoint == gateway.endpoint) @@ -407,7 +407,7 @@ struct XcodeMCPProxyServerTests { } let repeatedError = await #expect(throws: (any Error).self) { try await server.shutdown() } #expect(discoveryFails - ? repeatedError is XcodeMCPProxyServer.CleanupError + ? repeatedError is XcodeMCPServer.CleanupError : repeatedError as? GatewayShutdownFailure == .expected) #expect(gateway.shutdownCount == 1) #expect(runtime.shutdownCount == 1) @@ -422,7 +422,7 @@ struct XcodeMCPProxyServerTests { let runtime = StartupTestRuntime() var discovery = DiscoveryClient.testValue discovery.write = { _, _ in throw DiscoveryWriteFailure.expected } - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: .init(), dependencies: .init( discoveryClient: discovery, @@ -431,7 +431,7 @@ struct XcodeMCPProxyServerTests { ) ) - let error = try await #require(throws: XcodeMCPProxyServer.CleanupError.self) { + let error = try await #require(throws: XcodeMCPServer.CleanupError.self) { _ = try await server.start() } @@ -439,10 +439,10 @@ struct XcodeMCPProxyServerTests { #expect(error.cleanupError as? GatewayShutdownFailure == .expected) #expect(error.endpoint == gateway.endpoint) #expect((await server.snapshot()).endpoint == gateway.endpoint) - await #expect(throws: XcodeMCPProxyServer.CleanupError.self) { + await #expect(throws: XcodeMCPServer.CleanupError.self) { try await server.waitUntilShutdown() } - await #expect(throws: XcodeMCPProxyServer.CleanupError.self) { + await #expect(throws: XcodeMCPServer.CleanupError.self) { try await server.shutdown() } #expect(gateway.shutdownCount == 1) @@ -452,7 +452,7 @@ struct XcodeMCPProxyServerTests { @Test func gatewayAcquisitionFailurePreservesBothCausesThroughThePublicServer() async throws { let runtime = StartupTestRuntime() let groupShutdownCount = NIOLockedValueBox(0) - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: .init( bindAddress: .init(host: "127.0.0.1", port: 0), discovery: .disabled @@ -460,11 +460,11 @@ struct XcodeMCPProxyServerTests { dependencies: .init( makeRuntime: { _ in runtime }, makeHTTPGateway: { configuration, runtime, logger in - ProxyHTTPGateway( + ServerHTTPGateway( configuration: configuration, runtime: runtime, logger: logger, - bind: { _, _, _ in throw XcodeMCPProxyServer.LifecycleError.failedToBind }, + bind: { _, _, _ in throw XcodeMCPServer.LifecycleError.failedToBind }, shutdownGroup: { group in groupShutdownCount.withLockedValue { $0 += 1 } try await group.shutdownGracefully() @@ -475,16 +475,16 @@ struct XcodeMCPProxyServerTests { ) ) - let error = try await #require(throws: XcodeMCPProxyServer.CleanupError.self) { + let error = try await #require(throws: XcodeMCPServer.CleanupError.self) { _ = try await server.start() } let operationErrors = (error.operationError as NSError).underlyingErrors - #expect(operationErrors.contains { $0 as? XcodeMCPProxyServer.LifecycleError == .failedToBind }) + #expect(operationErrors.contains { $0 as? XcodeMCPServer.LifecycleError == .failedToBind }) let cleanupErrors = (error.cleanupError as NSError).underlyingErrors #expect(cleanupErrors.contains { $0 as? GatewayShutdownFailure == .expected }) #expect(error.endpoint == nil) - await #expect(throws: XcodeMCPProxyServer.CleanupError.self) { try await server.shutdown() } + await #expect(throws: XcodeMCPServer.CleanupError.self) { try await server.shutdown() } #expect(groupShutdownCount.withLockedValue { $0 } == 1) #expect(runtime.shutdownCount == 1) } @@ -492,7 +492,7 @@ struct XcodeMCPProxyServerTests { @Test func runningShutdownSharesReleaseFailureWithoutRepeatingCleanup() async throws { let gateway = ControlledShutdownGateway() let runtime = StartupTestRuntime() - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: .init(discovery: .disabled), dependencies: .init( makeRuntime: { _ in runtime }, @@ -516,14 +516,14 @@ struct XcodeMCPProxyServerTests { @Test func statusSnapshotExposesOnlySanitizedContractFields() async throws { let hosts = FakeHostSessionFactory() - let config = XcodeMCPProxyServerConfiguration( + let config = XcodeMCPServerConfiguration( bindAddress: .init(host: "127.0.0.1", port: 0), maxBodyBytes: 1_048_576, requestTimeout: .seconds(300), prewarmToolsList: false ) - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: config, dependencies: .init( discoveryClient: .testValue, @@ -551,7 +551,7 @@ struct XcodeMCPProxyServerTests { @Test func concurrentShutdownCompletesAllOwnedResourcesExactlyOnce() async throws { let hosts = FakeHostSessionFactory() - let server = XcodeMCPProxyServer( + let server = XcodeMCPServer( configuration: .init( bindAddress: .init(host: "127.0.0.1", port: 0), discovery: .disabled, @@ -605,8 +605,8 @@ private enum GatewayShutdownFailure: Error { case expected } -private final class ControlledShutdownGateway: ProxyHTTPGatewayServing, Sendable { - let endpoint = XcodeMCPProxyServer.Endpoint(host: "127.0.0.1", port: 9876) +private final class ControlledShutdownGateway: ServerHTTPGatewayServing, Sendable { + let endpoint = XcodeMCPServer.Endpoint(host: "127.0.0.1", port: 9876) let startBegan = TestSignal() let startCancelled = TestSignal() let allowStart = TestSignal() @@ -621,7 +621,7 @@ private final class ControlledShutdownGateway: ProxyHTTPGatewayServing, Sendable var shutdownCount: Int { shutdowns.withLockedValue { $0 } } - func start() async throws -> ProxyHTTPEndpoint { + func start() async throws -> ServerHTTPEndpoint { startBegan.signal() if holdStartup { let completion = Task { @@ -633,7 +633,7 @@ private final class ControlledShutdownGateway: ProxyHTTPGatewayServing, Sendable self.startCancelled.signal() } } - return ProxyHTTPEndpoint(host: endpoint.host, port: endpoint.port) + return ServerHTTPEndpoint(host: endpoint.host, port: endpoint.port) } func waitUntilShutdown() async throws { @@ -653,7 +653,7 @@ private final class ControlledShutdownGateway: ProxyHTTPGatewayServing, Sendable func cancelForDeinit() {} } -private final class RecordingPermissionDialogAutoApprover: Sendable, ProxyServerPermissionDialogAutoApprover { +private final class RecordingPermissionDialogAutoApprover: Sendable, ServerPermissionDialogAutoApprover { private let state = NIOLockedValueBox((start: 0, cancel: 0, shutdown: 0)) var counts: (start: Int, cancel: Int, shutdown: Int) { state.withLockedValue { $0 } } func start() { state.withLockedValue { $0.start += 1 } } @@ -661,7 +661,7 @@ private final class RecordingPermissionDialogAutoApprover: Sendable, ProxyServer func shutdown() async { state.withLockedValue { $0.shutdown += 1 } } } -private final class StartupTestRuntime: @unchecked Sendable, ProxyRuntimeServing { +private final class StartupTestRuntime: @unchecked Sendable, ServerRuntimeServing { private struct State { var startCount = 0 var shutdownCount = 0 @@ -680,13 +680,13 @@ private final class StartupTestRuntime: @unchecked Sendable, ProxyRuntimeServing func shutdown() async { state.withLockedValue { $0.shutdownCount += 1 } } - func openSession(_: ProxySessionID, - notify _: @escaping @Sendable (Data) -> Void) throws -> any ProxyRuntimeSession { - throw ProxyRuntimeUnavailable() + func openSession(_: ServerSessionID, + notify _: @escaping @Sendable (Data) -> Void) throws -> any ServerRuntimeSession { + throw ServerRuntimeUnavailable() } - func snapshot() -> ProxyRuntimeSnapshot { - ProxyRuntimeSnapshot(generatedAt: Date(), hosts: []) + func snapshot() -> ServerRuntimeSnapshot { + ServerRuntimeSnapshot(generatedAt: Date(), hosts: []) } func debugSnapshotData(includeSensitivePayloads: Bool) -> Data? { @@ -698,7 +698,7 @@ private final class StartupTestRuntime: @unchecked Sendable, ProxyRuntimeServing /// The production runtime over scripted host processes. private func makeServerTestRuntime( - config: ProxyRuntimeConfiguration, + config: ServerRuntimeConfiguration, hosts: FakeHostSessionFactory ) throws -> NativeHostBroker { let installation = XcodeHostInstallation(developerDirectory: URL(filePath: "/Fixture/Default.app")) @@ -711,8 +711,8 @@ private func makeServerTestRuntime( /// The runtime lists a host once it starts, which `start()` requests without waiting for it. private func waitUntilDefaultHostIsHealthy( - _ server: XcodeMCPProxyServer -) async throws -> XcodeMCPProxyServer.Status { + _ server: XcodeMCPServer +) async throws -> XcodeMCPServer.Status { try await waitWithTimeout("waiting for the default host to run", timeout: .seconds(5)) { while true { let status = await server.snapshot() @@ -739,12 +739,12 @@ private final class RestartProcessFixture: Sendable { private let state = NIOLockedValueBox(State()) private let reuseSecondPIDOnTermination: Bool private let processes: [Int: ProcessInfo] = [ - 123: .init(host: "127.0.0.1", port: 9000, executable: "xcode-mcp-proxy-server"), - 321: .init(host: "10.0.0.5", port: 8765, executable: "xcode-mcp-proxy-server"), - 456: .init(host: "127.0.0.1", port: 8765, executable: "xcode-mcp-proxy-server"), - 567: .init(host: "[::1]", port: 8765, executable: "xcode-mcp-proxy-server"), + 123: .init(host: "127.0.0.1", port: 9000, executable: "xcode-mcp-server"), + 321: .init(host: "10.0.0.5", port: 8765, executable: "xcode-mcp-server"), + 456: .init(host: "127.0.0.1", port: 8765, executable: "xcode-mcp-server"), + 567: .init(host: "[::1]", port: 8765, executable: "xcode-mcp-server"), 789: .init(host: "127.0.0.1", port: 8765, executable: "python3"), - 999: .init(host: "127.0.0.1", port: 8765, executable: "xcode-mcp-proxy-server"), + 999: .init(host: "127.0.0.1", port: 8765, executable: "xcode-mcp-server"), ] init(reuseSecondPIDOnTermination: Bool = false) { diff --git a/Tests/ProxyStressTests/DocumentationSearchStressTests.swift b/Tests/ServerStressTests/DocumentationSearchStressTests.swift similarity index 97% rename from Tests/ProxyStressTests/DocumentationSearchStressTests.swift rename to Tests/ServerStressTests/DocumentationSearchStressTests.swift index cba2a9e5..46c68448 100644 --- a/Tests/ProxyStressTests/DocumentationSearchStressTests.swift +++ b/Tests/ServerStressTests/DocumentationSearchStressTests.swift @@ -3,10 +3,10 @@ import Foundation import NIO import NIOHTTP1 import XcodeMCPKit -@testable import XcodeMCPProxyRuntime -@testable import XcodeMCPProxyHTTP +@testable import XcodeMCPServerRuntime +@testable import XcodeMCPServerHTTP import Testing -import XcodeMCPProxyTestSupport +import XcodeMCPServerTestSupport @Suite(.serialized, .enabled(if: StressTestEnvironment.isEnabled)) struct DocumentationSearchStressTests { @@ -143,13 +143,13 @@ private struct StressHTTPServer { let childChannelTracker: HTTPTestServerChannelTracker static func start(host: DocumentationSearchStressHostSession) throws -> StressHTTPServer { - ProxyLogging.bootstrap(environment: ["MCP_LOG_LEVEL": "critical"]) + ServerLogging.bootstrap(environment: ["MCP_LOG_LEVEL": "critical"]) let group = MultiThreadedEventLoopGroup(numberOfThreads: 4) let childChannelTracker = HTTPTestServerChannelTracker() let listenHost = "127.0.0.1" let listenPort = 0 let maxBodyBytes = 1_048_576 - let config = ProxyRuntimeConfiguration( + let config = ServerRuntimeConfiguration( maxMessageBytes: maxBodyBytes, requestTimeout: .seconds(60), prewarmToolsList: false @@ -168,7 +168,7 @@ private struct StressHTTPServer { channel.pipeline.configureHTTPServerPipeline(withErrorHandling: true).flatMap { channel.pipeline.addHandler( HTTPHandler( - config: ProxyHTTPConfiguration( + config: ServerHTTPConfiguration( listenHost: listenHost, listenPort: listenPort, maxBodyBytes: maxBodyBytes diff --git a/Tests/ProxyStressTests/StressTestEnvironment.swift b/Tests/ServerStressTests/StressTestEnvironment.swift similarity index 100% rename from Tests/ProxyStressTests/StressTestEnvironment.swift rename to Tests/ServerStressTests/StressTestEnvironment.swift diff --git a/Tests/ProxyToolVerifierTests/PreviewVerifierTests.swift b/Tests/ToolVerifierTests/PreviewVerifierTests.swift similarity index 99% rename from Tests/ProxyToolVerifierTests/PreviewVerifierTests.swift rename to Tests/ToolVerifierTests/PreviewVerifierTests.swift index 4ffc5f7b..c8cd240b 100644 --- a/Tests/ProxyToolVerifierTests/PreviewVerifierTests.swift +++ b/Tests/ToolVerifierTests/PreviewVerifierTests.swift @@ -4,7 +4,7 @@ import ImageIO import Testing import XcodeMCPKit import XcodeMCPKitTesting -@testable import XcodeMCPProxyToolVerifier +@testable import XcodeMCPToolVerifier struct PreviewVerifierTests { @Test func nativeWindowSelectionMatchesTheOwnedProjectDirectory() throws { diff --git a/Tests/ProxyToolVerifierTests/ProxyToolVerifierTests.swift b/Tests/ToolVerifierTests/ToolVerifierTests.swift similarity index 98% rename from Tests/ProxyToolVerifierTests/ProxyToolVerifierTests.swift rename to Tests/ToolVerifierTests/ToolVerifierTests.swift index 3066253d..729e87bc 100644 --- a/Tests/ProxyToolVerifierTests/ProxyToolVerifierTests.swift +++ b/Tests/ToolVerifierTests/ToolVerifierTests.swift @@ -2,9 +2,9 @@ import Foundation import Testing import XcodeMCPKit import XcodeMCPKitTesting -@testable import XcodeMCPProxyToolVerifier +@testable import XcodeMCPToolVerifier -struct ProxyToolVerifierTests { +struct ToolVerifierTests { @Test func repeatedOutputDirectoryKeepsBothGeneratedProjects() async throws { let fixture = try makeFixture() defer { try? FileManager.default.removeItem(at: fixture.outputRoot) } @@ -36,7 +36,7 @@ struct ProxyToolVerifierTests { var relationship = FileManager.URLRelationship.other try unsafe FileManager.default.getRelationship(&relationship, ofDirectoryAt: fixture.outputRoot, toItemAt: destination) #expect(relationship == .contains) - let contents = destination.appendingPathComponent("ProxyVerifierGeneratedCLI.xcodeproj/project.pbxproj") + let contents = destination.appendingPathComponent("ToolVerifierGeneratedCLI.xcodeproj/project.pbxproj") #expect(try String(contentsOf: contents, encoding: .utf8) == "native generated contents") } } @@ -315,7 +315,7 @@ struct ProxyToolVerifierTests { let options = try VerifierOptions(arguments: ["--request-timeout", "2"] + (runDestination.map { ["--run-destination", $0] } ?? []) + (deviceIdentifier.map { ["--device-identifier", $0] } ?? [])) - let failed = try await ProxyToolVerifier(options: options).verify(client: client, fixture: fixture, outputRoot: fixture.outputRoot) + let failed = try await ToolVerifier(options: options).verify(client: client, fixture: fixture, outputRoot: fixture.outputRoot) await client.close() return failed } catch { diff --git a/Tests/XcodeMCPCoreTests/NativeHostInvocationTests.swift b/Tests/XcodeMCPCoreTests/NativeHostInvocationTests.swift index 763670a1..94ae7b16 100644 --- a/Tests/XcodeMCPCoreTests/NativeHostInvocationTests.swift +++ b/Tests/XcodeMCPCoreTests/NativeHostInvocationTests.swift @@ -15,9 +15,9 @@ struct NativeHostInvocationTests { try manager.createDirectory(at: helper.deletingLastPathComponent(), withIntermediateDirectories: true) try Data().write(to: helper) try manager.setAttributes([.posixPermissions: 0o755], ofItemAtPath: helper.path) - let server = libexec.appendingPathComponent("xcode-mcp-proxy-server") + let server = libexec.appendingPathComponent("xcode-mcp-server") try Data().write(to: server) - try manager.createSymbolicLink(at: bin.appendingPathComponent("xcode-mcp-proxy-server"), withDestinationURL: server) + try manager.createSymbolicLink(at: bin.appendingPathComponent("xcode-mcp-server"), withDestinationURL: server) let invocation = try NativeHostInvocation.resolve( environment: ["PATH": bin.path], executableURL: nil) @@ -63,7 +63,7 @@ struct NativeHostInvocationTests { fileSystem.isExecutableFile = { $0 == "/installed/XcodeMCPNativeHost.app/Contents/MacOS/xcode-mcp-native-host" } let invocation = try NativeHostInvocation.resolve( environment: adjacent ? [:] : ["PATH": "/missing:/installed"], - executableURL: adjacent ? URL(fileURLWithPath: "/installed/xcode-mcp-proxy-server") : nil, + executableURL: adjacent ? URL(fileURLWithPath: "/installed/xcode-mcp-server") : nil, fileSystem: fileSystem) #expect(invocation.command == "/installed/XcodeMCPNativeHost.app/Contents/MacOS/xcode-mcp-native-host") } diff --git a/Tests/XcodeMCPKitTests/XcodeMCPTests.swift b/Tests/XcodeMCPKitTests/XcodeMCPTests.swift index 72dd1c0d..42dea486 100644 --- a/Tests/XcodeMCPKitTests/XcodeMCPTests.swift +++ b/Tests/XcodeMCPKitTests/XcodeMCPTests.swift @@ -858,8 +858,8 @@ struct XcodeMCPTests { @Test func serverTransportUsesTheStandardDiscoveryEnvironment() throws { let explicitDiscovery = XcodeMCPConfiguration.Transport.server( environment: [ - "XCODE_MCP_PROXY_DISCOVERY_FILE": "/tmp/public-contract/endpoint.json", - "XCODE_MCP_PROXY_CACHE_ROOT": "/tmp/ignored-cache-root", + "XCODE_MCP_SERVER_DISCOVERY_FILE": "/tmp/public-contract/endpoint.json", + "XCODE_MCP_SERVER_CACHE_ROOT": "/tmp/ignored-cache-root", ] ) #expect( @@ -870,13 +870,13 @@ struct XcodeMCPTests { let cacheRootDiscovery = XcodeMCPConfiguration.Transport.server( environment: [ - "XCODE_MCP_PROXY_CACHE_ROOT": "/tmp/public-contract-cache", + "XCODE_MCP_SERVER_CACHE_ROOT": "/tmp/public-contract-cache", ] ) #expect( cacheRootDiscovery == .server( discoveryFile: URL(fileURLWithPath: "/tmp/public-contract-cache") - .appendingPathComponent("XcodeMCPProxy", isDirectory: true) + .appendingPathComponent("XcodeMCPServer", isDirectory: true) .appendingPathComponent("endpoint.json") ) ) @@ -943,9 +943,9 @@ struct XcodeMCPTests { "Inspect the server error data and correct the request before retrying." ), ( - .transportUnavailable("proxy stopped"), - "The Xcode MCP transport is unavailable: proxy stopped", - "Start Xcode or the configured proxy, then reconnect." + .transportUnavailable("server stopped"), + "The Xcode MCP transport is unavailable: server stopped", + "Start Xcode or the configured server, then reconnect." ), ( .sessionRecoveryFailed("initialize failed"), @@ -3149,7 +3149,7 @@ private actor FakeStreamableHTTPServer { let result: MCPJSONValue = [ "protocolVersion": "2025-06-18", "serverInfo": [ - "name": "fake-http-proxy", + "name": "fake-http-server", "version": "test", ], "capabilities": [:], diff --git a/Tests/XcodeMCPPermissionAutomationTests/XcodePermissionDialogAutoApproverTests.swift b/Tests/XcodeMCPPermissionAutomationTests/XcodePermissionDialogAutoApproverTests.swift index a9df974b..939f8c30 100644 --- a/Tests/XcodeMCPPermissionAutomationTests/XcodePermissionDialogAutoApproverTests.swift +++ b/Tests/XcodeMCPPermissionAutomationTests/XcodePermissionDialogAutoApproverTests.swift @@ -64,7 +64,7 @@ struct XcodePermissionDialogAutoApproverTests { dependencies: .init( configuration: .init( permissionDialogProcessIDs: { [processID] }, - agentPathCandidates: { ["/tmp/xcode-mcp-proxy-server"] }, + agentPathCandidates: { ["/tmp/xcode-mcp-server"] }, assistantNameCandidates: { ["XcodeMCPKit"] }, agentProcessIDCandidates: { [6119] }, agentScope: .allAgents @@ -207,7 +207,7 @@ struct XcodePermissionDialogAutoApproverTests { dependencies: .init( configuration: .init( permissionDialogProcessIDs: { [processID] }, - agentPathCandidates: { ["/tmp/xcode-mcp-proxy-server"] }, + agentPathCandidates: { ["/tmp/xcode-mcp-server"] }, assistantNameCandidates: { ["XcodeMCPKit"] }, agentProcessIDCandidates: { [6119] }, agentScope: .allAgents @@ -230,7 +230,7 @@ struct XcodePermissionDialogAutoApproverTests { ] = [ (["エージェント XcodeMCPKit が Xcode のツール使用を要求しています。"], makeButton(title: "許可"), Set(["XcodeMCPKit"]), Set()), (["The agent XcodeMCPKit wants to use Xcode's tools."], XcodePermissionDialogAutomation.ButtonSnapshot(role: "AXButton", identifier: "action-button-1"), Set(["XcodeMCPKit"]), Set()), - (["The agent at /tmp/xcode-mcp-proxy-server wants to use Xcode's tools."], makeButton(title: "Allow"), Set(), Set(["/tmp/xcode-mcp-proxy-server"])), + (["The agent at /tmp/xcode-mcp-server wants to use Xcode's tools."], makeButton(title: "Allow"), Set(), Set(["/tmp/xcode-mcp-server"])), (["The agent Custom MCP, PID 6119 wants to use Xcode's tools."], makeButton(title: "Allow"), Set(["Custom MCP"]), Set()), ] @@ -444,7 +444,7 @@ struct XcodePermissionDialogAutoApproverTests { processBundleIdentifier: "com.apple.dt.Xcode", title: "許可", textValues: [ - "エージェント XcodeMCPKit at /tmp/xcode-mcp-proxy-server、プロセス ID 7001 が Xcode のツール使用を要求しています。" + "エージェント XcodeMCPKit at /tmp/xcode-mcp-server、プロセス ID 7001 が Xcode のツール使用を要求しています。" ], defaultButton: makeButton(title: "許可") ) @@ -452,7 +452,7 @@ struct XcodePermissionDialogAutoApproverTests { let decision = XcodePermissionDialogAutomation.Matcher.decision( for: snapshot, processID: 4317, - agentPathCandidates: ["/tmp/xcode-mcp-proxy-server"], + agentPathCandidates: ["/tmp/xcode-mcp-server"], assistantNameCandidates: ["XcodeMCPKit"], serverProcessIDCandidates: [6119] ) @@ -525,9 +525,9 @@ struct XcodePermissionDialogAutoApproverTests { title: #"Allow "XcodeMCPKit" to access Xcode?"#, textValues: [ "The agent wants to use Xcode's tools to perform actions like building, testing, or modifying code.", - "Path: /Users/kn/Dev/XcodeMCPKit/.build/arm64-apple-macosx/debug/xcode-mcp-proxy-server", + "Path: /Users/kn/Dev/XcodeMCPKit/.build/arm64-apple-macosx/debug/xcode-mcp-server", "PID: 23474", - "Signed by: xcode-mcp-proxy-server-55554944e4908a045cea3fc2aa2f6e03b9059810", + "Signed by: xcode-mcp-server-55554944e4908a045cea3fc2aa2f6e03b9059810", ], defaultButton: makeButton(title: "Allow") ) @@ -536,7 +536,7 @@ struct XcodePermissionDialogAutoApproverTests { for: snapshot, processID: 1036, agentPathCandidates: [ - "/Users/kn/Dev/XcodeMCPKit/.build/arm64-apple-macosx/debug/xcode-mcp-proxy-server" + "/Users/kn/Dev/XcodeMCPKit/.build/arm64-apple-macosx/debug/xcode-mcp-server" ], assistantNameCandidates: ["XcodeMCPKit"], serverProcessIDCandidates: [23474] @@ -589,14 +589,14 @@ struct XcodePermissionDialogAutoApproverTests { processBundleIdentifier: "com.apple.dt.Xcode", title: "許可", textValues: [ - "The agent XcodeMCPKit at /tmp/xcode-mcp-proxy-server wants to use Xcode's tools." + "The agent XcodeMCPKit at /tmp/xcode-mcp-server wants to use Xcode's tools." ] ) let decision = XcodePermissionDialogAutomation.Matcher.decision( for: snapshot, processID: 4317, - agentPathCandidates: ["/tmp/xcode-mcp-proxy-server"], + agentPathCandidates: ["/tmp/xcode-mcp-server"], assistantNameCandidates: ["XcodeMCPKit"], serverProcessIDCandidates: [6119] ) @@ -609,14 +609,14 @@ struct XcodePermissionDialogAutoApproverTests { processBundleIdentifier: "com.apple.dt.Xcode", title: "許可", textValues: [ - "The agent at /tmp/xcode-mcp-proxy-server wants to use Xcode's tools." + "The agent at /tmp/xcode-mcp-server wants to use Xcode's tools." ] ) let decision = XcodePermissionDialogAutomation.Matcher.decision( for: snapshot, processID: 4317, - agentPathCandidates: ["/tmp/xcode-mcp-proxy-server"], + agentPathCandidates: ["/tmp/xcode-mcp-server"], assistantNameCandidates: [], serverProcessIDCandidates: [] ) @@ -743,7 +743,7 @@ struct XcodePermissionDialogAutoApproverTests { dependencies: .init( configuration: .init( permissionDialogProcessIDs: { axClient.recordedProcessIDs() }, - agentPathCandidates: { ["/tmp/xcode-mcp-proxy-server"] }, + agentPathCandidates: { ["/tmp/xcode-mcp-server"] }, assistantNameCandidates: { [] }, agentProcessIDCandidates: { [6119] } ), diff --git a/Tests/XcodeMCPProxyHTTPTests/HTTPEventDeliveryStoreTests.swift b/Tests/XcodeMCPServerHTTPTests/HTTPEventDeliveryStoreTests.swift similarity index 93% rename from Tests/XcodeMCPProxyHTTPTests/HTTPEventDeliveryStoreTests.swift rename to Tests/XcodeMCPServerHTTPTests/HTTPEventDeliveryStoreTests.swift index 060959c2..afdd5103 100644 --- a/Tests/XcodeMCPProxyHTTPTests/HTTPEventDeliveryStoreTests.swift +++ b/Tests/XcodeMCPServerHTTPTests/HTTPEventDeliveryStoreTests.swift @@ -5,14 +5,14 @@ import NIOHTTP1 import Synchronization import Testing -@testable import XcodeMCPProxyHTTP -import XcodeMCPProxyRuntimeContract +@testable import XcodeMCPServerHTTP +import XcodeMCPServerRuntimeContract @Suite struct HTTPEventDeliveryStoreTests { @Test func notificationsBufferAcrossSSEReconnects() throws { let store = HTTPEventDeliveryStore() - let sessionID = ProxySessionID(rawValue: "session-buffer-owner") + let sessionID = ServerSessionID(rawValue: "session-buffer-owner") let buffered = Data(#"{"jsonrpc":"2.0","method":"buffered"}"#.utf8) let afterDisconnect = Data(#"{"jsonrpc":"2.0","method":"reconnected"}"#.utf8) let firstChannel = EmbeddedChannel() @@ -45,7 +45,7 @@ struct HTTPEventDeliveryStoreTests { /// Progress goes to the running request that routed its token, never to the session's event stream. @Test func progressReachesOnlyTheRequestThatRoutedItsToken() throws { let store = HTTPEventDeliveryStore() - let sessionID = ProxySessionID(rawValue: "session-progress") + let sessionID = ServerSessionID(rawValue: "session-progress") let progress = Data(#"{"jsonrpc":"2.0","method":"notifications/progress","params":{"progressToken":"build","progress":1}}"#.utf8) let unrouted = Data(#"{"jsonrpc":"2.0","method":"notifications/progress","params":{"progressToken":7,"progress":1}}"#.utf8) let message = Data(#"{"jsonrpc":"2.0","method":"notifications/message"}"#.utf8) @@ -79,7 +79,7 @@ struct HTTPEventDeliveryStoreTests { @Test(arguments: [("-0.0", "0"), ("1e16", "10000000000000000")]) func progressForANumericTokenReachesItsRoute(sent: String, restored: String) throws { let store = HTTPEventDeliveryStore() - let sessionID = ProxySessionID(rawValue: "session-numeric-token") + let sessionID = ServerSessionID(rawValue: "session-numeric-token") openSession(sessionID, in: store) defer { store.closeAll() } let token = try #require( @@ -94,7 +94,7 @@ struct HTTPEventDeliveryStoreTests { @Test func notificationBufferDropsOldestPayloadPastItsLimit() throws { let store = HTTPEventDeliveryStore(bufferLimit: 2) - let sessionID = ProxySessionID(rawValue: "session-bounded-buffer") + let sessionID = ServerSessionID(rawValue: "session-bounded-buffer") let first = Data("first".utf8) let second = Data("second".utf8) let third = Data("third".utf8) @@ -127,7 +127,7 @@ struct HTTPEventDeliveryStoreTests { overflowWarningSink: { state.record($0) } ) defer { store.closeAll() } - let sessionID = ProxySessionID(rawValue: "session-overflow-warning") + let sessionID = ServerSessionID(rawValue: "session-overflow-warning") openSession(sessionID, in: store) store.deliver(notification(method: "notifications/first"), to: sessionID) @@ -170,8 +170,8 @@ struct HTTPEventDeliveryStoreTests { overflowWarningSink: { state.record($0) } ) defer { store.closeAll() } - let firstSessionID = ProxySessionID(rawValue: "session-overflow-a") - let secondSessionID = ProxySessionID(rawValue: "session-overflow-b") + let firstSessionID = ServerSessionID(rawValue: "session-overflow-a") + let secondSessionID = ServerSessionID(rawValue: "session-overflow-b") openSession(firstSessionID, in: store) openSession(secondSessionID, in: store) @@ -210,7 +210,7 @@ struct HTTPEventDeliveryStoreTests { overflowWarningSink: { state.record($0) } ) defer { store.closeAll() } - let sessionID = ProxySessionID(rawValue: "session-overflow-method-cardinality") + let sessionID = ServerSessionID(rawValue: "session-overflow-method-cardinality") openSession(sessionID, in: store) store.deliver(notification(method: "notifications/initial"), to: sessionID) @@ -249,7 +249,7 @@ struct HTTPEventDeliveryStoreTests { @Test func notificationBuffersWhileChannelInactiveCallbackIsPending() throws { let store = HTTPEventDeliveryStore() - let sessionID = ProxySessionID(rawValue: "session-inactive-race") + let sessionID = ServerSessionID(rawValue: "session-inactive-race") let notification = Data(#"{"jsonrpc":"2.0","method":"during-disconnect"}"#.utf8) let disconnectedChannel = EmbeddedChannel() let reconnectedChannel = EmbeddedChannel() @@ -275,7 +275,7 @@ struct HTTPEventDeliveryStoreTests { @Test func notificationReturnsToBufferWhenSelectedChannelClosesBeforeWrite() throws { let store = HTTPEventDeliveryStore() - let sessionID = ProxySessionID(rawValue: "session-write-race") + let sessionID = ServerSessionID(rawValue: "session-write-race") let notification = Data(#"{"jsonrpc":"2.0","method":"during-write"}"#.utf8) let disconnectedChannel = EmbeddedChannel() let reconnectedChannel = EmbeddedChannel() @@ -302,7 +302,7 @@ struct HTTPEventDeliveryStoreTests { @Test func bufferedNotificationsPrecedeEventsArrivingDuringReconnect() throws { let store = HTTPEventDeliveryStore() - let sessionID = ProxySessionID(rawValue: "session-reconnect-order") + let sessionID = ServerSessionID(rawValue: "session-reconnect-order") let first = Data(#"{"jsonrpc":"2.0","method":"first"}"#.utf8) let second = Data(#"{"jsonrpc":"2.0","method":"second"}"#.utf8) let duringReconnect = Data(#"{"jsonrpc":"2.0","method":"during-reconnect"}"#.utf8) @@ -329,7 +329,7 @@ struct HTTPEventDeliveryStoreTests { @Test func sessionClosureClosesItsSSEChannels() throws { let store = HTTPEventDeliveryStore() - let sessionID = ProxySessionID(rawValue: "session-closed") + let sessionID = ServerSessionID(rawValue: "session-closed") let channel = EmbeddedChannel() defer { store.closeAll() @@ -347,7 +347,7 @@ struct HTTPEventDeliveryStoreTests { @Test func lateNotificationDoesNotRecreateClosedSessionDelivery() throws { let store = HTTPEventDeliveryStore() - let sessionID = ProxySessionID(rawValue: "session-late-notification") + let sessionID = ServerSessionID(rawValue: "session-late-notification") let channel = EmbeddedChannel() defer { store.closeAll() @@ -387,7 +387,7 @@ private func notification(method: String) -> Data { Data(#"{"jsonrpc":"2.0","method":"\#(method)"}"#.utf8) } -private func openSession(_ sessionID: ProxySessionID, in store: HTTPEventDeliveryStore) { +private func openSession(_ sessionID: ServerSessionID, in store: HTTPEventDeliveryStore) { store.register(sessionID) } diff --git a/Tests/XcodeMCPProxyHTTPTests/HTTPResponseWriterLoggingTests.swift b/Tests/XcodeMCPServerHTTPTests/HTTPResponseWriterLoggingTests.swift similarity index 98% rename from Tests/XcodeMCPProxyHTTPTests/HTTPResponseWriterLoggingTests.swift rename to Tests/XcodeMCPServerHTTPTests/HTTPResponseWriterLoggingTests.swift index 95f1afc7..59d14932 100644 --- a/Tests/XcodeMCPProxyHTTPTests/HTTPResponseWriterLoggingTests.swift +++ b/Tests/XcodeMCPServerHTTPTests/HTTPResponseWriterLoggingTests.swift @@ -3,7 +3,7 @@ import Logging import NIOHTTP1 import Testing -@testable import XcodeMCPProxyHTTP +@testable import XcodeMCPServerHTTP @Suite struct HTTPResponseWriterLoggingTests { diff --git a/Tests/XcodeMCPProxyHTTPTests/HTTPSessionStoreTests.swift b/Tests/XcodeMCPServerHTTPTests/HTTPSessionStoreTests.swift similarity index 76% rename from Tests/XcodeMCPProxyHTTPTests/HTTPSessionStoreTests.swift rename to Tests/XcodeMCPServerHTTPTests/HTTPSessionStoreTests.swift index a730de96..f875e587 100644 --- a/Tests/XcodeMCPProxyHTTPTests/HTTPSessionStoreTests.swift +++ b/Tests/XcodeMCPServerHTTPTests/HTTPSessionStoreTests.swift @@ -4,8 +4,8 @@ import NIOEmbedded import Synchronization import Testing -@testable import XcodeMCPProxyHTTP -import XcodeMCPProxyRuntimeContract +@testable import XcodeMCPServerHTTP +import XcodeMCPServerRuntimeContract @Suite struct HTTPSessionStoreTests { @@ -14,7 +14,7 @@ struct HTTPSessionStoreTests { let clock = ManualUptime() let store = HTTPSessionStore(runtime: runtime, delivery: HTTPEventDeliveryStore(), uptimeNanoseconds: { clock.now }) - let id = ProxySessionID(rawValue: "session") + let id = ServerSessionID(rawValue: "session") let grace = TimeAmount.seconds(10) let channel = EmbeddedChannel() defer { _ = try? channel.finish() } @@ -46,9 +46,9 @@ struct HTTPSessionStoreTests { @Test func eachWayToEndASessionClosesItsRuntimeSessionOnce() throws { let runtime = SessionRecordingRuntime() let store = HTTPSessionStore(runtime: runtime, delivery: HTTPEventDeliveryStore()) - let deleted = ProxySessionID(rawValue: "deleted") - let expired = ProxySessionID(rawValue: "expired") - let remaining = ProxySessionID(rawValue: "remaining") + let deleted = ServerSessionID(rawValue: "deleted") + let expired = ServerSessionID(rawValue: "expired") + let remaining = ServerSessionID(rawValue: "remaining") for id in [deleted, expired, remaining] { _ = try store.create(id) } store.release(expired) @@ -69,18 +69,18 @@ struct HTTPSessionStoreTests { @Test func noSessionStartsWhileTheRuntimeResets() async throws { let runtime = SessionRecordingRuntime() let store = HTTPSessionStore(runtime: runtime, delivery: HTTPEventDeliveryStore()) - let existing = ProxySessionID(rawValue: "existing") - let duringReset = ProxySessionID(rawValue: "during-reset") + let existing = ServerSessionID(rawValue: "existing") + let duringReset = ServerSessionID(rawValue: "during-reset") _ = try store.create(existing) await store.closeAll { - #expect(throws: ProxyRuntimeUnavailable.self) { try store.create(duringReset) } + #expect(throws: ServerRuntimeUnavailable.self) { try store.create(duringReset) } } #expect(store.phase(of: existing) == nil) #expect(store.phase(of: duringReset) == nil) #expect(runtime.closeCounts == [existing: 1]) - let afterReset = ProxySessionID(rawValue: "after-reset") + let afterReset = ServerSessionID(rawValue: "after-reset") _ = try store.create(afterReset) #expect(store.phase(of: afterReset) == .initializing) } @@ -90,7 +90,7 @@ struct HTTPSessionStoreTests { @Test func aSessionOpenedBeforeAResetIsNotKeptAfterIt() throws { let runtime = SessionRecordingRuntime() let store = HTTPSessionStore(runtime: runtime, delivery: HTTPEventDeliveryStore()) - let id = ProxySessionID(rawValue: "overlapping") + let id = ServerSessionID(rawValue: "overlapping") runtime.onOpen.withLock { onOpen in onOpen = { let reset = DispatchSemaphore(value: 0) @@ -102,7 +102,7 @@ struct HTTPSessionStoreTests { } } - #expect(throws: ProxyRuntimeUnavailable.self) { try store.create(id) } + #expect(throws: ServerRuntimeUnavailable.self) { try store.create(id) } #expect(store.phase(of: id) == nil) #expect(runtime.closeCounts == [id: 1]) } @@ -117,41 +117,41 @@ private final class ManualUptime: Sendable { } } -private final class SessionRecordingRuntime: ProxyRuntimeServing { - private let closes = Mutex<[ProxySessionID: Int]>([:]) +private final class SessionRecordingRuntime: ServerRuntimeServing { + private let closes = Mutex<[ServerSessionID: Int]>([:]) /// Runs inside `openSession`, before it returns. let onOpen = Mutex<(@Sendable () -> Void)?>(nil) - var closeCounts: [ProxySessionID: Int] { closes.withLock { $0 } } + var closeCounts: [ServerSessionID: Int] { closes.withLock { $0 } } func start() {} func cancelForDeinit() {} func shutdown() async {} - func openSession(_ id: ProxySessionID, - notify _: @escaping @Sendable (Data) -> Void) throws -> any ProxyRuntimeSession { + func openSession(_ id: ServerSessionID, + notify _: @escaping @Sendable (Data) -> Void) throws -> any ServerRuntimeSession { onOpen.withLock { $0 }?() return Session { self.closes.withLock { $0[id, default: 0] += 1 } } } - func snapshot() -> ProxyRuntimeSnapshot { - ProxyRuntimeSnapshot(generatedAt: Date(), hosts: []) + func snapshot() -> ServerRuntimeSnapshot { + ServerRuntimeSnapshot(generatedAt: Date(), hosts: []) } func debugSnapshotData(includeSensitivePayloads _: Bool) -> Data? { nil } func reset() async {} - private struct Answered: ProxyRuntimeCall { - var reply: ProxyRuntimeReply { .accepted } + private struct Answered: ServerRuntimeCall { + var reply: ServerRuntimeReply { .accepted } func cancel() {} } - private struct Session: ProxyRuntimeSession { + private struct Session: ServerRuntimeSession { let onClose: @Sendable () -> Void - func receive(_: ProxyRuntimeRequest) -> any ProxyRuntimeCall { Answered() } + func receive(_: ServerRuntimeRequest) -> any ServerRuntimeCall { Answered() } func close() { onClose() } } } diff --git a/Tests/XcodeMCPProxyHTTPTests/SSEHubTests.swift b/Tests/XcodeMCPServerHTTPTests/SSEHubTests.swift similarity index 95% rename from Tests/XcodeMCPProxyHTTPTests/SSEHubTests.swift rename to Tests/XcodeMCPServerHTTPTests/SSEHubTests.swift index 881810e9..c689c64b 100644 --- a/Tests/XcodeMCPProxyHTTPTests/SSEHubTests.swift +++ b/Tests/XcodeMCPServerHTTPTests/SSEHubTests.swift @@ -4,8 +4,8 @@ import NIOEmbedded import NIOHTTP1 import Testing -@testable import XcodeMCPProxyHTTP -import XcodeMCPProxyRuntimeContract +@testable import XcodeMCPServerHTTP +import XcodeMCPServerRuntimeContract @Suite struct SSEHubTests { diff --git a/Tests/XcodeMCPProxyHTTPTests/ProxyHTTPGatewayTests.swift b/Tests/XcodeMCPServerHTTPTests/ServerHTTPGatewayTests.swift similarity index 91% rename from Tests/XcodeMCPProxyHTTPTests/ProxyHTTPGatewayTests.swift rename to Tests/XcodeMCPServerHTTPTests/ServerHTTPGatewayTests.swift index 1e5adf45..644dbae6 100644 --- a/Tests/XcodeMCPProxyHTTPTests/ProxyHTTPGatewayTests.swift +++ b/Tests/XcodeMCPServerHTTPTests/ServerHTTPGatewayTests.swift @@ -3,19 +3,19 @@ import Logging import NIO import Testing -@testable import XcodeMCPProxyHTTP -import XcodeMCPProxyRuntimeContract +@testable import XcodeMCPServerHTTP +import XcodeMCPServerRuntimeContract -struct ProxyHTTPGatewayTests { +struct ServerHTTPGatewayTests { @Test func shutdownClosesListenerAndReleasesPort() async throws { - let gateway = ProxyHTTPGateway( - configuration: ProxyHTTPConfiguration( + let gateway = ServerHTTPGateway( + configuration: ServerHTTPConfiguration( listenHost: "127.0.0.1", listenPort: 0, maxBodyBytes: 1_048_576 ), runtime: GatewayTestRuntime(), - logger: Logger(label: "ProxyHTTPGatewayTests") + logger: Logger(label: "ServerHTTPGatewayTests") ) let endpoint = try await gateway.start() #expect(endpoint.port > 0) @@ -40,10 +40,10 @@ struct ProxyHTTPGatewayTests { func startupFailurePreservesGroupCleanupFailure(cleanupFails: Bool) async throws { let recorded = GatewayCleanupRecorder() defer { recorded.finishCleanup() } - let gateway = ProxyHTTPGateway( + let gateway = ServerHTTPGateway( configuration: .init(listenHost: "127.0.0.1", listenPort: 0, maxBodyBytes: 1_048_576), runtime: GatewayTestRuntime(), - logger: Logger(label: "ProxyHTTPGatewayTests"), + logger: Logger(label: "ServerHTTPGatewayTests"), bind: { _, _, _ in throw GatewayFailure.bind }, shutdownGroup: { group in recorded.record(group: group) @@ -69,10 +69,10 @@ struct ProxyHTTPGatewayTests { @Test func shutdownAttemptsEveryResourceAndReportsAllFailures() async throws { let recorded = GatewayCleanupRecorder() defer { recorded.finishCleanup() } - let gateway = ProxyHTTPGateway( + let gateway = ServerHTTPGateway( configuration: .init(listenHost: "127.0.0.1", listenPort: 0, maxBodyBytes: 1_048_576), runtime: GatewayTestRuntime(), - logger: Logger(label: "ProxyHTTPGatewayTests"), + logger: Logger(label: "ServerHTTPGatewayTests"), bind: { bootstrap, host, port in let listener = try await bootstrap.bind(host: host, port: port).get() let accepted = listener.eventLoop.makePromise(of: Channel.self) @@ -189,17 +189,17 @@ private final class RecordAcceptedChannel: ChannelInboundHandler, @unchecked Sen } } -private final class GatewayTestRuntime: ProxyRuntimeServing, Sendable { +private final class GatewayTestRuntime: ServerRuntimeServing, Sendable { func start() {} func cancelForDeinit() {} func shutdown() async {} - func openSession(_: ProxySessionID, - notify _: @escaping @Sendable (Data) -> Void) throws -> any ProxyRuntimeSession { - throw ProxyRuntimeUnavailable() + func openSession(_: ServerSessionID, + notify _: @escaping @Sendable (Data) -> Void) throws -> any ServerRuntimeSession { + throw ServerRuntimeUnavailable() } - func snapshot() -> ProxyRuntimeSnapshot { + func snapshot() -> ServerRuntimeSnapshot { fatalError("gateway lifecycle test does not read runtime state") } diff --git a/Tests/XcodeMCPProxyRuntimeTestSupport/FakeHostSession.swift b/Tests/XcodeMCPServerRuntimeTestSupport/FakeHostSession.swift similarity index 96% rename from Tests/XcodeMCPProxyRuntimeTestSupport/FakeHostSession.swift rename to Tests/XcodeMCPServerRuntimeTestSupport/FakeHostSession.swift index 88050fe7..56629126 100644 --- a/Tests/XcodeMCPProxyRuntimeTestSupport/FakeHostSession.swift +++ b/Tests/XcodeMCPServerRuntimeTestSupport/FakeHostSession.swift @@ -2,8 +2,8 @@ import Foundation import NIOConcurrencyHelpers import Testing import XcodeMCPCore -@testable import XcodeMCPProxyRuntime -import XcodeMCPProxyTestSupport +@testable import XcodeMCPServerRuntime +import XcodeMCPServerTestSupport /// A scripted host process. It answers `initialize` and, unless `handlesCatalog` is set, /// `tools/list` itself, and asks `handle` for every other request. @@ -23,12 +23,12 @@ final class FakeHostSession: MCPProcessSession, Sendable { private let tools: NIOLockedValueBox private let initializeReply: Reply? private let handlesCatalog: Bool - /// Every message the proxy wrote, in order. + /// Every message the server wrote, in order. let received = NIOLockedValueBox<[JSONValue]>([]) private let held = NIOLockedValueBox<[(id: JSONValue, method: String)]>([]) let heldRequest = TestSignal() let stopped = TestSignal() - /// Signaled when the proxy requests termination without waiting for it. + /// Signaled when the server requests termination without waiting for it. let cancelled = TestSignal() private let stops = NIOLockedValueBox(0) var stopCount: Int { stops.withLockedValue { $0 } } diff --git a/Tests/XcodeMCPProxyRuntimeTestSupport/HostProcessConfigurationMirror.swift b/Tests/XcodeMCPServerRuntimeTestSupport/HostProcessConfigurationMirror.swift similarity index 98% rename from Tests/XcodeMCPProxyRuntimeTestSupport/HostProcessConfigurationMirror.swift rename to Tests/XcodeMCPServerRuntimeTestSupport/HostProcessConfigurationMirror.swift index 504cf7a4..7d44b1d2 100644 --- a/Tests/XcodeMCPProxyRuntimeTestSupport/HostProcessConfigurationMirror.swift +++ b/Tests/XcodeMCPServerRuntimeTestSupport/HostProcessConfigurationMirror.swift @@ -1,7 +1,7 @@ import Foundation import Testing import XcodeMCPCore -@testable import XcodeMCPProxyRuntime +@testable import XcodeMCPServerRuntime func upstreamEnvironment(from factory: any MCPProcessSessionFactory) throws -> [String: String] { let configMirror = try upstreamConfigMirror(from: factory) diff --git a/Tests/XcodeMCPProxyRuntimeTests/NativeBrokerTurnsTests.swift b/Tests/XcodeMCPServerRuntimeTests/NativeBrokerTurnsTests.swift similarity index 97% rename from Tests/XcodeMCPProxyRuntimeTests/NativeBrokerTurnsTests.swift rename to Tests/XcodeMCPServerRuntimeTests/NativeBrokerTurnsTests.swift index 69c14921..4ce878d3 100644 --- a/Tests/XcodeMCPProxyRuntimeTests/NativeBrokerTurnsTests.swift +++ b/Tests/XcodeMCPServerRuntimeTests/NativeBrokerTurnsTests.swift @@ -1,7 +1,7 @@ import NIOConcurrencyHelpers import Testing -@testable import XcodeMCPProxyRuntime -import XcodeMCPProxyTestSupport +@testable import XcodeMCPServerRuntime +import XcodeMCPServerTestSupport @Suite(.timeLimit(.minutes(1))) struct NativeBrokerTurnsTests { diff --git a/Tests/XcodeMCPProxyRuntimeTests/NativeHostBrokerTests.swift b/Tests/XcodeMCPServerRuntimeTests/NativeHostBrokerTests.swift similarity index 97% rename from Tests/XcodeMCPProxyRuntimeTests/NativeHostBrokerTests.swift rename to Tests/XcodeMCPServerRuntimeTests/NativeHostBrokerTests.swift index 3f147f6b..6ea0885d 100644 --- a/Tests/XcodeMCPProxyRuntimeTests/NativeHostBrokerTests.swift +++ b/Tests/XcodeMCPServerRuntimeTests/NativeHostBrokerTests.swift @@ -4,9 +4,9 @@ import NIO import NIOConcurrencyHelpers import Testing @testable import XcodeMCPCore -@testable import XcodeMCPProxyRuntime -import XcodeMCPProxyRuntimeContract -import XcodeMCPProxyTestSupport +@testable import XcodeMCPServerRuntime +import XcodeMCPServerRuntimeContract +import XcodeMCPServerTestSupport @Suite(.serialized, .timeLimit(.minutes(1)), .asyncTestCleanup) struct NativeHostBrokerTests { @@ -156,7 +156,7 @@ struct NativeHostBrokerTests { @Test func requestCancelledWhileTheHostStartsIsNotSentToTheHost() async throws { let fixture = try BrokerFixture(holdsInitialization: true) let session = try await fixture.initialize("cancel-during-start") - let request = try ProxyRuntimeRequest(json: .object([ + let request = try ServerRuntimeRequest(json: .object([ "jsonrpc": .string("2.0"), "id": .number(.int(41)), "method": .string("tools/call"), "params": .object(["name": .string("XcodeListTemplates"), "arguments": .object([:])]), ])) @@ -551,7 +551,7 @@ struct NativeHostBrokerTests { let session = try await fixture.initialize("runtime-failure") let workspace = try await fixture.open(session) _ = fixture.factory.invalidResponses.withLockedValue { $0.insert(operation) } - let reply: ProxyRuntimeReply + let reply: ServerRuntimeReply if operation == "tools/list" { reply = try await fixture.reply(session, method: "tools/list") } else { @@ -703,7 +703,7 @@ struct NativeHostBrokerTests { == [.object(["scheme": .string("App")]), .object(["scheme": .string("Tool")])]) let conversations = logs.map { $0.metadata[NativeHostBroker.conversationKey] } #expect(conversations[0] != nil && conversations[1] != nil && conversations[0] != conversations[1]) - // The host's report stays between the proxy and the host. + // The host's report stays between the server and the host. guard case .object(let fields) = resultB, case .object(let metadata)? = fields["_meta"] else { Issue.record("missing result metadata"); return } @@ -1165,14 +1165,14 @@ private final class BrokerFixture: Sendable { let broker: NativeHostBroker let factory = BrokerRuntimeFactory() let guiFactory = BrokerRuntimeFactory() - let sessions = NIOLockedValueBox<[ProxySessionID: any ProxyRuntimeSession]>([:]) + let sessions = NIOLockedValueBox<[ServerSessionID: any ServerRuntimeSession]>([:]) /// Host notifications that reached each session. - let notifications = NIOLockedValueBox<[(session: ProxySessionID, data: Data)]>([]) + let notifications = NIOLockedValueBox<[(session: ServerSessionID, data: Data)]>([]) let defaultInstallation = XcodeHostInstallation(developerDirectory: URL(fileURLWithPath: "/Fixture/Default.app")) init(clock: ClockClient = .liveValue, requestTimeout: Duration? = .seconds(5), holdsInitialization: Bool = false, prewarmToolsList: Bool = false, - logger: Logger = ProxyLogging.make("broker")) throws { + logger: Logger = ServerLogging.make("broker")) throws { let factory = factory factory.holdsInitialization.withLockedValue { $0 = holdsInitialization } let defaultInstallation = defaultInstallation @@ -1187,7 +1187,7 @@ private final class BrokerFixture: Sendable { #expect(registerAsyncTestCleanup(description: "broker shutdown") { await broker.shutdown() }) } - func open(_ session: ProxySessionID, host: JSONValue? = nil) async throws -> JSONValue { + func open(_ session: ServerSessionID, host: JSONValue? = nil) async throws -> JSONValue { var arguments: [String: JSONValue] = ["path": .string("/Fixture/App.xcodeproj")] if let host { arguments["hostIdentifier"] = host } let result = try await call(session, name: NativeHostBroker.openWorkspaceTool, arguments: arguments) @@ -1197,7 +1197,7 @@ private final class BrokerFixture: Sendable { return identifier } - func workspaces(_ session: ProxySessionID) async throws -> [[String: JSONValue]] { + func workspaces(_ session: ServerSessionID) async throws -> [[String: JSONValue]] { let result = try await call(session, name: NativeHostBroker.listWorkspacesTool) guard case .array(let values)? = result["workspaces"] else { throw NativeHostBrokerError("missing workspace list") @@ -1205,15 +1205,15 @@ private final class BrokerFixture: Sendable { return values.compactMap { if case .object(let fields) = $0 { fields } else { nil } } } - func toolResult(_ session: ProxySessionID, name: String, + func toolResult(_ session: ServerSessionID, name: String, arguments: [String: JSONValue] = [:], id: Int64 = 19) async throws -> JSONValue { try await request(session, method: "tools/call", parameters: .object([ "name": .string(name), "arguments": .object(arguments), ]), id: id) } - func initialize(_ name: String) async throws -> ProxySessionID { - let id = ProxySessionID(rawValue: name) + func initialize(_ name: String) async throws -> ServerSessionID { + let id = ServerSessionID(rawValue: name) let notifications = notifications let session = try broker.openSession(id) { data in notifications.withLockedValue { $0.append((id, data)) } } sessions.withLockedValue { $0[id] = session } @@ -1225,32 +1225,32 @@ private final class BrokerFixture: Sendable { return id } - func reply(_ session: ProxySessionID, method: String, parameters: JSONValue? = nil, - id: Int64? = 19) async throws -> ProxyRuntimeReply { + func reply(_ session: ServerSessionID, method: String, parameters: JSONValue? = nil, + id: Int64? = 19) async throws -> ServerRuntimeReply { var json: [String: JSONValue] = ["jsonrpc": .string("2.0"), "method": .string(method)] if let id { json["id"] = .number(.int(id)) } if let parameters { json["params"] = parameters } - let request = try ProxyRuntimeRequest(json: .object(json)) + let request = try ServerRuntimeRequest(json: .object(json)) let runtimeSession = try runtimeSession(session) return try await waitWithTimeout("broker request", timeout: .seconds(10)) { await runtimeSession.receive(request).reply } } - func runtimeSession(_ id: ProxySessionID) throws -> any ProxyRuntimeSession { + func runtimeSession(_ id: ServerSessionID) throws -> any ServerRuntimeSession { try #require(sessions.withLockedValue { $0[id] }) } /// Ends a session, as the gateway does when it is deleted or expires. - func close(_ id: ProxySessionID) { + func close(_ id: ServerSessionID) { sessions.withLockedValue { $0[id] }?.close() } - func request(_ session: ProxySessionID, method: String, parameters: JSONValue? = nil, + func request(_ session: ServerSessionID, method: String, parameters: JSONValue? = nil, id: Int64? = 19) async throws -> JSONValue { try NativeHostBroker.result(in: await reply(session, method: method, parameters: parameters, id: id).brokerReply) } - func call(_ session: ProxySessionID, name: String, + func call(_ session: ServerSessionID, name: String, arguments: [String: JSONValue] = [:]) async throws -> [String: JSONValue] { let result = try await request(session, method: "tools/call", parameters: .object([ "name": .string(name), "arguments": .object(arguments), @@ -1260,7 +1260,7 @@ private final class BrokerFixture: Sendable { } return content } - func list(_ session: ProxySessionID) async throws -> [[String: JSONValue]] { + func list(_ session: ServerSessionID) async throws -> [[String: JSONValue]] { let value = try await call(session, name: NativeHostBroker.listTool) guard case .array(let hosts)? = value["hosts"] else { throw NativeHostBrokerError("missing host list") @@ -1277,7 +1277,7 @@ private func jsonRPCError(in data: Data) -> (code: Int, message: String)? { return (code, message) } -private extension ProxyRuntimeReply { +private extension ServerRuntimeReply { var brokerReply: NativeBrokerReply { switch self { case .response(let data): .response(data) @@ -1286,14 +1286,14 @@ private extension ProxyRuntimeReply { } var jsonRPCError: (code: Int, message: String)? { - if case .response(let data) = self { XcodeMCPProxyRuntimeTests.jsonRPCError(in: data) } else { nil } + if case .response(let data) = self { XcodeMCPServerRuntimeTests.jsonRPCError(in: data) } else { nil } } } private extension NativeBrokerReply { var jsonRPCError: (code: Int, message: String)? { switch self { - case .response(let data): XcodeMCPProxyRuntimeTests.jsonRPCError(in: data) + case .response(let data): XcodeMCPServerRuntimeTests.jsonRPCError(in: data) case .error(_, let code, let message): (code, message) case .accepted: nil } diff --git a/Tests/XcodeMCPProxyRuntimeTests/NativeHostConnectionTests.swift b/Tests/XcodeMCPServerRuntimeTests/NativeHostConnectionTests.swift similarity index 98% rename from Tests/XcodeMCPProxyRuntimeTests/NativeHostConnectionTests.swift rename to Tests/XcodeMCPServerRuntimeTests/NativeHostConnectionTests.swift index c40a4acf..289a0913 100644 --- a/Tests/XcodeMCPProxyRuntimeTests/NativeHostConnectionTests.swift +++ b/Tests/XcodeMCPServerRuntimeTests/NativeHostConnectionTests.swift @@ -3,10 +3,10 @@ import Logging import NIOConcurrencyHelpers import Testing import XcodeMCPCore -@testable import XcodeMCPProxyRuntime -import XcodeMCPProxyRuntimeContract -@testable import XcodeMCPProxyRuntimeTestSupport -import XcodeMCPProxyTestSupport +@testable import XcodeMCPServerRuntime +import XcodeMCPServerRuntimeContract +@testable import XcodeMCPServerRuntimeTestSupport +import XcodeMCPServerTestSupport @Suite(.serialized, .timeLimit(.minutes(1)), .asyncTestCleanup) struct NativeHostConnectionTests { @@ -38,7 +38,7 @@ struct NativeHostConnectionTests { if let progressToken { params["_meta"] = .object(["progressToken": progressToken]) } let data = try await connection.send(.object([ "jsonrpc": .string("2.0"), "id": id, "method": .string("tools/call"), "params": .object(params), - ]), owner: ProxySessionID(rawValue: owner), generation: generation) + ]), owner: ServerSessionID(rawValue: owner), generation: generation) guard case .object(let object)? = (try? JSONSerialization.jsonObject(with: data)).flatMap(JSONValue.init(any:)) else { throw NativeHostBrokerError("The connection returned a non-object response") } @@ -71,7 +71,7 @@ struct NativeHostConnectionTests { guard case .notification(let owner, let data) = try await fixture.events.nextValue(at: 0) else { Issue.record("The progress notification was not routed"); return } - #expect(owner == ProxySessionID(rawValue: "a")) + #expect(owner == ServerSessionID(rawValue: "a")) let progress = try JSONRPC.Wire.object(fromData: data) #expect((progress["params"] as? [String: Any])?["progressToken"] as? String == "token") } diff --git a/Tests/XcodeMCPProxyRuntimeTests/NativeHostRuntimeTests.swift b/Tests/XcodeMCPServerRuntimeTests/NativeHostRuntimeTests.swift similarity index 98% rename from Tests/XcodeMCPProxyRuntimeTests/NativeHostRuntimeTests.swift rename to Tests/XcodeMCPServerRuntimeTests/NativeHostRuntimeTests.swift index b2a79772..89302126 100644 --- a/Tests/XcodeMCPProxyRuntimeTests/NativeHostRuntimeTests.swift +++ b/Tests/XcodeMCPServerRuntimeTests/NativeHostRuntimeTests.swift @@ -1,12 +1,12 @@ -@testable import XcodeMCPProxyRuntimeTestSupport +@testable import XcodeMCPServerRuntimeTestSupport @testable import XcodeMCPCore import Foundation import NIO import NIOConcurrencyHelpers import NIOEmbedded import Testing -@testable import XcodeMCPProxyRuntime -import XcodeMCPProxyTestSupport +@testable import XcodeMCPServerRuntime +import XcodeMCPServerTestSupport @Suite(.serialized, .asyncTestCleanup) struct NativeHostRuntimeTests { diff --git a/Tests/XcodeMCPProxyRuntimeTests/NativeHostTestSupport.swift b/Tests/XcodeMCPServerRuntimeTests/NativeHostTestSupport.swift similarity index 91% rename from Tests/XcodeMCPProxyRuntimeTests/NativeHostTestSupport.swift rename to Tests/XcodeMCPServerRuntimeTests/NativeHostTestSupport.swift index 253396e0..d1c2c11e 100644 --- a/Tests/XcodeMCPProxyRuntimeTests/NativeHostTestSupport.swift +++ b/Tests/XcodeMCPServerRuntimeTests/NativeHostTestSupport.swift @@ -1,11 +1,11 @@ import Foundation import NIOConcurrencyHelpers import XcodeMCPCore -import XcodeMCPProxyTestSupport -@testable import XcodeMCPProxyRuntime +import XcodeMCPServerTestSupport +@testable import XcodeMCPServerRuntime -func makeConfig(requestTimeout: Duration?) -> ProxyRuntimeConfiguration { - ProxyRuntimeConfiguration( +func makeConfig(requestTimeout: Duration?) -> ServerRuntimeConfiguration { + ServerRuntimeConfiguration( maxMessageBytes: 1024, requestTimeout: requestTimeout, prewarmToolsList: false @@ -13,7 +13,7 @@ func makeConfig(requestTimeout: Duration?) -> ProxyRuntimeConfiguration { } func makeBridgeRuntimeConfig( - _ config: ProxyRuntimeConfiguration + _ config: ServerRuntimeConfiguration ) throws -> NativeHostRuntime.Configuration { try NativeHostRuntime.Configuration( nativeHostBundleURL: nativeHostBundleURLForTests(), developerDirectoryURL: config.developerDirectoryURL, diff --git a/Tests/XcodeMCPProxyRuntimeTests/ProxyLoggingTests.swift b/Tests/XcodeMCPServerRuntimeTests/ServerLoggingTests.swift similarity index 97% rename from Tests/XcodeMCPProxyRuntimeTests/ProxyLoggingTests.swift rename to Tests/XcodeMCPServerRuntimeTests/ServerLoggingTests.swift index 0e08c97b..944a52c6 100644 --- a/Tests/XcodeMCPProxyRuntimeTests/ProxyLoggingTests.swift +++ b/Tests/XcodeMCPServerRuntimeTests/ServerLoggingTests.swift @@ -1,10 +1,10 @@ import Logging import Testing -@testable import XcodeMCPProxyRuntime +@testable import XcodeMCPServerRuntime @Suite -struct ProxyLoggingTests { +struct ServerLoggingTests { @Test func logLevelParserTrimsAndMatches() async throws { let level = LogLevelParser.parse(" WARN ") #expect(level == .warning) diff --git a/Tests/XcodeMCPProxyRuntimeTests/StableToolCatalogTests.swift b/Tests/XcodeMCPServerRuntimeTests/StableToolCatalogTests.swift similarity index 99% rename from Tests/XcodeMCPProxyRuntimeTests/StableToolCatalogTests.swift rename to Tests/XcodeMCPServerRuntimeTests/StableToolCatalogTests.swift index 8ede1ce1..687e380b 100644 --- a/Tests/XcodeMCPProxyRuntimeTests/StableToolCatalogTests.swift +++ b/Tests/XcodeMCPServerRuntimeTests/StableToolCatalogTests.swift @@ -1,6 +1,6 @@ import Testing @testable import XcodeMCPCore -@testable import XcodeMCPProxyRuntime +@testable import XcodeMCPServerRuntime struct StableToolCatalogTests { @Test(arguments: ["XcodeListWindows", "GetTopCrashIssues", "GetCrashIssueLogs"]) diff --git a/Tests/XcodeMCPProxyRuntimeTests/ToolCallNormalizerTests.swift b/Tests/XcodeMCPServerRuntimeTests/ToolCallNormalizerTests.swift similarity index 98% rename from Tests/XcodeMCPProxyRuntimeTests/ToolCallNormalizerTests.swift rename to Tests/XcodeMCPServerRuntimeTests/ToolCallNormalizerTests.swift index ebb47311..619fb858 100644 --- a/Tests/XcodeMCPProxyRuntimeTests/ToolCallNormalizerTests.swift +++ b/Tests/XcodeMCPServerRuntimeTests/ToolCallNormalizerTests.swift @@ -1,7 +1,7 @@ import Foundation import Testing import XcodeMCPCore -@testable import XcodeMCPProxyRuntime +@testable import XcodeMCPServerRuntime struct ToolCallNormalizerTests { private func normalize(_ result: [String: Any], toolName: String, catalog: JSONValue? = nil) throws -> [String: Any] { diff --git a/Tests/XcodeMCPProxyRuntimeTests/ToolCatalogStartupLogFormatterTests.swift b/Tests/XcodeMCPServerRuntimeTests/ToolCatalogStartupLogFormatterTests.swift similarity index 96% rename from Tests/XcodeMCPProxyRuntimeTests/ToolCatalogStartupLogFormatterTests.swift rename to Tests/XcodeMCPServerRuntimeTests/ToolCatalogStartupLogFormatterTests.swift index a16fde3b..1c1fa260 100644 --- a/Tests/XcodeMCPProxyRuntimeTests/ToolCatalogStartupLogFormatterTests.swift +++ b/Tests/XcodeMCPServerRuntimeTests/ToolCatalogStartupLogFormatterTests.swift @@ -1,5 +1,5 @@ @testable import XcodeMCPCore -@testable import XcodeMCPProxyRuntime +@testable import XcodeMCPServerRuntime import Testing diff --git a/Tests/XcodeMCPProxyTestSupport/AsyncTestSupport.swift b/Tests/XcodeMCPServerTestSupport/AsyncTestSupport.swift similarity index 100% rename from Tests/XcodeMCPProxyTestSupport/AsyncTestSupport.swift rename to Tests/XcodeMCPServerTestSupport/AsyncTestSupport.swift diff --git a/Tests/XcodeMCPProxyTestSupport/DocumentationAssetFixture.swift b/Tests/XcodeMCPServerTestSupport/DocumentationAssetFixture.swift similarity index 100% rename from Tests/XcodeMCPProxyTestSupport/DocumentationAssetFixture.swift rename to Tests/XcodeMCPServerTestSupport/DocumentationAssetFixture.swift diff --git a/scripts/benchmark-live-server.py b/scripts/benchmark-live-server.py index f1c7ce5b..9922210a 100755 --- a/scripts/benchmark-live-server.py +++ b/scripts/benchmark-live-server.py @@ -14,9 +14,9 @@ DEFAULT_ENDPOINT = "http://localhost:8765/mcp" -ENDPOINT_ENV = "XCODE_MCP_PROXY_ENDPOINT" -DISCOVERY_FILE_ENV = "XCODE_MCP_PROXY_DISCOVERY_FILE" -CACHE_ROOT_ENV = "XCODE_MCP_PROXY_CACHE_ROOT" +ENDPOINT_ENV = "XCODE_MCP_SERVER_ENDPOINT" +DISCOVERY_FILE_ENV = "XCODE_MCP_SERVER_DISCOVERY_FILE" +CACHE_ROOT_ENV = "XCODE_MCP_SERVER_CACHE_ROOT" SESSION_HEADER = "Mcp-Session-Id" PROTOCOL_HEADER = "MCP-Protocol-Version" PROTOCOL_VERSION = "2025-06-18" @@ -209,7 +209,7 @@ async def close(self) -> None: def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser( description=( - "Benchmark an already-running xcode-mcp-proxy-server. Each agent " + "Benchmark an already-running xcode-mcp-server. Each agent " "opens one MCP session, sends DocumentationSearch requests in a " "closed loop, then reports throughput and per-request latency " "percentiles." @@ -218,7 +218,7 @@ def parse_args() -> argparse.Namespace: parser.add_argument( "--endpoint", help=( - "Proxy endpoint URL. Defaults to XCODE_MCP_PROXY_ENDPOINT, then the " + "Server endpoint URL. Defaults to XCODE_MCP_SERVER_ENDPOINT, then the " "discovery file, then http://localhost:8765/mcp." ), ) @@ -297,7 +297,7 @@ def discovery_file_path() -> str: root = os.path.expanduser(cache_root) else: root = os.path.expanduser("~/Library/Caches") - return os.path.join(root, "XcodeMCPProxy", "endpoint.json") + return os.path.join(root, "XcodeMCPServer", "endpoint.json") def read_discovery_endpoint( diff --git a/scripts/build-release.sh b/scripts/build-release.sh index dca4419a..4463bb4d 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -52,7 +52,7 @@ fi out_dir="$dist_base/$arch" bin_out="$out_dir/bin" products=( - "xcode-mcp-proxy-server" + "xcode-mcp-server" ) pushd "$repo_root" >/dev/null diff --git a/scripts/restore-source-mtimes.sh b/scripts/restore-source-mtimes.sh index 6367c92f..0ca76ebd 100755 --- a/scripts/restore-source-mtimes.sh +++ b/scripts/restore-source-mtimes.sh @@ -35,5 +35,5 @@ done < <( # retain the version string from the commit that produced the cache. find .build \ -type f \ - -path '*/ProxyBuildInfoPlugin/BuildInfo.generated.swift' \ + -path '*/ServerBuildInfoPlugin/BuildInfo.generated.swift' \ -delete 2> /dev/null || true diff --git a/scripts/smoke-homebrew.py b/scripts/smoke-homebrew.py index af3ab183..86aeb89c 100644 --- a/scripts/smoke-homebrew.py +++ b/scripts/smoke-homebrew.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""Exercise installed proxy and native-host MCP sessions using a disposable fixture.""" +"""Exercise installed server and native-host MCP sessions using a disposable fixture.""" import argparse import asyncio @@ -81,7 +81,7 @@ async def exercise(request, fixture): raise RuntimeError(f"Installed native backend could not list headless workspaces: {listed}") workspaces = listed.get("structuredContent", {}).get("workspaces", []) if any(workspace.get("kind") == "gui" for workspace in workspaces): - raise RuntimeError("Installed proxy exposed GUI workspaces during headless discovery") + raise RuntimeError("Installed server exposed GUI workspaces during headless discovery") result = await request(4, "tools/call", dict(name="XcodeRead", arguments=dict( workspaceIdentifier=str(fixture / "ProxyToolVerifierFixture.xcodeproj"), filePath="ProxyToolVerifierFixture/VerifierCore.swift", limit=40))) @@ -117,7 +117,7 @@ def verify_closed_pipes(executable, artifacts, environment): async def verify(prefix, version, fixture_source): - server = prefix / "bin/xcode-mcp-proxy-server" + server = prefix / "bin/xcode-mcp-server" bundle = prefix / "libexec/XcodeMCPNativeHost.app" actual = subprocess.check_output([str(server), "--version"], text=True).strip() if actual != version: @@ -128,10 +128,10 @@ async def verify(prefix, version, fixture_source): fixture = root / "Fixture" shutil.copytree(fixture_source, fixture) discovery = root / "endpoint.json" - environment = dict(os.environ, XCODE_MCP_PROXY_DISCOVERY_FILE=str(discovery), - XCODE_MCP_PROXY_CACHE_ROOT=str(root / "cache")) + environment = dict(os.environ, XCODE_MCP_SERVER_DISCOVERY_FILE=str(discovery), + XCODE_MCP_SERVER_CACHE_ROOT=str(root / "cache")) environment.pop("XCODE_MCP_NATIVE_HOST_BUNDLE", None) - environment.pop("XCODE_MCP_PROXY_ENDPOINT", None) + environment.pop("XCODE_MCP_SERVER_ENDPOINT", None) await asyncio.to_thread(verify_closed_pipes, bundle / "Contents/MacOS/xcode-mcp-native-host", root / "disconnect-artifacts", environment) @@ -153,11 +153,11 @@ async def launch(*command): await asyncio.wait_for(native.wait(), timeout=30) if native.returncode: raise RuntimeError(f"Native helper exited with {native.returncode}") - proxy = await launch(server, "--host", "127.0.0.1", "--port", "0") + server_process = await launch(server, "--host", "127.0.0.1", "--port", "0") async with asyncio.timeout(60): while not discovery.exists(): - if proxy.returncode is not None: - raise RuntimeError(f"Proxy exited with {proxy.returncode}") + if server_process.returncode is not None: + raise RuntimeError(f"Server exited with {server_process.returncode}") await asyncio.sleep(0.05) endpoint = json.loads(discovery.read_text())["url"] await exercise(http_client(endpoint), fixture) @@ -174,7 +174,7 @@ async def launch(*command): except TimeoutError: os.killpg(process.pid, signal.SIGKILL) await process.wait() - print("Installed CLI version, native signature, early disconnect, direct MCP, and proxy MCP passed.") + print("Installed CLI version, native signature, early disconnect, direct MCP, and server MCP passed.") def main(): diff --git a/scripts/verify-proxy-target-boundaries.sh b/scripts/verify-server-target-boundaries.sh similarity index 52% rename from scripts/verify-proxy-target-boundaries.sh rename to scripts/verify-server-target-boundaries.sh index 1af6dedd..4390e787 100755 --- a/scripts/verify-proxy-target-boundaries.sh +++ b/scripts/verify-server-target-boundaries.sh @@ -2,7 +2,7 @@ set -euo pipefail if ! command -v jq > /dev/null 2>&1; then - echo "error: verify-proxy-target-boundaries requires jq" >&2 + echo "error: verify-server-target-boundaries requires jq" >&2 exit 2 fi @@ -31,33 +31,33 @@ reject_matches() { } reject_matches \ - "permission automation must not import native execution, proxy routing, or SDK modules" \ - '^[[:space:]]*import[[:space:]]+(XcodeMCPCore|XcodeMCPKit|XcodeMCPNative[A-Za-z0-9_]*|XcodeMCPProxy[A-Za-z0-9_]*)([[:space:].;]|$)' \ + "permission automation must not import native execution, server routing, or SDK modules" \ + '^[[:space:]]*import[[:space:]]+(XcodeMCPCore|XcodeMCPKit|XcodeMCPNative[A-Za-z0-9_]*|XcodeMCPServer[A-Za-z0-9_]*)([[:space:].;]|$)' \ Sources/XcodeMCPPermissionAutomation reject_matches \ - "XcodeMCPProxyRuntime must not import NIOHTTP1" \ + "XcodeMCPServerRuntime must not import NIOHTTP1" \ '^import NIOHTTP1$' \ - Sources/XcodeMCPProxyRuntime + Sources/XcodeMCPServerRuntime reject_matches \ - "XcodeMCPProxyRuntime must not own the facade aggregate configuration" \ + "XcodeMCPServerRuntime must not own the facade aggregate configuration" \ 'listenHost|listenPort|discoveryFileURL' \ - Sources/XcodeMCPProxyRuntime + Sources/XcodeMCPServerRuntime reject_matches \ - "XcodeMCPProxyKit must not own the HTTP listener lifecycle" \ - 'ServerBootstrap|ProxyAcceptedChannel|listenChannels|childChannelInitializer' \ - Sources/XcodeMCPProxyKit + "XcodeMCPServerKit must not own the HTTP listener lifecycle" \ + 'ServerBootstrap|ServerAcceptedChannel|listenChannels|childChannelInitializer' \ + Sources/XcodeMCPServerKit reject_matches \ - "XcodeMCPProxyHTTP references a host process type" \ + "XcodeMCPServerHTTP references a host process type" \ '(^|[^[:alnum:]_])(Upstream|MCPProcess)[A-Za-z0-9_]*([^[:alnum:]_]|$)' \ - Sources/XcodeMCPProxyHTTP + Sources/XcodeMCPServerHTTP reject_matches \ - "native host, installation, and wire modules must not import NIO or the proxy/client runtime" \ - '^[[:space:]]*([[:alnum:]_@()]+[[:space:]]+)*import[[:space:]]+((class|enum|func|let|protocol|struct|typealias|var)[[:space:]]+)?(NIO[[:alnum:]_]*|CNIO[[:alnum:]_]*|_NIO[[:alnum:]_]*|XcodeMCPCore|XcodeMCPKit|XcodeMCPProxy[[:alnum:]_]*)([[:space:].;]|$)' \ + "native host, installation, and wire modules must not import NIO or the server/client runtime" \ + '^[[:space:]]*([[:alnum:]_@()]+[[:space:]]+)*import[[:space:]]+((class|enum|func|let|protocol|struct|typealias|var)[[:space:]]+)?(NIO[[:alnum:]_]*|CNIO[[:alnum:]_]*|_NIO[[:alnum:]_]*|XcodeMCPCore|XcodeMCPKit|XcodeMCPServer[[:alnum:]_]*)([[:space:].;]|$)' \ Sources/XcodeMCPNativeHost Sources/XcodeMCPNativeRuntime Sources/XcodeMCPInstallation Sources/XcodeMCPWire package_description="$(swift package describe --type json)" @@ -70,17 +70,17 @@ if ! jq -e ' def directlyUses($target; $dependency): ($graph[$target] | index($dependency)) != null; def hasOnlyNativeDependencies($target): - dependencies($target) | all(test("^(NIO|CNIO|_NIO|XcodeMCPCore$|XcodeMCPKit$|XcodeMCPProxy|XcodeMCPPermissionAutomation$)") | not); + dependencies($target) | all(test("^(NIO|CNIO|_NIO|XcodeMCPCore$|XcodeMCPKit$|XcodeMCPServer|XcodeMCPPermissionAutomation$)") | not); hasOnlyNativeDependencies("XcodeMCPNativeHost") and hasOnlyNativeDependencies("XcodeMCPNativeRuntime") and ($graph["XcodeMCPInstallation"] == []) and ($graph["XcodeMCPWire"] == []) and ($graph["XcodeMCPPermissionAutomation"] == ["Logging"]) and - excludes("XcodeMCPProxyRuntime"; ["XcodeMCPPermissionAutomation"]) and - excludes("XcodeMCPProxyHTTP"; ["XcodeMCPPermissionAutomation"]) and + excludes("XcodeMCPServerRuntime"; ["XcodeMCPPermissionAutomation"]) and + excludes("XcodeMCPServerHTTP"; ["XcodeMCPPermissionAutomation"]) and directlyUses("XcodeMCPNativeHost"; "XcodeMCPInstallation") and directlyUses("XcodeMCPNativeRuntime"; "XcodeMCPInstallation") and - directlyUses("XcodeMCPProxyRuntime"; "XcodeMCPInstallation") and + directlyUses("XcodeMCPServerRuntime"; "XcodeMCPInstallation") and directlyUses("XcodeMCPNativeHost"; "XcodeMCPNativeRuntime") and directlyUses("XcodeMCPNativeHost"; "XcodeMCPWire") and directlyUses("XcodeMCPNativeRuntime"; "XcodeMCPWire") and @@ -88,26 +88,26 @@ if ! jq -e ' ($graph["XcodeMCPCore"] == ["XcodeMCPWire"]) and (dependencies("XcodeMCPKit") == ["XcodeMCPCore", "XcodeMCPWire"]) and (dependencies("XcodeMCPKitTesting") == ["XcodeMCPCore", "XcodeMCPKit", "XcodeMCPWire"]) and - excludes("XcodeMCPProxyRuntime"; ["XcodeMCPKit", "XcodeMCPProxyHTTP", "XcodeMCPProxyKit"]) and - excludes("XcodeMCPProxyHTTP"; ["XcodeMCPKit", "XcodeMCPProxyRuntime", "XcodeMCPProxyKit"]) and - excludes("XcodeMCPProxyRuntimeContract"; ["XcodeMCPKit", "XcodeMCPProxyRuntime", "XcodeMCPProxyHTTP", "XcodeMCPProxyKit"]) and - excludes("XcodeMCPCoreTests"; ["XcodeMCPKit", "XcodeMCPProxyRuntime", "XcodeMCPProxyHTTP", "XcodeMCPProxyKit"]) and - excludes("XcodeMCPProcessRuntimeTests"; ["XcodeMCPKit", "XcodeMCPProxyRuntime", "XcodeMCPProxyHTTP", "XcodeMCPProxyKit"]) and - excludes("XcodeMCPProxyRuntimeTests"; ["XcodeMCPKit", "XcodeMCPProxyHTTP", "XcodeMCPProxyKit"]) and - excludes("XcodeMCPProxyRuntimeTestSupport"; ["XcodeMCPKit", "XcodeMCPProxyHTTP", "XcodeMCPProxyKit"]) and - excludes("XcodeMCPProxyTestSupport"; ["XcodeMCPKit", "XcodeMCPProxyRuntime", "XcodeMCPProxyHTTP", "XcodeMCPProxyKit"]) and - excludes("XcodeMCPProxyHTTPTests"; ["XcodeMCPKit", "XcodeMCPProxyRuntime", "XcodeMCPProxyKit"]) and - excludes("XcodeMCPProxyKit"; ["XcodeMCPKit"]) and - directlyUses("XcodeMCPProxyRuntime"; "XcodeMCPCore") and - directlyUses("XcodeMCPProxyHTTP"; "XcodeMCPCore") and - directlyUses("XcodeMCPProxyHTTP"; "XcodeMCPProxyRuntimeContract") and - directlyUses("XcodeMCPProxyRuntime"; "XcodeMCPProxyRuntimeContract") and - directlyUses("XcodeMCPProxyKit"; "XcodeMCPProxyRuntime") and - directlyUses("XcodeMCPProxyKit"; "XcodeMCPProxyHTTP") and - directlyUses("XcodeMCPProxyKit"; "XcodeMCPPermissionAutomation") + excludes("XcodeMCPServerRuntime"; ["XcodeMCPKit", "XcodeMCPServerHTTP", "XcodeMCPServerKit"]) and + excludes("XcodeMCPServerHTTP"; ["XcodeMCPKit", "XcodeMCPServerRuntime", "XcodeMCPServerKit"]) and + excludes("XcodeMCPServerRuntimeContract"; ["XcodeMCPKit", "XcodeMCPServerRuntime", "XcodeMCPServerHTTP", "XcodeMCPServerKit"]) and + excludes("XcodeMCPCoreTests"; ["XcodeMCPKit", "XcodeMCPServerRuntime", "XcodeMCPServerHTTP", "XcodeMCPServerKit"]) and + excludes("XcodeMCPProcessRuntimeTests"; ["XcodeMCPKit", "XcodeMCPServerRuntime", "XcodeMCPServerHTTP", "XcodeMCPServerKit"]) and + excludes("XcodeMCPServerRuntimeTests"; ["XcodeMCPKit", "XcodeMCPServerHTTP", "XcodeMCPServerKit"]) and + excludes("XcodeMCPServerRuntimeTestSupport"; ["XcodeMCPKit", "XcodeMCPServerHTTP", "XcodeMCPServerKit"]) and + excludes("XcodeMCPServerTestSupport"; ["XcodeMCPKit", "XcodeMCPServerRuntime", "XcodeMCPServerHTTP", "XcodeMCPServerKit"]) and + excludes("XcodeMCPServerHTTPTests"; ["XcodeMCPKit", "XcodeMCPServerRuntime", "XcodeMCPServerKit"]) and + excludes("XcodeMCPServerKit"; ["XcodeMCPKit"]) and + directlyUses("XcodeMCPServerRuntime"; "XcodeMCPCore") and + directlyUses("XcodeMCPServerHTTP"; "XcodeMCPCore") and + directlyUses("XcodeMCPServerHTTP"; "XcodeMCPServerRuntimeContract") and + directlyUses("XcodeMCPServerRuntime"; "XcodeMCPServerRuntimeContract") and + directlyUses("XcodeMCPServerKit"; "XcodeMCPServerRuntime") and + directlyUses("XcodeMCPServerKit"; "XcodeMCPServerHTTP") and + directlyUses("XcodeMCPServerKit"; "XcodeMCPPermissionAutomation") ' <<< "${package_description}" >/dev/null; then - echo "error: package dependencies violate the native-host, shared-core, or proxy ownership boundaries" >&2 + echo "error: package dependencies violate the native-host, shared-core, or server ownership boundaries" >&2 exit 1 fi -echo "Native host and proxy target boundaries verified." +echo "Native host and server target boundaries verified."