Skip to content

Implement a default SetLevelRequestSchema handler #871

@kentcdodds

Description

@kentcdodds

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:

  1. Create an MCP server that advertises the "logging" capability.
  2. Do not implement a request handler for the logging/setLevel request.
  3. Attempt to connect to this server using the MCP Inspector.
  4. 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 {};
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions