Update Client.listTools return type to include next cursor (#54)
This commit is contained in:
parent
cfcead8121
commit
20d4fe6f5a
2 changed files with 5 additions and 5 deletions
|
|
@ -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 -> (
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue