feat(mcp): add convenience methods without cursor parameter

Add overloaded methods for list operations (tools, resources, templates, prompts)
 that don't require a cursor parameter, simplifying the API for basic use cases
 where pagination is not needed.
This commit is contained in:
Christian Tzolov 2024-12-13 09:15:28 +01:00
commit be31c6119c

View file

@ -111,6 +111,15 @@ public class McpSyncClient implements AutoCloseable {
* Send a tools/list request.
* @return the list of tools result.
*/
public McpSchema.ListToolsResult listTools() {
return this.delegate.listTools().block();
}
/**
* Send a tools/list request.
* @param cursor the cursor
* @return the list of tools result.
*/
public McpSchema.ListToolsResult listTools(String cursor) {
return this.delegate.listTools(cursor).block();
}
@ -128,6 +137,14 @@ public class McpSyncClient implements AutoCloseable {
return this.delegate.listResources(cursor).block();
}
/**
* Send a resources/list request.
* @return the list of resources result.
*/
public McpSchema.ListResourcesResult listResources() {
return this.delegate.listResources().block();
}
/**
* Send a resources/read request.
* @param resource the resource to read
@ -158,6 +175,14 @@ public class McpSyncClient implements AutoCloseable {
return this.delegate.listResourceTemplates(cursor).block();
}
/**
* Request a list of resource templates the server has.
* @return the list of resource templates result.
*/
public McpSchema.ListResourceTemplatesResult listResourceTemplates() {
return this.delegate.listResourceTemplates().block();
}
/**
* List Changed Notification. When the list of available resources changes, servers
* that declared the listChanged capability SHOULD send a notification:
@ -195,6 +220,10 @@ public class McpSyncClient implements AutoCloseable {
return this.delegate.listPrompts(cursor).block();
}
public ListPromptsResult listPrompts() {
return this.delegate.listPrompts().block();
}
public GetPromptResult getPrompt(GetPromptRequest getPromptRequest) {
return this.delegate.getPrompt(getPromptRequest).block();
}