Closed
Description
Bug description
The request handlers for resources, templates and prompts are only added if any are provided at the moment of building the server. Although methods like addResource() do function as expected, request with methods such as resources/list
or resources/read
fail with no such method errors because the handlers are not there, even if the server does support the capability.
Environment
Java SDK, async server
Steps to reproduce
Create a server like this:
return McpServer.async(createTransport())
.serverInfo(config.getServerName(), config.getServerVersion())
.capabilities(new ServerCapabilities(
emptyMap(),
null,
null,
new ResourceCapabilities(
config.getResourceCapabilities().isSubscribe(),
config.getResourceCapabilities().isListChanged()),
new ServerCapabilities.ToolCapabilities(config.getToolCapabilities()
.isListChanged())))
.build();
Afterwards, add a resource like this:
server.addResource(new AsyncResourceRegistration(
new McpSchema.Resource(uri, name, description, mimeType, null), mono -> {....});
Expected behavior
The resource can be accessed and listed after being added
Metadata
Metadata
Assignees
Labels
No labels