Skip to content

fix(server): close stdio transport on stdin close#2473

Open
harshmathurx wants to merge 2 commits into
modelcontextprotocol:mainfrom
harshmathurx:fix/stdio-server-stdin-close
Open

fix(server): close stdio transport on stdin close#2473
harshmathurx wants to merge 2 commits into
modelcontextprotocol:mainfrom
harshmathurx:fix/stdio-server-stdin-close

Conversation

@harshmathurx

Copy link
Copy Markdown

Summary

  • close StdioServerTransport when stdin emits close or end
  • remove stdin lifecycle listeners during transport close
  • add regression coverage for both stdin close paths

Fixes #2002.

Test Plan

  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/server test -- packages/server/test/server/stdio.test.ts
  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/server lint

@harshmathurx harshmathurx requested a review from a team as a code owner July 9, 2026 15:55
@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2656e1f

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

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

pkg-pr-new Bot commented Jul 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/codemod

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

@modelcontextprotocol/core

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

@modelcontextprotocol/server

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

@modelcontextprotocol/server-legacy

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 2656e1f

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.

Bug: StdioServerTransport doesn't handle stdin close/end — causes zombie process accumulation

1 participant