Implementation guide
OWASP AISVS v1.01
Model Context Protocol (MCP) Security · Schema, Message, and Input Validation
Limit MCP payload size
Verify that all MCP transports enforce maximum payload size limits.
OWASP AISVS v1.01, requirement 10.4.5
In plain English
Set maximum payload sizes on every MCP transport, for requests and for responses. Without them, one oversized message can exhaust memory, and a huge tool result can flood the model's context.
What good looks like
- Size limits are set for requests and responses on each transport, stdio included.
- Oversized payloads are rejected early, before they are fully read into memory.
- Limits are sized for the use case.
- Clients enforce limits on what they accept from servers.
How teams usually do it
- Body size limits in the web server, gateway or framework.
- Message size limits in the MCP client and in stdio readers.
- Pagination or resource links for large results, in place of one huge response.
Suggested evidence
- Configuration for each transport.
- Tests with oversized requests and responses.
Common mistakes
- Leaving framework defaults that allow very large payloads.
- Limiting requests and not responses.
- Forgetting streamed responses, which can run on without ever exceeding a per-message limit.
Not sure which requirements apply to your system? Take the assessment, or browse every guide in this chapter.
Requirement text from the OWASP AI Security Verification Standard, licensed under CC BY-SA 4.0. This guidance is shared under the same licence.