@modelcontextprotocol/sdk: MCP TypeScript SDK: HTTP server transports and handlers did not limit request body size or JSON-RPC batch length
What fixes it
- 1.30.1@modelcontextprotocol/sdk, npmGitHub
npm install @modelcontextprotocol/sdk@1.30.1 - 2.1.0@modelcontextprotocol/server, npmGitHub
npm install @modelcontextprotocol/server@2.1.0 - 2.1.0@modelcontextprotocol/node, npmGitHub
npm install @modelcontextprotocol/node@2.1.0 - 2.0.1@modelcontextprotocol/hono, npmGitHub
npm install @modelcontextprotocol/hono@2.0.1
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
Summary
In affected versions, MCP servers reachable over HTTP put no limit on the size of a POST body or on the number of messages in a JSON-RPC batch. Large requests could exhaust the server's memory, and one long batch could block it from serving anyone else. No credentials were needed, unless your application authenticates requests before they reach the SDK.
Am I affected?
Yes, if clients you do not fully trust can reach your server over Streamable HTTP. A body parser such as express.json() does not protect you, because it does not limit batch length. Servers that only use stdio are not affected.
Affected versions:
@modelcontextprotocol/sdk1.10.0 through 1.30.0@modelcontextprotocol/server2.0.0@modelcontextprotocol/node2.0.0@modelcontextprotocol/hono2.0.0
Fix
Upgrade to:
- 1.x:
@modelcontextprotocol/sdk1.30.1 or later - 2.x:
@modelcontextprotocol/server2.1.0,@modelcontextprotocol/node2.1.0 and@modelcontextprotocol/hono2.0.1 or later. Upgrade every one you have installed.
Bodies over 4 MiB now get 413, and batches over 100 messages get 400. If your clients send larger bodies, raise the new maxRequestBodySize option.
If you cannot upgrade yet, cap request body size in a reverse proxy.
Text from GitHub Advisory Database
Affected versions 8
- @modelcontextprotocol/sdk, npm>= 1.10.0, < 1.30.1GitHub
- @modelcontextprotocol/server, npm>= 2.0.0, < 2.1.0GitHub
- @modelcontextprotocol/node, npm>= 2.0.0, < 2.1.0GitHub
- @modelcontextprotocol/hono, npm>= 2.0.0, < 2.0.1GitHub
- @modelcontextprotocol/sdk, npmfrom 1.10.0, fixed in 1.30.1OSV
- @modelcontextprotocol/server, npmfrom 2.0.0, fixed in 2.1.0OSV
- @modelcontextprotocol/node, npmfrom 2.0.0, fixed in 2.1.0OSV
- @modelcontextprotocol/hono, npmfrom 2.0.0, fixed in 2.0.1OSV
References 10
- github.com/modelcontextprotocol/typescript-sdk/commit/7b781ed4e25355a25d15974f3c76de81299694edFixvia GitHub
- github.com/modelcontextprotocol/typescript-sdk/commit/a9f6eb709b85459d01e8f2a9e881fef2621756c1Fixvia GitHub
- github.com/modelcontextprotocol/typescript-sdk/releases/tag/1.30.1Fixvia GitHub
- github.com/modelcontextprotocol/typescript-sdk/releases/tag/@modelcontextprotocol/hono@2.0.1Fixvia GitHub
- github.com/modelcontextprotocol/typescript-sdk/releases/tag/@modelcontextprotocol/node@2.1.0Fixvia GitHub
- github.com/modelcontextprotocol/typescript-sdk/releases/tag/@modelcontextprotocol/server@2.1.0Fixvia GitHub
- github.com/modelcontextprotocol/typescript-sdk/security/advisories/GHSA-f897-62hf-6gxqAdvisoryvia GitHub
- github.com/advisories/GHSA-f897-62hf-6gxqAdvisoryvia GitHub
- github.com/modelcontextprotocol/typescript-sdk/pull/2698Referencevia GitHub
- github.com/modelcontextprotocol/typescript-sdk/pull/2717Referencevia GitHub