Skip to content

Commit be5e7db

Browse files
committed
implements the notifications/initialized method
- According to https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle, "After successful initialization, the client MUST send an initialized notification to indicate it is ready to begin normal operations".
1 parent 541bbe0 commit be5e7db

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/mcp/server.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def initialize(
7474
Methods::PROMPTS_GET => method(:get_prompt),
7575
Methods::INITIALIZE => method(:init),
7676
Methods::PING => ->(_) { {} },
77+
Methods::NOTIFICATIONS_INITIALIZED => ->(_) {},
7778

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

test/mcp/server_test.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,26 @@ class ServerTest < ActiveSupport::TestCase
160160
assert_instrumentation_data({ method: "unsupported_method" })
161161
end
162162

163+
test "#handle notifications/initialized returns nil response" do
164+
request = {
165+
jsonrpc: "2.0",
166+
method: "notifications/initialized",
167+
}
168+
169+
assert_nil @server.handle(request)
170+
assert_instrumentation_data({ method: "notifications/initialized" })
171+
end
172+
173+
test "#handle_json notifications/initialized returns nil response" do
174+
request = JSON.generate({
175+
jsonrpc: "2.0",
176+
method: "notifications/initialized",
177+
})
178+
179+
assert_nil @server.handle_json(request)
180+
assert_instrumentation_data({ method: "notifications/initialized" })
181+
end
182+
163183
test "#handle tools/list returns available tools" do
164184
request = {
165185
jsonrpc: "2.0",

0 commit comments

Comments
 (0)