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.
This commit is contained in:
parent
a2514a0ef2
commit
9d9a1347d9
1 changed files with 1 additions and 8 deletions
|
|
@ -263,25 +263,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
|
||||
|
|
|
|||
Loading…
Reference in a new issue