Skip to content

feat(http): enforce a request body size limit#150

Open
SVilgelm wants to merge 1 commit into
rust-mcp-stack:mainfrom
SVilgelm:feat/http-body-limit
Open

feat(http): enforce a request body size limit#150
SVilgelm wants to merge 1 commit into
rust-mcp-stack:mainfrom
SVilgelm:feat/http-body-limit

Conversation

@SVilgelm
Copy link
Copy Markdown
Contributor

📌 Summary

The streamable HTTP endpoint buffered the entire request body into a String with no limit, so a single large POST could exhaust server memory. The router now enforces a configurable body-size limit and rejects oversized requests with 413 Payload Too Large.

🔍 Related Issues

✨ Changes Made

  • Add HyperServerOptions::max_request_body_size (defaults to 4 MiB).
  • Apply DefaultBodyLimit to the router in app_routes.
  • Add an integration test asserting 413 for oversized bodies.

Add a configurable max_request_body_size (default 4 MiB) and reject larger streamable-HTTP request bodies with 413 instead of buffering them.

Assisted-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Sergey Vilgelm <sergey@vilgelm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant