Skip to content

Commit b8f1cc9

Browse files
authored
Merge pull request #230 from koic/fix_logging_set_level
Fix `logging/setLevel` to return empty hash per MCP specification
2 parents 34b7c68 + 4dc2a8e commit b8f1cc9

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/mcp/server.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ def configure_logging_level(request)
362362
end
363363

364364
@logging_message_notification = logging_message_notification
365+
366+
{}
365367
end
366368

367369
def list_tools(request)

test/mcp/server_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,24 @@ class Example < Tool
810810
assert_instrumentation_data({ method: "resources/templates/list" })
811811
end
812812

813+
test "#configure_logging_level returns empty hash on success" do
814+
response = @server.handle(
815+
{
816+
jsonrpc: "2.0",
817+
id: 1,
818+
method: "logging/setLevel",
819+
params: {
820+
level: "info",
821+
},
822+
},
823+
)
824+
825+
assert_equal "2.0", response[:jsonrpc]
826+
assert_equal 1, response[:id]
827+
assert_empty(response[:result])
828+
refute response.key?(:error)
829+
end
830+
813831
test "#configure_logging_level returns an error object when invalid log level is provided" do
814832
server = Server.new(
815833
tools: [TestTool],

0 commit comments

Comments
 (0)