What happened?
I lost a few hours to realize that if I want to subscribe to a resource, I need to explicitly put in the server:
const server = new McpServer({ name: 'proofdiag', version: '0.0.1' }, {
capabilities: {
tools: {},
resources: { subscribe: true, listChanged: true }, // <--- this is the important line
}
});
// Later someone calls
await server.server.sendResourceUpdated({ uri }).catch((e) => {console.log("Error in sendResourceUpdated", e)});
Otherwise, when subscribing the client would just receive an acknowledgment with an empty notifications, which is really hard to debug. As such, I would expect maybe some warning/errors if the declared capabilities do not allow to call a functionality (here when calling sendResourceUpdated or when receiving from the client the subscribe message), or otherwise capabilities should be changed based on what the server defines.
What did you expect?
An error/warning.
Code to reproduce
MWE with resource subscription.
SDK version
2.0.0-beta.4
Area
Server
What happened?
I lost a few hours to realize that if I want to subscribe to a resource, I need to explicitly put in the server:
Otherwise, when subscribing the client would just receive an acknowledgment with an empty
notifications, which is really hard to debug. As such, I would expect maybe some warning/errors if the declared capabilities do not allow to call a functionality (here when callingsendResourceUpdatedor when receiving from the client thesubscribemessage), or otherwise capabilities should be changed based on what the server defines.What did you expect?
An error/warning.
Code to reproduce
SDK version
2.0.0-beta.4
Area
Server