Skip to content

fix: cancel native MCP captures when stdio reaches EOF - #52

Merged
fcostaoliveira merged 1 commit into
mainfrom
fix/mcp-eof-capture-cleanup
Oct 23, 2026
Merged

fcostaoliveira merged 1 commit into
mainfrom
fix/mcp-eof-capture-cleanup

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Closing an MCP client's stdin during capture leaves the server waiting for the active handler on the supported MCP 1.24 floor. The capture can continue until its deadline because that SDK version does not cancel handlers when the transport ends.

The POSIX stdio boundary now cancels its request scope at EOF and waits for the existing shielded native cleanup. The same reproduced Stax control changed from still running three seconds after EOF to a clean exit in about 86 ms. Partial artifacts remain available and attached targets are not signaled. HTTP retains its existing server handling.

Tests cover active native cleanup on EOF and SIGTERM, a child ignoring SIGTERM, descriptor restoration, and a simulated older SDK that waits indefinitely after input closes. Validation: focused lifecycle/protocol suite 26 passed; full macOS suite 2,120 passed / 109 skipped; full Linux aarch64 suite with real PostgreSQL 16.15 2,186 passed / 43 skipped; Ruff and all six CI checks passed.

An installed-wheel control with real Linux Stax binaries and MCP 1.24.0 exited cleanly about 170 ms after EOF, retained a valid partial archive, reaped native children, left the attached target alive and created no automatic database. Explicitly importing the partial archive recovered 13 CPU samples from its actual 1.07-second window.

@fcostaoliveira
fcostaoliveira marked this pull request as ready for review October 23, 2026 20:54
@fcostaoliveira
fcostaoliveira merged commit 7b386a9 into main Oct 23, 2026
6 checks passed
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.

1 participant