Skip to content

Commit 91af9ad

Browse files
committed
Gracefully handle POST requests with nil bodies
1 parent 5800299 commit 91af9ad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/mcp/server/transports/streamable_http_transport.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def extract_session_id(request)
162162

163163
def parse_request_body(body_string)
164164
JSON.parse(body_string)
165-
rescue JSON::ParserError
165+
rescue JSON::ParserError, TypeError
166166
[400, { "Content-Type" => "application/json" }, [{ error: "Invalid JSON" }.to_json]]
167167
end
168168

0 commit comments

Comments
 (0)