Gracefully handle POST requests with nil bodies

This commit is contained in:
Riley Shott 2025-06-09 14:14:41 -07:00
commit 91af9ad19a

View file

@ -162,7 +162,7 @@ module MCP
def parse_request_body(body_string)
JSON.parse(body_string)
rescue JSON::ParserError
rescue JSON::ParserError, TypeError
[400, { "Content-Type" => "application/json" }, [{ error: "Invalid JSON" }.to_json]]
end