Skip to content

express: add maxBodyBytes guard for JSON parsing#1497

Closed
TheodorNEngoy wants to merge 1 commit intomodelcontextprotocol:mainfrom
TheodorNEngoy:codex/express-body-limit
Closed

express: add maxBodyBytes guard for JSON parsing#1497
TheodorNEngoy wants to merge 1 commit intomodelcontextprotocol:mainfrom
TheodorNEngoy:codex/express-body-limit

Conversation

@TheodorNEngoy
Copy link

createMcpExpressApp() currently installs express.json() with its default size limit behavior.

This PR adds a maxBodyBytes option (default: 1_000_000) and passes it through to express.json({ limit: ... }), so oversized JSON payloads return 413 and don't get fully buffered.

  • Adds maxBodyBytes to CreateMcpExpressAppOptions
  • Enforces the limit via express.json({ limit })
  • Adds a vitest + supertest coverage for 413
  • Documents the option in the Express + Node adapter READMEs
  • Includes a changeset for @modelcontextprotocol/express

@TheodorNEngoy TheodorNEngoy requested a review from a team as a code owner February 7, 2026 23:01
@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2026

🦋 Changeset detected

Latest commit: 61b305b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/express Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 7, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1497

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1497

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1497

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1497

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1497

commit: 61b305b

@TheodorNEngoy
Copy link
Author

Closing as a duplicate of #1495 (same feature, more complete error-shaping + safer default). I folded the useful bits there so maintainers only need to review one PR.

@TheodorNEngoy TheodorNEngoy deleted the codex/express-body-limit branch February 7, 2026 23:32
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