Skip to content

Commit 9d9a134

Browse files
committed
Remove dead code in handle_regular_request
Notifications never reach `handle_regular_request` because `handle_post` checks `notification?(body)` first and returns 202 via `handle_accepted`. Since only notifications cause `handle_json` to return `nil`, `response` is always non-`nil` here.
1 parent a2514a0 commit 9d9a134

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

lib/mcp/server/transports/streamable_http_transport.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,25 +263,18 @@ def handle_regular_request(body_string, session_id)
263263
end
264264
end
265265

266-
response = @server.handle_json(body_string) || ""
266+
response = @server.handle_json(body_string)
267267

268268
# Stream can be nil since stateless mode doesn't retain streams
269269
stream = get_session_stream(session_id) if session_id
270270

271271
if stream
272272
send_response_to_stream(stream, response, session_id)
273-
elsif response.nil? && notification_request?(body_string)
274-
[202, { "Content-Type" => "application/json" }, [response]]
275273
else
276274
[200, { "Content-Type" => "application/json" }, [response]]
277275
end
278276
end
279277

280-
def notification_request?(body_string)
281-
body = parse_request_body(body_string)
282-
body.is_a?(Hash) && body["method"].start_with?("notifications/")
283-
end
284-
285278
def get_session_stream(session_id)
286279
@mutex.synchronize { @sessions[session_id]&.fetch(:stream, nil) }
287280
end

0 commit comments

Comments
 (0)