Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Docs/migrations/native-backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ The current server API is documented in
| 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. |
| `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. |
| `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. |

Expand Down
1 change: 0 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ let package = Package(
dependencies: [
"XcodeMCPProxyRuntimeContract",
"XcodeMCPCore",
"XcodeMCPKit",
"XcodeMCPProxyRuntime",
"XcodeMCPProxyHTTP",
"XcodeMCPPermissionAutomation",
Expand Down
21 changes: 4 additions & 17 deletions Sources/XcodeMCPProxyKit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ may be incomplete, even though the server lifecycle has stopped.
- `approvalPolicy`: `.manual` by default. `.automatic` approves MCP connection dialogs for agents connecting directly to GUI Xcode, using macOS Accessibility access.
- `maxBodyBytes`: positive maximum HTTP request body size.
- `requestTimeout`: a positive `Duration`, or `nil` for no timeout, the default. A client that gives up cancels its request or disconnects, which also ends the work; starting a host stays bounded either way.
- `initializeHandshake`: typed upstream initialization for embedding.
- `discovery`: `.disabled`, `.defaultLocation`, or `.file(URL)`.
- `prewarmToolsList`: whether discovery begins during startup.

Expand All @@ -81,22 +80,10 @@ 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).

```swift
import Foundation
import XcodeMCPKit
import XcodeMCPProxyKit

let configuration = XcodeMCPProxyServerConfiguration(
initializeHandshake: .init(
clientInfo: .init(name: "EmbeddingClient", version: "1.0"),
capabilities: ["experimental": ["embedding": true]]
)
)
```

The handshake omits `roots`, `sampling`, and `elicitation`: every client
session shares an Xcode host, so no client can answer the host requests those
capabilities allow.
Every host receives the same `initialize` request: the client name
`XcodeMCPKit` and no client capabilities. Initialize parameters from connected
clients do not reach a host. Every client session shares a host, so no client
can answer the host requests that `roots`, `sampling`, or `elicitation` allow.

`snapshot()` returns a sanitized read model: lifecycle phase, endpoint, and one
entry per owned headless host with its identifier, kind, state, and active
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ protocol ProxyServerPermissionDialogAutoApprover: Sendable {
}

extension XcodePermissionDialogAutomation.AutoApprover: ProxyServerPermissionDialogAutoApprover {
static func liveForAllAgents(assistantName: String?) -> Self {
let names = Set(["XcodeMCPKit", "XcodeMCPProxyKit"] + [assistantName].compactMap { $0 })
static func liveForAllAgents() -> Self {
let names: Set<String> = ["XcodeMCPKit", "XcodeMCPProxyKit"]
return Self(
configuration: .init(
permissionDialogProcessIDs: {
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeMCPProxyKit/XcodeMCPProxyServer+Startup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ extension XcodeMCPProxyServer {
runtime: runtime,
endpoint: boundEndpoint,
autoApprover: configuration.approvalPolicy == .automatic
? dependencies.makeAutoApprover(configuration) : nil
? dependencies.makeAutoApprover() : nil
)
} catch {
let operationError = error
Expand Down
86 changes: 5 additions & 81 deletions Sources/XcodeMCPProxyKit/XcodeMCPProxyServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import XcodeMCPProxyRuntimeContract
import XcodeMCPCore
import Foundation
import Logging
import XcodeMCPKit
import XcodeMCPProxyHTTP
import XcodeMCPProxyRuntime
import XcodeMCPPermissionAutomation
Expand Down Expand Up @@ -59,49 +58,6 @@ public struct XcodeMCPProxyServerConfiguration: Equatable, Sendable {
case automatic
}

/// Initialize handshake values sent from the proxy to native helpers.
///
/// Properties left as `nil` use the built-in defaults.
public struct InitializeHandshake: Equatable, Sendable {
/// Upstream client information for the initialize handshake.
public struct ClientInfo: Equatable, Sendable {
/// Client name to advertise to the native helper.
public var name: String?

/// Client version to advertise to the native helper.
public var version: String?

/// Creates upstream client information.
public init(name: String? = nil, version: String? = nil) {
self.name = name
self.version = version
}
}

/// Protocol version to send in initialize params.
public var protocolVersion: String?

/// Client info to send in initialize params.
public var clientInfo: ClientInfo?

/// Capability object to send in initialize params.
///
/// `roots`, `sampling`, and `elicitation` are not sent: every client session shares an Xcode
/// host, so no client can answer the host requests those capabilities allow.
public var capabilities: [String: MCPJSONValue]?

/// Creates initialize handshake overrides.
public init(
protocolVersion: String? = nil,
clientInfo: ClientInfo? = nil,
capabilities: [String: MCPJSONValue]? = nil
) {
self.protocolVersion = protocolVersion
self.clientInfo = clientInfo
self.capabilities = capabilities
}
}

/// HTTP bind address.
public var bindAddress: BindAddress

Expand All @@ -124,9 +80,6 @@ public struct XcodeMCPProxyServerConfiguration: Equatable, Sendable {
/// or disconnects, which also ends the work. Starting a host stays bounded either way.
public var requestTimeout: Duration?

/// Initialize handshake overrides. `nil` uses the built-in defaults.
public var initializeHandshake: InitializeHandshake?

/// Endpoint discovery policy.
public var discovery: Discovery

Expand All @@ -150,7 +103,6 @@ public struct XcodeMCPProxyServerConfiguration: Equatable, Sendable {
/// - discovery: Endpoint discovery policy.
/// - approvalPolicy: Xcode MCP connection dialog automation policy. Defaults to `.manual`.
/// - prewarmToolsList: Whether to fetch native tool catalogs during startup.
/// - initializeHandshake: Explicit upstream initialize handshake override.
/// - enablesDebugEndpoints: Whether to serve the debug endpoints on a loopback listener. Defaults to `false`.
public init(
bindAddress: BindAddress = .localhost(),
Expand All @@ -159,7 +111,6 @@ public struct XcodeMCPProxyServerConfiguration: Equatable, Sendable {
sharesCompilationCache: Bool = false,
maxBodyBytes: Int = 1_048_576,
requestTimeout: Duration? = nil,
initializeHandshake: InitializeHandshake? = nil,
discovery: Discovery = .defaultLocation,
approvalPolicy: ApprovalPolicy = .manual,
prewarmToolsList: Bool = true,
Expand All @@ -172,7 +123,6 @@ public struct XcodeMCPProxyServerConfiguration: Equatable, Sendable {
self.approvalPolicy = approvalPolicy
self.maxBodyBytes = maxBodyBytes
self.requestTimeout = requestTimeout
self.initializeHandshake = initializeHandshake
self.discovery = discovery
self.prewarmToolsList = prewarmToolsList
self.enablesDebugEndpoints = enablesDebugEndpoints
Expand Down Expand Up @@ -344,7 +294,7 @@ public final class XcodeMCPProxyServer: Sendable {
var discoveryClient: DiscoveryClient
var processID: @Sendable () -> Int
var makeRuntime: @Sendable (ProxyRuntimeConfiguration) throws -> any ProxyRuntimeServing
var makeAutoApprover: @Sendable (XcodeMCPProxyServerConfiguration) -> any ProxyServerPermissionDialogAutoApprover
var makeAutoApprover: @Sendable () -> any ProxyServerPermissionDialogAutoApprover
var makeHTTPGateway:
@Sendable (
ProxyHTTPConfiguration,
Expand All @@ -358,10 +308,8 @@ public final class XcodeMCPProxyServer: Sendable {
Int(ProcessInfo.processInfo.processIdentifier)
},
makeRuntime: @escaping @Sendable (ProxyRuntimeConfiguration) throws -> any ProxyRuntimeServing,
makeAutoApprover: @escaping @Sendable (XcodeMCPProxyServerConfiguration) -> any ProxyServerPermissionDialogAutoApprover = { configuration in
XcodePermissionDialogAutomation.AutoApprover.liveForAllAgents(
assistantName: configuration.initializeHandshake?.clientInfo?.name
)
makeAutoApprover: @escaping @Sendable () -> any ProxyServerPermissionDialogAutoApprover = {
XcodePermissionDialogAutomation.AutoApprover.liveForAllAgents()
},
makeHTTPGateway: @escaping @Sendable (
ProxyHTTPConfiguration,
Expand Down Expand Up @@ -481,37 +429,13 @@ extension XcodeMCPProxyServerConfiguration {
if let requestTimeout, requestTimeout <= .zero {
throw XcodeMCPProxyServer.LifecycleError.invalidConfiguration("requestTimeout must be positive; use nil to disable it")
}
let configuration = ProxyRuntimeConfiguration(
return ProxyRuntimeConfiguration(
nativeHostBundleURL: nativeHostBundleURL,
developerDirectoryURL: developerDirectoryURL,
sharesCompilationCache: sharesCompilationCache,
maxMessageBytes: maxBodyBytes,
requestTimeout: requestTimeout,
prewarmToolsList: prewarmToolsList,
initializeParamsOverride: initializeHandshake.map { handshake in
.init(
protocolVersion: handshake.protocolVersion,
clientName: handshake.clientInfo?.name,
clientVersion: handshake.clientInfo?.version,
capabilities: handshake.capabilities?.mapValues(ProxyRuntimeConfiguration.JSONValue.init)
)
}
prewarmToolsList: prewarmToolsList
)
try configuration.validateModernProtocolConfiguration()
return configuration
}
}

private extension ProxyRuntimeConfiguration.JSONValue {
init(_ value: MCPJSONValue) {
switch value {
case .object(let object): self = .object(object.mapValues(Self.init))
case .array(let array): self = .array(array.map(Self.init))
case .string(let string): self = .string(string)
case .integer(let integer): self = .number(.integer(integer))
case .double(let double): self = .number(.double(double))
case .bool(let bool): self = .bool(bool)
case .null: self = .null
}
}
}
13 changes: 9 additions & 4 deletions Sources/XcodeMCPProxyRuntime/Broker/NativeHostBroker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable {
/// Bounds a cleanup close while client requests have no timeout, so a host that never answers
/// does not keep the model from being bound again.
static let cleanupFallbackTimeout: Duration = .seconds(60)
/// The `initialize` params every host receives. Client sessions share a host, so the handshake
/// advertises no capability that would let the host send requests to a client.
static let initializeParams: JSONValue = .object([
"protocolVersion": .string(MCP.ProtocolVersion.current),
"capabilities": .object([:]),
"clientInfo": .object(["name": .string("XcodeMCPKit"), "version": .string("dev")]),
])
/// Bounds a host's initialize handshake even when client requests have no timeout.
private static let handshakeTimeoutLimit: Duration = .seconds(60)
/// Bounds an internal catalog load even when client requests have no timeout.
Expand Down Expand Up @@ -96,8 +103,7 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable {
maxBodyBytes: configuration.maxMessageBytes)
let connection = NativeHostConnection(
factory: sessionFactory(processConfiguration),
handshake: .object(InitializeHandshakeJSON.resolved(
initializeParamsOverride: configuration.initializeParamsOverride)),
handshake: Self.initializeParams,
handshakeTimeout: handshakeTimeout, catalogTimeout: catalogTimeout,
prewarmsCatalog: configuration.prewarmToolsList, clock: clock,
logger: ProxyLogging.make("native-host"),
Expand All @@ -123,8 +129,7 @@ package final class NativeHostBroker: ProxyRuntimeServing, Sendable {
guard !storage.stopped, storage.resetsInProgress == 0 else { throw CancellationError() }
if let connection = storage.guiConnection { return connection }
let connection = NativeHostConnection(factory: guiSessionFactory,
handshake: .object(InitializeHandshakeJSON.resolved(
initializeParamsOverride: configuration.initializeParamsOverride)),
handshake: Self.initializeParams,
handshakeTimeout: handshakeTimeout, catalogTimeout: catalogTimeout,
prewarmsCatalog: false, clock: clock, logger: ProxyLogging.make("mcpbridge"),
onEvent: { [weak self] event in self?.receive(event, from: Self.guiHostIdentifier) })
Expand Down

This file was deleted.

Loading