feat(mcp): stateless transport shim — Slice B-1 (#1511) - #1518
Closed
Lexus2016 wants to merge 1 commit into
Closed
Conversation
Add HERMES_MCP_STATELESS env flag (default OFF), _detect_stateless_support(), synthesize_capabilities(), and _initialize_or_synthesize() helper that skips session.initialize() in stateless mode and synthesizes an InitializeResult-shaped object so existing capability gates keep working. All 4 transport call sites (stdio, SSE, streamable_http new, streamablehttp deprecated) are wired through the helper. Zero behavioral change unless HERMES_MCP_STATELESS=1 is set AND per-server config has stateless: true. Closes #1511
Owner
Author
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
Implements Slice B-1 of the MCP 2026-07-28 stateless transport migration (issue #1511, parent #1287).
Changes
HERMES_MCP_STATELESSenv flag — default OFF, zero behavioral change unless enabled_detect_stateless_support(config)— reads env flag + per-serverstateless: trueconfig key; both must be truthysynthesize_capabilities()— constructs anInitializeResult-shapedSimpleNamespacewith all three capability families (tools, resources, prompts) so existing capability gates work without a live session_initialize_or_synthesize()— helper method onMCPServerTaskthat skipssession.initialize()in stateless mode and returns synthesized caps; delegates to the real handshake otherwiseDesign
stateless: truein config.yaml (requires global env flag too).well-known/mcpto narrow the set_advertises_tools(),_select_utility_schemas()) are capability-source-agnostic and work unchanged with synthesized capsTest plan
tests/tools/test_mcp_stateless_b1.py) — all pass_initialize_or_synthesize()both pathsScope
This is Slice B-1 only. B-2 (stateless RPC adapter, header injection, per-call sessions) and B-3 (mock tests) are separate issues (#1512, #1513).
Closes #1511