Skip to content

fix(serve-mcp): concurrent stdio dispatch, real local session, notification delivery#68

Merged
deer merged 2 commits into
mainfrom
mcp_stdio_improvements
Jun 22, 2026
Merged

fix(serve-mcp): concurrent stdio dispatch, real local session, notification delivery#68
deer merged 2 commits into
mainfrom
mcp_stdio_improvements

Conversation

@deer

@deer deer commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Previously stdioLoop processed one request at a time — each line was parsed, dispatched, and written before the next was read. Now each line is dispatched onto its own virtual thread. A Phaser waits for all in-flight dispatches before the loop exits. A single mcp-stdio-writer virtual thread owns all writes to the output stream via a LinkedBlockingQueue, serializing responses without blocking dispatch and keeping PipedInputStream's writer-thread tracking pointed at one live thread.

Previously stdioLoop dispatched all requests under the session ID "local" but never created a corresponding SessionState, so resources/subscribe and resources/unsubscribe silently no-oped. A SessionState is now created at loop entry and torn down on exit. stateFor(sessionId) centralises the lookup so dispatch, subscribe, and unsubscribe all reach it correctly.

notifyResourceChanged now checks stdioOutputQueue alongside the existing SSE emitter loop, delivering notifications/resources/updated to any stdio session subscribed to the changed URI. It is a no-op when the stdio loop is not running.

@deer deer merged commit 7d5287a into main Jun 22, 2026
2 checks passed
@deer deer deleted the mcp_stdio_improvements branch June 22, 2026 13:40
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