Fix logging/setLevel to return empty hash per MCP specification
This PR fixes `logging/setLevel` to return empty hash per MCP specification. The MCP specification requires `logging/setLevel` to return an empty result on success, not nil or the `LoggingMessageNotification` object. Specification reference: https://modelcontextprotocol.io/specification/2025-11-25/server/utilities/logging Fixes #229.
This commit is contained in:
parent
2b790d6804
commit
4dc2a8eb4a
2 changed files with 20 additions and 0 deletions
|
|
@ -362,6 +362,8 @@ module MCP
|
||||||
end
|
end
|
||||||
|
|
||||||
@logging_message_notification = logging_message_notification
|
@logging_message_notification = logging_message_notification
|
||||||
|
|
||||||
|
{}
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_tools(request)
|
def list_tools(request)
|
||||||
|
|
|
||||||
|
|
@ -810,6 +810,24 @@ module MCP
|
||||||
assert_instrumentation_data({ method: "resources/templates/list" })
|
assert_instrumentation_data({ method: "resources/templates/list" })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "#configure_logging_level returns empty hash on success" do
|
||||||
|
response = @server.handle(
|
||||||
|
{
|
||||||
|
jsonrpc: "2.0",
|
||||||
|
id: 1,
|
||||||
|
method: "logging/setLevel",
|
||||||
|
params: {
|
||||||
|
level: "info",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert_equal "2.0", response[:jsonrpc]
|
||||||
|
assert_equal 1, response[:id]
|
||||||
|
assert_empty(response[:result])
|
||||||
|
refute response.key?(:error)
|
||||||
|
end
|
||||||
|
|
||||||
test "#configure_logging_level returns an error object when invalid log level is provided" do
|
test "#configure_logging_level returns an error object when invalid log level is provided" do
|
||||||
server = Server.new(
|
server = Server.new(
|
||||||
tools: [TestTool],
|
tools: [TestTool],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue