feat: Add HTTP Streaming transport support for MCP servers#444
Conversation
|
is there any way to autodetect this? |
|
maybe by trying to make a request and falling back to sse if it fails, but that's kinda hacky. I tried to prototype that and kept getting 400 errors so I probably just wasnt forming the request body properly for that "test request" fwiw claude code and all the other tools I checked make you specify sse vs. streaming http explicitly |
|
Why not reusing the type field and instead of |
|
yeah thats actually a really good point, specially because I run local mcp servers that communicate over http so "remote" isnt fully accurate to describe the "type" of mcp server what do you think @thdxr ? |
- Add @modelcontextprotocol/sdk override to 1.13.2 in package.json - Import StreamableHTTPClientTransport from @modelcontextprotocol SDK - Add conditional transport selection based on mcp.transport config
Implement suggestion from PR anomalyco#444 to use the type field for transport selection instead of a separate transport field: - Keep "remote" as an alias for SSE (backward compatible) - Add "sse" as explicit SSE transport type - Add "http" for HTTP streaming transport - Remove "http+sse" option - Update schema and initialization logic accordingly This makes the configuration cleaner and more intuitive while maintaining backward compatibility with existing "remote" configurations. 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode <noreply@opencode.ai>
|
hey @thdxr anything you want changed in this PR? I use this feature a lot and am hoping to get back to using the main release so I can get updates more easily |
|
we ended up fixing this in a different way - thank you for the contribution though |
feat(app): new design language
Summary
This PR expands OpenCode's MCP (Model Context Protocol) server support by adding HTTP Streaming as a transport option alongside the existing SSE (Server-Sent Events) implementation. HTTP Streaming provides a more reliable and performant alternative for MCP server communication.
Why HTTP Streaming over SSE?
While SSE has served well as the initial transport protocol, HTTP Streaming offers several advantages:
Changes
1. Configuration Schema Update
Based on community feedback, we've simplified the configuration by using the
typefield to specify both the connection type and transport protocol:"remote"- Kept as an alias for SSE to maintain backward compatibility"sse"- Explicitly uses SSE transport"http"- Uses HTTP Streaming transport2. MCP SDK Version Override
Added a version override for
@modelcontextprotocol/sdkto1.13.2inpackage.json. This was necessary because:StreamableHTTPClientTransportclass we need for HTTP Streaming support was introduced in later versions3. Transport Selection Logic
Updated the MCP client initialization to support the new type values:
Usage
Users can now specify the transport method directly in the type field:
SSE Transport (default):
{ "mcp": { "myserver": { "type": "sse", "url": "https://my-mcp-server.com" } } }HTTP Streaming Transport:
{ "mcp": { "myserver": { "type": "http", "url": "https://my-mcp-server.com" } } }Backward Compatible (uses SSE):
{ "mcp": { "myserver": { "type": "remote", "url": "https://my-mcp-server.com" } } }Testing
Impact
This change is fully backward compatible. Existing configurations using
type: "remote"will continue to work as before, using SSE transport. Users can opt into HTTP Streaming by settingtype: "http".