Repository navigation
fix(mcp): import Hermes and OpenCode remote servers as Streamable HTTP - #8824
Conversation
Hermes connects to a `url` server over Streamable HTTP and uses SSE only when the entry sets `transport: sse`, and OpenCode connects to `remote` servers over Streamable HTTP. Both importers stored every such server as `sse`, so enabling an imported server for Claude Code or another app wrote `type: sse` for an endpoint that speaks Streamable HTTP. Import them as `http`, keep `sse` for Hermes entries that set `transport: sse`, and write `transport: sse` back to Hermes for SSE servers so that choice survives a sync.
farion1231
left a comment
There was a problem hiding this comment.
Thanks for the fix and the upstream references. The import side matches what Hermes and OpenCode actually do. One problem on the Hermes write side:
[P1] Rows stored as sse by the old importer now get transport: sse written into Hermes, which breaks servers that used to work
Before this change every Hermes url entry (and every OpenCode remote entry) was imported as type: sse, and convert_to_hermes_format wrote those rows back as a plain url. Hermes therefore kept connecting over Streamable HTTP, falling back to SSE on its own when needed. These rows are not migrated, and importing again does not fix them: for an id that already exists, import_from_hermes only sets apps.hermes and keeps the stored spec (hermes.rs#L309-L314).
After upgrading, the next time such a row is projected to Hermes (editing or toggling the server, or re-syncing MCP, all through sync_single_server_to_hermes), the new branch at hermes.rs#L98-L100 adds transport: sse, and merge_hermes_spec carries it into the existing entry. In Hermes, transport == "sse" takes the SSE path directly, and when SSE fails it does not retry Streamable HTTP (_run_http). An entry like notion: {url: https://mcp.notion.com/mcp} that was imported before this change and worked in Hermes would stop connecting.
I checked this on a merge with current main: merge_hermes_spec({"url": ..., "enabled": true, "timeout": 30}, convert_to_hermes_format({"type": "sse", "url": ...})) returns an entry with "transport": "sse".
The write side needs to handle rows stored as sse by the earlier importers before it starts emitting transport: sse, with a test that covers this upgrade path (an existing Hermes entry without transport plus a stored sse row).
Everything else passes on the merge with main (cargo fmt --check, cargo clippy -- -D warnings, cargo test). Once this is addressed it is good to merge, and I'm happy to re-review quickly.
Rows that earlier importers stored as `sse` came from plain Hermes `url` entries, which Hermes reaches over Streamable HTTP and falls back from to SSE on its own. Writing `transport: sse` for every SSE row would move those servers to SSE only, with no fallback, on their next sync. Write SSE rows without `transport` again, and keep a `transport: sse` that the existing Hermes entry already has while the server stays SSE.
|
Thanks, you're right. A row stored as
Tests: End to end, with a temporary integration test that is not part of the PR: Hermes has
|
funkpopo
left a comment
There was a problem hiding this comment.
Thanks for the clean fix in 3fc3cb3d!
- Importing Hermes
urlentries (unless explicitly markedtransport: sse) and OpenCoderemoteentries as Streamable HTTP (http) matches upstream client behavior. - The write-side regression from the previous review is resolved:
merge_into_existing_entrypreserves an existingtransport: ssewhile the server stayssse, never injectstransport: sseonto legacysserows, and drops it when switched tohttp, backed by 4 dedicated unit tests. - Merges cleanly onto latest
main(bd3d38801) with all CI checks green.
LGTM, ready to merge.
allenxu09
left a comment
There was a problem hiding this comment.
LGTM。
核对确认了 Hermes 与 OpenCode 远程 MCP 导入及回写逻辑:
- 导入语义对齐:
convert_from_hermes_format对纯url条目导入为http(仅transport: sse导入为sse),convert_from_opencode_format将remote导入为http,符合双方默认 Streamable HTTP 行为。 - 存量 SSE 条目回写安全:
merge_into_existing_entry仅在现有 Hermes 条目本身带有transport: sse且配置仍为sse时保留该字段;对旧版导入成sse但 Hermes 原配置无transport的条目不会误写入transport: sse,切回http时也会正确移除。 - 测试与 CI:新增及更新的单元测试覆盖各路径,跨平台后端 CI 全绿。
Summary / 概述
Hermes connects to a
urlMCP server over Streamable HTTP and uses SSE only when the entry setstransport: sse. OpenCode connects toremoteservers over Streamable HTTP. CC Switch imported every such server assse, so enabling an imported server for Claude Code or another app wrotetype: ssefor an endpoint that speaks Streamable HTTP. Writing a server back to Hermes also droppedtransport: sse.convert_from_hermes_format: aurlentry becomeshttp, orssewhen it setstransport: sse.transport: ssethat the existing entry already has while the server stayssse, and drops it when the server ishttp. It never adds one: rows that earlier importers stored asssecame from plainurlentries, which Hermes keeps reaching over Streamable HTTP.convert_from_opencode_format:remotebecomeshttp.This matches the newer importers: Pi, Agy, Mcode and Kimi already map a URL server without a transport to
http. Servers imported before this change keep the type they were stored with.Related Issue / 关联 Issue
Fixes #8823
Testing
End to end with a temporary integration test (not part of this PR). It sets up Hermes with
notion: {url: https://mcp.notion.com/mcp}andlegacy: {url: https://legacy.example.com/sse, transport: sse}and OpenCode with aremoteserverlinear, imports both, enables the three servers for Claude Code, then editslegacy:notion(Hermes, plainurl) in~/.claude.json"type":"sse""type":"http"linear(OpenCoderemote) in~/.claude.json"type":"sse""type":"http"legacy(Hermes,transport: sse) in~/.claude.json"type":"sse""type":"sse"legacyin Hermesconfig.yamlafter the edittransportdroppedtransport: ssekeptssefor a plain URL server. New tests:test_convert_hermes_sse_transport_to_unified,test_merge_keeps_hermes_sse_transport_while_server_is_sse,test_merge_drops_sse_transport_when_server_is_http, andtest_merge_does_not_add_transport_to_rows_stored_as_ssefor the upgrade path (an existing entry withouttransportplus a storedsserow).notion: {url: https://mcp.notion.com/mcp, enabled: true, timeout: 30}and a storedsserow for it, an edit in CC Switch writesnotionback withouttransport.cargo test: 4240 passed;cargo test --lib mcp::: 66 passed.cargo fmt --checkpasses.cargo clippy --libreports nothing in the changed files (Rust 1.99.1; its 5 warnings are inproxy/forwarder.rs,gemini_mcp.rsand the two auto-sync services).Checklist / 检查清单
cargo clippypasses (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)pnpm typecheck,pnpm format:checkand the i18n files are not affected.