Skip to content

Commit c606320

Browse files
committed
do not respond to notifications/initialized
- as per https://www.jsonrpc.org/specification#notification
1 parent 7c1aa6e commit c606320

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

lib/mcp/server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def initialize(
6666
Methods::PROMPTS_GET => method(:get_prompt),
6767
Methods::INITIALIZE => method(:init),
6868
Methods::PING => ->(_) { {} },
69-
Methods::NOTIFICATIONS_INITIALIZED => ->(_) { {} },
69+
Methods::NOTIFICATIONS_INITIALIZED => ->(_) {},
7070

7171
# No op handlers for currently unsupported methods
7272
Methods::RESOURCES_SUBSCRIBE => ->(_) {},

test/mcp/server_test.rb

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,23 @@ class ServerTest < ActiveSupport::TestCase
141141
assert_instrumentation_data({ method: "unsupported_method" })
142142
end
143143

144-
test "#handle notifications/initialized returns empty response" do
144+
test "#handle notifications/initialized returns nil response" do
145145
request = {
146146
jsonrpc: "2.0",
147147
method: "notifications/initialized",
148-
id: "123",
149148
}
150149

151-
response = @server.handle(request)
152-
assert_equal(
153-
{
154-
jsonrpc: "2.0",
155-
id: "123",
156-
result: {},
157-
},
158-
response,
159-
)
150+
assert_nil @server.handle(request)
151+
assert_instrumentation_data({ method: "notifications/initialized" })
152+
end
153+
154+
test "#handle_json notifications/initialized returns nil response" do
155+
request = JSON.generate({
156+
jsonrpc: "2.0",
157+
method: "notifications/initialized",
158+
})
159+
160+
assert_nil @server.handle_json(request)
160161
assert_instrumentation_data({ method: "notifications/initialized" })
161162
end
162163

0 commit comments

Comments
 (0)