Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2025
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
4 changes: 2 additions & 2 deletions Sources/MCP/Client/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public actor Client {

// 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")
let request: Request<ListTools>
if let cursor = cursor {
Expand All @@ -373,7 +373,7 @@ public actor Client {
request = ListTools.request(.init())
}
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 -> (
Expand Down
6 changes: 3 additions & 3 deletions Tests/MCPTests/RoundtripTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ struct RoundtripTests {
}

let listToolsTask = Task {
let result = try await client.listTools()
#expect(result.count == 1)
#expect(result[0].name == "add")
let (tools, _) = try await client.listTools()
#expect(tools.count == 1)
#expect(tools[0].name == "add")
}

let callToolTask = Task {
Expand Down