Add Streamable HTTP request body limits (#3095)
This commit is contained in:
parent
2713b53b12
commit
03aaebd3aa
2 changed files with 280 additions and 19 deletions
|
|
@ -43,6 +43,7 @@ async def test_streamable_http_app_takes_runs_options_except_port() -> None:
|
|||
"stateless_http",
|
||||
"event_store",
|
||||
"retry_interval",
|
||||
"max_request_body_size",
|
||||
"transport_security",
|
||||
"host",
|
||||
}
|
||||
|
|
@ -56,6 +57,17 @@ async def test_a_request_before_the_session_manager_runs_is_rejected() -> None:
|
|||
await http.post("/mcp")
|
||||
|
||||
|
||||
async def test_streamable_http_app_applies_the_configured_request_body_limit() -> None:
|
||||
"""The documented `max_request_body_size` option rejects larger requests with HTTP 413."""
|
||||
server = MCPServer("Notes")
|
||||
app = server.streamable_http_app(max_request_body_size=8)
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with server.session_manager.run():
|
||||
async with httpx2.AsyncClient(transport=transport, base_url="http://localhost") as http:
|
||||
response = await http.post("/mcp", content=b"123456789")
|
||||
assert response.status_code == 413
|
||||
|
||||
|
||||
async def test_mounting_at_the_root_keeps_the_default_path() -> None:
|
||||
"""tutorial002: `Mount("/")` plus the default `streamable_http_path` leaves the endpoint at `/mcp`."""
|
||||
(mount,) = tutorial002.app.routes
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ def test_streamable_http_app_has_no_era_knob() -> None:
|
|||
"stateless_http",
|
||||
"event_store",
|
||||
"retry_interval",
|
||||
"max_request_body_size",
|
||||
"transport_security",
|
||||
"host",
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue