Some requests in McpAsyncServerExchange make a point of failing fast if functionality not supported, such the condition on line 146
|
public Mono<McpSchema.CreateMessageResult> createMessage(McpSchema.CreateMessageRequest createMessageRequest) { |
|
if (this.clientCapabilities == null) { |
|
return Mono |
|
.error(new IllegalStateException("Client must be initialized. Call the initialize method first!")); |
|
} |
|
if (this.clientCapabilities.sampling() == null) { |
|
return Mono.error(new IllegalStateException("Client must be configured with sampling capabilities")); |
|
} |
|
return this.session.sendRequest(McpSchema.METHOD_SAMPLING_CREATE_MESSAGE, createMessageRequest, |
|
CREATE_MESSAGE_RESULT_TYPE_REF); |
|
} |
listRoots does not do the same
|
public Mono<McpSchema.ListRootsResult> listRoots(String cursor) { |
|
return this.session.sendRequest(McpSchema.METHOD_ROOTS_LIST, new McpSchema.PaginatedRequest(cursor), |
|
LIST_ROOTS_RESULT_TYPE_REF); |
|
} |
For example, add this
if (this.clientCapabilities.roots() == null) {
return Mono.error(new IllegalStateException("Client must be configured with root listing capabilities"));
}
Some requests in McpAsyncServerExchange make a point of failing fast if functionality not supported, such the condition on line 146
java-sdk/mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java
Lines 141 to 151 in fd00498
listRootsdoes not do the samejava-sdk/mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java
Lines 227 to 230 in fd00498
For example, add this