Skip to content

Commit 7c1aa6e

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". - This implementation just replies with an empty response (same as ping).
1 parent 6bace86 commit 7c1aa6e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/mcp/server.rb

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

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

test/mcp/server_test.rb

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

144+
test "#handle notifications/initialized returns empty response" do
145+
request = {
146+
jsonrpc: "2.0",
147+
method: "notifications/initialized",
148+
id: "123",
149+
}
150+
151+
response = @server.handle(request)
152+
assert_equal(
153+
{
154+
jsonrpc: "2.0",
155+
id: "123",
156+
result: {},
157+
},
158+
response,
159+
)
160+
assert_instrumentation_data({ method: "notifications/initialized" })
161+
end
162+
144163
test "#handle tools/list returns available tools" do
145164
request = {
146165
jsonrpc: "2.0",

0 commit comments

Comments
 (0)