Skip to content

Resources and prompts cannot be added after server start #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marianogonzalez opened this issue Feb 21, 2025 · 3 comments
Closed

Resources and prompts cannot be added after server start #17

marianogonzalez opened this issue Feb 21, 2025 · 3 comments

Comments

@marianogonzalez
Copy link
Contributor

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

@jwflicker
Copy link

is there a workaround for this?

@marianogonzalez
Copy link
Contributor Author

@jwflicker I sent PR #18 that fixes the problem. You can apply that fix locally while waiting for it to be merged

tzolov pushed a commit that referenced this issue Feb 26, 2025
* Resources and prompts cannot be added after server start #17
@marianogonzalez
Copy link
Contributor Author

Fixed in PR #18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants