Skip to content

fix(hono): skip JSON parsing on GET/HEAD and empty-body requests - #3205

Open
DevKursat wants to merge 1 commit into
modelcontextprotocol:mainfrom
DevKursat:fix/hono-empty-json-body
Open

DevKursat wants to merge 1 commit into
modelcontextprotocol:mainfrom
DevKursat:fix/hono-empty-json-body

Conversation

@DevKursat

Copy link
Copy Markdown

Fixes #3201

Summary

  • Skip JSON body pre-parsing in createMcpHonoApp() for GET and HEAD requests (matching toWebRequest in @modelcontextprotocol/node).
  • Return { tooLarge: false, empty: true } from parseJsonBody() when body.text.length === 0 so parsedBody remains undefined for bodyless DELETE, OPTIONS, and empty POST requests carrying Content-Type: application/json.
  • Non-empty invalid JSON bodies still return 400 Invalid JSON, and oversized bodies still return 413.

Verification

  • Added regression test in packages/middleware/hono/test/hono.test.ts covering GET, HEAD, DELETE, and empty POST with Content-Type: application/json.
  • Ran vitest run (2 test files, 19 tests passed) and tsc --noEmit on packages/middleware/hono.

@DevKursat
DevKursat requested a review from a team as a code owner November 18, 2026 20:26
@changeset-bot

changeset-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a3cf1cb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@pkg-pr-new

pkg-pr-new Bot commented Nov 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@3205

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@3205

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@3205

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@3205

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@3205

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@3205

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@3205

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@3205

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@3205

commit: a3cf1cb

@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v2] createMcpHonoApp answers 400 Invalid JSON on GET/HEAD/DELETE and empty-body requests with Content-Type: application/json

1 participant