Merge pull request #256 from koic/remove_dead_code_in_handle_regular_request

Remove dead code in `handle_regular_request`
This commit is contained in:
Koichi ITO 2026-03-17 01:04:32 +09:00 • committed by GitHub
commit 6e35d13479
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -265,25 +265,18 @@ module MCP
end
end
response = @server.handle_json(body_string) || ""
response = @server.handle_json(body_string)
# Stream can be nil since stateless mode doesn't retain streams
stream = get_session_stream(session_id) if session_id
if stream
send_response_to_stream(stream, response, session_id)
elsif response.nil? && notification_request?(body_string)
[202, { "Content-Type" => "application/json" }, [response]]
else
[200, { "Content-Type" => "application/json" }, [response]]
end
end
def notification_request?(body_string)
body = parse_request_body(body_string)
body.is_a?(Hash) && body["method"].start_with?("notifications/")
end
def get_session_stream(session_id)
@mutex.synchronize { @sessions[session_id]&.fetch(:stream, nil) }
end