Skip to content

fix(mcp): notify onclose when standalone SSE stream aborts - #2075

Open
edenbuilds wants to merge 4 commits into
honojs:mainfrom
edenbuilds:fix/mcp-sse-abort-onclose-1762
Open

fix(mcp): notify onclose when standalone SSE stream aborts#2075
edenbuilds wants to merge 4 commits into
honojs:mainfrom
edenbuilds:fix/mcp-sse-abort-onclose-1762

Conversation

@edenbuilds

Copy link
Copy Markdown
Contributor

Summary

  • Call onclose when the standalone GET SSE stream (_GET_stream) aborts, so apps can detect client disconnects without relying on DELETE.
  • Deduplicate notifications so close() after an abort does not fire onclose twice.

Fixes #1762

Test plan

  • Unit test: cancel SSE body → onclose once; subsequent close() does not double-fire
  • Existing onsessionclosed DELETE tests still pass

Made with Cursor

MCP clients often drop the GET SSE stream without DELETE. Call onclose on
standalone stream abort so apps can detect disconnects, without double-firing
when close() also runs.

Fixes honojs#1762
@changeset-bot

changeset-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f7310a6

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

This PR includes changesets to release 1 package
Name Type
@hono/mcp 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

@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.24%. Comparing base (45c94d6) to head (b90b874).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2075      +/-   ##
==========================================
+ Coverage   92.23%   92.24%   +0.01%     
==========================================
  Files         116      116              
  Lines        4122     4129       +7     
  Branches     1077     1079       +2     
==========================================
+ Hits         3802     3809       +7     
  Misses        285      285              
  Partials       35       35              
Flag Coverage Δ
mcp 90.66% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Await stopTestServer and prefer ?? for session ids so @hono/mcp lint passes in CI.
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.

StreamableHTTPTransport: SSE stream abort should notify via onclose (or new callback)

2 participants