Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions lib/mcp/server/transports/streamable_http_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,25 +263,18 @@ def handle_regular_request(body_string, session_id)
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
Expand Down