Resources and prompts cannot be added after server start (#18)

* Resources and prompts cannot be added after server start #17
This commit is contained in:
Mariano Gonzalez 2025-02-26 11:49:30 +01:00 • committed by GitHub
commit 2c500b9cdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -138,18 +138,14 @@ public class McpAsyncServer {
}
// Add resources API handlers if provided
if (!Utils.isEmpty(this.resources)) {
if (this.serverCapabilities.resources() != null) {
requestHandlers.put(McpSchema.METHOD_RESOURCES_LIST, resourcesListRequestHandler());
requestHandlers.put(McpSchema.METHOD_RESOURCES_READ, resourcesReadRequestHandler());
}
// Add resource templates API handlers if provided.
if (!Utils.isEmpty(this.resourceTemplates)) {
requestHandlers.put(McpSchema.METHOD_RESOURCES_TEMPLATES_LIST, resourceTemplateListRequestHandler());
}
// Add prompts API handlers if provider exists
if (!Utils.isEmpty(this.prompts)) {
if (this.serverCapabilities.prompts() != null) {
requestHandlers.put(McpSchema.METHOD_PROMPT_LIST, promptsListRequestHandler());
requestHandlers.put(McpSchema.METHOD_PROMPT_GET, promptsGetRequestHandler());
}