Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Commit be31c61

Browse files
committed
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.
1 parent c332300 commit be31c61

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

spring-ai-mcp-core/src/main/java/org/springframework/ai/mcp/client/McpSyncClient.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ public McpSchema.CallToolResult callTool(McpSchema.CallToolRequest callToolReque
111111
* Send a tools/list request.
112112
* @return the list of tools result.
113113
*/
114+
public McpSchema.ListToolsResult listTools() {
115+
return this.delegate.listTools().block();
116+
}
117+
118+
/**
119+
* Send a tools/list request.
120+
* @param cursor the cursor
121+
* @return the list of tools result.
122+
*/
114123
public McpSchema.ListToolsResult listTools(String cursor) {
115124
return this.delegate.listTools(cursor).block();
116125
}
@@ -128,6 +137,14 @@ public McpSchema.ListResourcesResult listResources(String cursor) {
128137
return this.delegate.listResources(cursor).block();
129138
}
130139

140+
/**
141+
* Send a resources/list request.
142+
* @return the list of resources result.
143+
*/
144+
public McpSchema.ListResourcesResult listResources() {
145+
return this.delegate.listResources().block();
146+
}
147+
131148
/**
132149
* Send a resources/read request.
133150
* @param resource the resource to read
@@ -158,6 +175,14 @@ public McpSchema.ListResourceTemplatesResult listResourceTemplates(String cursor
158175
return this.delegate.listResourceTemplates(cursor).block();
159176
}
160177

178+
/**
179+
* Request a list of resource templates the server has.
180+
* @return the list of resource templates result.
181+
*/
182+
public McpSchema.ListResourceTemplatesResult listResourceTemplates() {
183+
return this.delegate.listResourceTemplates().block();
184+
}
185+
161186
/**
162187
* List Changed Notification. When the list of available resources changes, servers
163188
* that declared the listChanged capability SHOULD send a notification:
@@ -195,6 +220,10 @@ public ListPromptsResult listPrompts(String cursor) {
195220
return this.delegate.listPrompts(cursor).block();
196221
}
197222

223+
public ListPromptsResult listPrompts() {
224+
return this.delegate.listPrompts().block();
225+
}
226+
198227
public GetPromptResult getPrompt(GetPromptRequest getPromptRequest) {
199228
return this.delegate.getPrompt(getPromptRequest).block();
200229
}

0 commit comments

Comments
 (0)