Skip to content

Commit ea31fa4

Browse files
committed
Make generated MCP clients Sendable by default
1 parent 98cb754 commit ea31fa4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Sources/SwiftMCPMacros/MCPServerMacro.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ public func callPrompt(_ name: String, arguments: [String: Sendable]) async thro
655655
) -> String {
656656
var lines: [String] = []
657657
lines.append(contentsOf: clientTypeDocCommentLines(description: serverDescription))
658-
lines.append("public struct Client {")
658+
lines.append("public struct Client: Sendable {")
659659
lines.append(" public let proxy: MCPServerProxy")
660660
lines.append("")
661661
lines.append(contentsOf: initDocCommentLines())

Tests/SwiftMCPTests/MCPClientGenerationTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ actor ClientTestServer {
104104

105105
@Suite("Generated Client Tests", .tags(.client))
106106
struct MCPClientGenerationTests {
107+
@Test("Generated client is Sendable")
108+
func generatedClientIsSendable() {
109+
requireSendable(ClientTestServer.Client.self)
110+
}
111+
107112
@Test("Preserves Int results and default parameters", .enabled(if: false))
108113
func preservesIntAndDefaults() async throws {
109114
let (server, client, proxy) = try await makeClient()
@@ -176,3 +181,5 @@ private func makeClient() async throws -> (ClientTestServer, ClientTestServer.Cl
176181
extension Tag {
177182
@Tag static var client: Self
178183
}
184+
185+
private func requireSendable<T: Sendable>(_: T.Type) {}

0 commit comments

Comments
 (0)