Update Client.listTools return type to include next cursor (#54)

This commit is contained in:
Mattt 2025-04-09 16:20:55 -07:00 • committed by GitHub
commit 20d4fe6f5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -364,7 +364,7 @@ public actor Client {
// MARK: - Tools // MARK: - Tools
public func listTools(cursor: String? = nil) async throws -> [Tool] { public func listTools(cursor: String? = nil) async throws -> (tools: [Tool], nextCursor: String?) {
try validateServerCapability(\.tools, "Tools") try validateServerCapability(\.tools, "Tools")
let request: Request<ListTools> let request: Request<ListTools>
if let cursor = cursor { if let cursor = cursor {
@ -373,7 +373,7 @@ public actor Client {
request = ListTools.request(.init()) request = ListTools.request(.init())
} }
let result = try await send(request) let result = try await send(request)
return result.tools return (tools: result.tools, nextCursor: result.nextCursor)
} }
public func callTool(name: String, arguments: [String: Value]? = nil) async throws -> ( public func callTool(name: String, arguments: [String: Value]? = nil) async throws -> (

View file

@ -144,9 +144,9 @@ struct RoundtripTests {
} }
let listToolsTask = Task { let listToolsTask = Task {
let result = try await client.listTools() let (tools, _) = try await client.listTools()
#expect(result.count == 1) #expect(tools.count == 1)
#expect(result[0].name == "add") #expect(tools[0].name == "add")
} }
let callToolTask = Task { let callToolTask = Task {