fix(mcp): complete the initialize handshake instead of exiting on stdio (#211) - #217
Draft
Frankie-Xu wants to merge 1 commit into
Draft
fix(mcp): complete the initialize handshake instead of exiting on stdio (#211)#217Frankie-Xu wants to merge 1 commit into
Frankie-Xu wants to merge 1 commit into
Conversation
…io (trailhq#211) Closes trailhq#211 trailhq#212 — same root cause on both spec revisions: the stdio server loaded native grammars at boot (or returned before stdin was armed), so official SDK clients saw Connection closed / timeout instead of an initialize result. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
🌱 graft blast radius3 areas changed → 2 areas can be affected. 7 dependent symbols, depth 2. flowchart TB
A0(("Workspace Graph<br/>5 symbols"))
A1(("Engine Core<br/>2 symbols"))
classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
class A0,A1 reached;
All 7 dependent symbols, grouped by areaWorkspace Graph — 5 symbols in 5 files
Engine Core — 2 symbols in 1 file
Test signal per changed area — 1 ✓ · 1 ⚠ · 1 –Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.
35 test suites also reference this code41 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.
Open the interactive graph → — click an area to see its dependent symbols at file:line. |
Frankie-Xu
marked this pull request as draft
August 26, 2026 09:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
graft mcpeither exited before answering or never wrote aninitializeresult, so the official SDK sawConnection closed/ timeout.initializeeven whenprotocolVersionis missing (default2025-11-25) or unsupported (JSON-RPC-32022with{ supported, requested }— not an echo of1999-01-01).tools/call.initialize/tools/list/server/discoveronly need the tool roster.Closes #211
Closes #212
Follow-up (still not this PR)
Pagination, resources, prompts, result-envelope fields (
resultType, cache hints on list results), andsubscriptions/listenwere not verified in those issues because the handshake never completed. They are out of scope here.After this lands they may start running in
@hasmcp/mcp-spec-testand fail for real capability gaps rather than “server exited”. Local run of2026-07-28against this branch already shows that: handshake / discover / SDK interop pass; 4 remaining failures are envelope fields ontools/listandtools/call(resultType,cacheScope,ttlMs,_metaserverInfo).Test plan
npm run build && npm test— 923/923initialize, unsupported version refused,tools/list,server/discoverwithout a sessiongraft mcp <tmpdir>: initialize → initialized → tools/list → tools/call; process still running on a quiet stdin pipe@hasmcp/mcp-spec-test@0.1.1 -c "node dist/cli.js mcp <abs>" --spec-version 2025-11-25: 14 passed, 0 failed (handshake, version negotiation, official SDK initialize +tools/list)--spec-version 2026-07-28: handshake,server/discover, and official SDK interop pass; 4 envelope failures left as follow-upMade with Cursor