Skip to content

fix(server): guard stdio SSE notification sends#1410

Open
echooo-agent wants to merge 1 commit into
modelcontextprotocol:mainfrom
echooo-agent:ai/handle-disconnected-stdio-sse
Open

fix(server): guard stdio SSE notification sends#1410
echooo-agent wants to merge 1 commit into
modelcontextprotocol:mainfrom
echooo-agent:ai/handle-disconnected-stdio-sse

Conversation

@echooo-agent
Copy link
Copy Markdown

Summary

  • Catches failed SSE sends when forwarding stdio stderr notifications.
  • Cleans up the paired client/server transports idempotently after the inspector
    client disconnects.
  • Preserves the existing command-not-found cleanup path while preventing an
    unhandled Not connected error from crashing the server.

Note: Inspector V2 is under development to address architectural and UX improvements. During this time, V1 contributions should focus on bug fixes and MCP spec compliance. See CONTRIBUTING.md for more details.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Refactoring (no functional changes)
  • Test updates
  • Build/CI improvements

Changes Made

  • Adds a guarded sendStdioNotification helper for /stdio stderr forwarding.
  • Adds idempotent cleanup for the SSE client transport and stdio server
    transport when notification delivery fails.
  • Reuses the guarded path for both ordinary stderr notifications and the
    MODULE_NOT_FOUND cleanup notification.

Related Issues

Fixes #1014

Testing

  • Tested in UI mode
  • Tested in CLI mode
  • Tested with STDIO transport
  • Tested with SSE transport
  • Tested with Streamable HTTP transport
  • Added/updated automated tests
  • Manual testing performed

Test Results and/or Instructions

  • npm.cmd run build in server/
  • server/node_modules/.bin/prettier.cmd --check server/src/index.ts
  • git diff --check
  • Manual smoke test: started server/build/index.js with auth disabled on a
    local test port, repeatedly opened and aborted /stdio SSE connections while
    the child process wrote stderr, and confirmed the server did not crash.

Local note: the default npm registry path repeatedly timed out on this machine,
so local verification dependencies were installed temporarily through
registry.npmmirror.com without changing package manifests or lockfiles.

Checklist

  • Code follows the style guidelines (ran Prettier on the changed file)
  • Self-review completed
  • Code is commented where necessary
  • Documentation updated (README, comments, etc.)

Breaking Changes

None.

Additional Context

This PR was prepared with AI assistance from Echo (echooo-agent). I reviewed
the scope and validation before submitting.

No documentation changes were needed for this internal server error-handling
fix.

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.

SSE transport crashes with "Not connected" error when multiple connections occur

1 participant