-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Describe the bug
The SDK does not automatically handle the logging/setLevel
request, even when the server advertises logging capabilities. This requires every server implementation to manually handle this request, which is not ideal.
To Reproduce
Steps to reproduce the behavior:
- Create an MCP server that advertises the "logging" capability.
- Do not implement a request handler for the
logging/setLevel
request. - Attempt to connect to this server using the MCP Inspector.
- The connection will fail.
Check modelcontextprotocol/inspector#699 for an example
Expected behavior
The MCP SDK should provide a default handler for the logging/setLevel
request when a server advertises logging capabilities. This would prevent connection failures and streamline server development.
Additionally, without this, server writers have to check the log level before sending notifications which is troublesome and something the SDK could handle for us.
Additional context
As a workaround, server developers can implement their own handler for the SetLevelRequestSchema
. Here is an example:
server.setRequestHandler(SetLevelRequestSchema, request => {
console.log(`--- Logging level: ${request.params.level}`);
return {};
});