Skip to content

Conversation

@mattzcarey
Copy link
Contributor

@mattzcarey mattzcarey commented Jan 20, 2026

Summary

  • Pass overrideGlobalObjects: false to getRequestListener() calls in NodeStreamableHTTPServerTransport
  • Prevents Hono from overwriting the global Response object
  • Adds tests to verify global Response is preserved after transport initialization

Problem

When StreamableHTTPServerTransport is instantiated, Hono's getRequestListener() overwrites the global Response object with its own implementation (by default). This breaks frameworks like Next.js whose NextResponse class extends the native Response, causing instanceof Response checks to fail.

Fixes #1369

Test plan

  • Added tests that verify global Response is not overwritten after transport construction
  • Added tests that verify global Response is not overwritten after handleRequest is called
  • All existing tests pass

@mattzcarey mattzcarey requested a review from a team as a code owner January 20, 2026 10:55
@changeset-bot
Copy link

changeset-bot bot commented Jan 20, 2026

🦋 Changeset detected

Latest commit: 2ddf200

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

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/node 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 Jan 20, 2026

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 2ddf200

Pass `overrideGlobalObjects: false` to `getRequestListener()` calls in
NodeStreamableHTTPServerTransport to prevent Hono from overwriting the
global Response object.

This fixes an issue where frameworks like Next.js whose response classes
extend the native Response would break after initializing MCP transport,
as `instanceof Response` checks would fail.

Fixes #1369
@mattzcarey mattzcarey force-pushed the fix/hono-override-global-objects branch from 2a43bfc to 2bf9b8f Compare January 20, 2026 11:01
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.

Next AppRouter routes break because hono globally overwrites the response objects (v1.25.x +)

3 participants