Skip to content

feat(transport): support local streamable HTTP handler futures - #1369

Open
ricochet wants to merge 1 commit into
modelcontextprotocol:mainfrom
ricochet:feat/local-streamable-http
Open

ricochet wants to merge 1 commit into
modelcontextprotocol:mainfrom
ricochet:feat/local-streamable-http

Conversation

@ricochet

@ricochet ricochet commented Oct 15, 2026 •

Copy link
Copy Markdown

Enabling local currently compiles out the Streamable HTTP server even when its transport feature is selected. Keep the service and configuration exports available, dispatch HTTP background work through the existing local-aware spawning helper, and use the conditional boxed future for Tower calls.

Handlers can now hold !Send values across awaits when the service runs on a Tokio LocalSet. The handler and factory bounds stay as they are, and the standard Tokio path retains Send futures. This adds no runtime dependencies.

Motivation and Context

We’re building Rust MCP servers as --target wasm32-wasip3 HTTP components on wasmCloud/Cosmonic. We want to use the official SDK’s HTTP transport and protocol handling while letting tools await host-provided WASI HTTP operations directly.

Our current integration bridges Tokio and component-model async through an outbound request queue and serializes MCP exchanges within each component instance. We’re exploring native p3 execution to simplify that integration.

Supporting local handler futures in the HTTP transport is a prerequisite. The SDK already provides a local feature, but enabling it currently removes the HTTP server transport entirely. This PR takes a small, independently useful step to enable HTTP handler futures that hold !Send values across awaits, using the existing Tokio LocalSet support. A native p3 execution backend can follow separately.

How Has This Been Tested?

  • Five new tests pass for direct and Tower dispatch, JSON and SSE responses, modern and legacy stateless requests, and legacy sessions. Each handler holds Rc across an await and returns its value in the response.
  • Twelve existing HTTP tests pass for disconnect cancellation, initialization failures, JSON responses, and SSE fallback.

Breaking Changes

Non-breaking, backward-compatible addition.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Related: #290, #379. This supports local HTTP handler futures; services still run on Tokio.

@github-actions github-actions Bot added T-documentation Documentation improvements T-dependencies Dependencies related changes T-test Testing related changes T-config Configuration file changes T-core Core library changes T-transport Transport layer changes labels Oct 15, 2026
@github-actions
github-actions Bot requested a review from bolinfest October 15, 2026 18:55
@github-actions

Copy link
Copy Markdown
Contributor

@bolinfest is on triage rotation this week and is the reviewer for this one.

Labels come from the PR labeler. Please review the change.

Automated triage. Labels are a first pass and the assigned maintainer has the final say.

@ricochet
ricochet marked this pull request as ready for review October 15, 2026 19:06
@ricochet
ricochet requested a review from a team as a code owner October 15, 2026 19:06
Signed-off-by: Bailey Hayes <bailey@cosmonic.com>
@ricochet
ricochet force-pushed the feat/local-streamable-http branch from 8075750 to d77fa74 Compare October 15, 2026 21:27

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-config Configuration file changes T-core Core library changes T-dependencies Dependencies related changes T-documentation Documentation improvements T-test Testing related changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant