[PR #444] [CLOSED] feat: Add HTTP Streaming transport support for MCP servers #9615

Closed
opened 2026-02-16 18:13:51 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/444
Author: @z80dev
Created: 6/27/2025
Status: Closed

Base: devHead: dev


📝 Commits (10+)

  • 84fe88a feat: HTTP Streaming support
  • 1df868e better type spec
  • 6cb9247 refactor: simplify MCP transport configuration based on PR feedback
  • f770f4d Merge remote-tracking branch 'origin/dev' into dev
  • c273ca7 Update download stats 2025-07-03
  • bb4cb13 Update download stats 2025-07-04
  • 4eaf313 Update download stats 2025-07-05
  • f1e5ca8 Update download stats 2025-07-06
  • d36f325 Update download stats 2025-07-07
  • ead2c3e Update download stats 2025-07-08

📊 Changes

6 files changed (+204 additions, -128 deletions)

View changed files

📝 STATS.md (+28 -6)
📝 bun.lock (+114 -103)
📝 package.json (+2 -1)
📝 packages/opencode/config.schema.json (+32 -10)
📝 packages/opencode/src/config/config.ts (+6 -2)
📝 packages/opencode/src/mcp/index.ts (+22 -6)

📄 Description

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:

  1. Better Error Handling: HTTP Streaming provides clearer error states and recovery mechanisms compared to SSE's limited error handling capabilities
  2. Reduced Latency: Direct streaming without the overhead of SSE's event framing and reconnection logic
  3. Simpler Implementation: No need for EventSource polyfills or SSE-specific server configurations
  4. Better Proxy Support: Works more reliably through corporate proxies and firewalls that may block or interfere with SSE connections
  5. Standardization: As MCP adoption grows, HTTP Streaming is becoming the preferred transport method in tools like Claude Code and other LLM tooling

Changes

1. Configuration Schema Update

Based on community feedback, we've simplified the configuration by using the type field to specify both the connection type and transport protocol:

type: z
  .enum(["remote", "sse", "http"])
  .describe("Type of MCP server connection and transport protocol (remote is alias for sse)")
  • "remote" - Kept as an alias for SSE to maintain backward compatibility
  • "sse" - Explicitly uses SSE transport
  • "http" - Uses HTTP Streaming transport

2. MCP SDK Version Override

Added a version override for @modelcontextprotocol/sdk to 1.13.2 in package.json. This was necessary because:

  • OpenCode's dependencies specify an outdated version of the MCP SDK (1.6.1)
  • The StreamableHTTPClientTransport class we need for HTTP Streaming support was introduced in later versions
  • Version 1.13.2 includes the necessary HTTP Streaming transport implementation while maintaining backward compatibility

3. Transport Selection Logic

Updated the MCP client initialization to support the new type values:

if (mcp.type === "http") {
  transport = new StreamableHTTPClientTransport(new URL(mcp.url))
} else {
  // SSE transport (for both "remote" and "sse")
  transport = {
    type: "sse",
    url: mcp.url,
  }
}

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

  • Tested with SSE, HTTP Streaming, and remote (SSE alias) transports
  • Verified backward compatibility with existing "remote" configurations
  • Confirmed successful connection and operation with HTTP Streaming servers
  • All TypeScript checks pass

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 setting type: "http".


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/444 **Author:** [@z80dev](https://github.com/z80dev) **Created:** 6/27/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `dev` --- ### 📝 Commits (10+) - [`84fe88a`](https://github.com/anomalyco/opencode/commit/84fe88abd1ea17cbc50bee9e514ff60acffb4a74) feat: HTTP Streaming support - [`1df868e`](https://github.com/anomalyco/opencode/commit/1df868ec13f7484d8915261991f8ffbcff743d98) better type spec - [`6cb9247`](https://github.com/anomalyco/opencode/commit/6cb9247f7798561a488c72168ffafc913b3b2c76) refactor: simplify MCP transport configuration based on PR feedback - [`f770f4d`](https://github.com/anomalyco/opencode/commit/f770f4d31723076cdad8fa5a51c0b1bbf618a711) Merge remote-tracking branch 'origin/dev' into dev - [`c273ca7`](https://github.com/anomalyco/opencode/commit/c273ca736c4c212cef1bc0ccf2cc2e1285ae6238) Update download stats 2025-07-03 - [`bb4cb13`](https://github.com/anomalyco/opencode/commit/bb4cb13015725ea9262c838cd78239d97c493991) Update download stats 2025-07-04 - [`4eaf313`](https://github.com/anomalyco/opencode/commit/4eaf313a02eab44e71561c25e5def652d383ffef) Update download stats 2025-07-05 - [`f1e5ca8`](https://github.com/anomalyco/opencode/commit/f1e5ca84de0f3da04a65943e94afa512c3aa762f) Update download stats 2025-07-06 - [`d36f325`](https://github.com/anomalyco/opencode/commit/d36f325aa73dafb32b014235a175b52bec334181) Update download stats 2025-07-07 - [`ead2c3e`](https://github.com/anomalyco/opencode/commit/ead2c3e6f9bf0bea233938ae696b3d7635745f88) Update download stats 2025-07-08 ### 📊 Changes **6 files changed** (+204 additions, -128 deletions) <details> <summary>View changed files</summary> 📝 `STATS.md` (+28 -6) 📝 `bun.lock` (+114 -103) 📝 `package.json` (+2 -1) 📝 `packages/opencode/config.schema.json` (+32 -10) 📝 `packages/opencode/src/config/config.ts` (+6 -2) 📝 `packages/opencode/src/mcp/index.ts` (+22 -6) </details> ### 📄 Description ## 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: 1. **Better Error Handling**: HTTP Streaming provides clearer error states and recovery mechanisms compared to SSE's limited error handling capabilities 2. **Reduced Latency**: Direct streaming without the overhead of SSE's event framing and reconnection logic 3. **Simpler Implementation**: No need for EventSource polyfills or SSE-specific server configurations 4. **Better Proxy Support**: Works more reliably through corporate proxies and firewalls that may block or interfere with SSE connections 5. **Standardization**: As MCP adoption grows, HTTP Streaming is becoming the preferred transport method in tools like Claude Code and other LLM tooling ## Changes ### 1. Configuration Schema Update Based on community feedback, we've simplified the configuration by using the `type` field to specify both the connection type and transport protocol: ```typescript type: z .enum(["remote", "sse", "http"]) .describe("Type of MCP server connection and transport protocol (remote is alias for sse)") ``` - `"remote"` - Kept as an alias for SSE to maintain backward compatibility - `"sse"` - Explicitly uses SSE transport - `"http"` - Uses HTTP Streaming transport ### 2. MCP SDK Version Override Added a version override for `@modelcontextprotocol/sdk` to `1.13.2` in `package.json`. This was necessary because: - OpenCode's dependencies specify an outdated version of the MCP SDK (1.6.1) - The `StreamableHTTPClientTransport` class we need for HTTP Streaming support was introduced in later versions - Version 1.13.2 includes the necessary HTTP Streaming transport implementation while maintaining backward compatibility ### 3. Transport Selection Logic Updated the MCP client initialization to support the new type values: ```typescript if (mcp.type === "http") { transport = new StreamableHTTPClientTransport(new URL(mcp.url)) } else { // SSE transport (for both "remote" and "sse") transport = { type: "sse", url: mcp.url, } } ``` ## Usage Users can now specify the transport method directly in the type field: **SSE Transport (default):** ```json { "mcp": { "myserver": { "type": "sse", "url": "https://my-mcp-server.com" } } } ``` **HTTP Streaming Transport:** ```json { "mcp": { "myserver": { "type": "http", "url": "https://my-mcp-server.com" } } } ``` **Backward Compatible (uses SSE):** ```json { "mcp": { "myserver": { "type": "remote", "url": "https://my-mcp-server.com" } } } ``` ## Testing - Tested with SSE, HTTP Streaming, and remote (SSE alias) transports - Verified backward compatibility with existing "remote" configurations - Confirmed successful connection and operation with HTTP Streaming servers - All TypeScript checks pass ## 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 setting `type: "http"`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:13:51 -05:00
yindo closed this issue 2026-02-16 18:13:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9615