Skip to content

fix(mcp,agents,server): serve MCP 2026-07-28 cache hints and deliver the companion per session - #141

Closed
kinddde wants to merge 4 commits into
DimoADE:masterfrom
kinddde:fix/mcp-modern-protocol-handshake
Closed

kinddde wants to merge 4 commits into
DimoADE:masterfrom
kinddde:fix/mcp-modern-protocol-handshake

Conversation

@kinddde

@kinddde kinddde commented Dec 3, 2026

Copy link
Copy Markdown

Summary

Three independent gaps kept every modern MCP client from mounting the product companion. All three are the SEP-2549 cache hints that MCP 2026-07-28 makes required; the fourth change is a delivery rule that only ever worked for clients Dimo does not launch.

 crates/dimo-mcp/src/main.rs
-  discover_result  -> { resultType, supportedVersions, capabilities, _meta }
-  tools/list       -> { tools }
+  discover_result  -> { ..., ttlMs: 0, cacheScope: "private" }
+  tools/list       -> { ..., ttlMs: 0, cacheScope: "private" }

 plugins/{browser,computer-use}/runtime/*.mjs
+  modernize() adds the same pair to every list-shaped result

 crates/agents/src/profiles/mod.rs
-  delivers_session_mcp = !(Openclaw | Cline | Pi | DeepseekHarness)
+  delivers_session_mcp = !(Openclaw | Cline | Pi)

 crates/agents/src/manager/runner/replay.rs
+  merged session MCP list -> dedupe_by_name (first source wins)

 crates/server/src/host/plugin_projections.rs
-  superagent projection -> every assignable Agent config file
+  superagent projection -> Cline only (every other Agent gets it per session)
+  sweep Plugin projections whose runtime paths are gone

Why each gap mattered:

  • server/discover — rmcp decodes the reply as DiscoverResult, whose ttl_ms and cache_scope are non-optional. Without them serde falls through to another result variant and the handshake fails with expect initialized result, but received: Some(CallToolResult(...)).
  • tools/list — dsh-mcp-client validates the same pair; because deepseek-acp sets failOnStartupError: true for client-supplied servers, a rejected catalog failed the whole session/new.
  • DeepSeek Harness delivery — its ACP adapter does mount the session/new list, so excluding it only removed the tools. The Host keeps ~/.dsh/mcp.json for the adapter's own runs and now injects the same servers per session.
  • Projection scope — a config-file entry cannot carry --conversation-id, so a globally projected companion competed with the per-session entry of the same name and left Codex without a ready client for threads Dimo did not launch.
  • Orphan sweep — reconcile_disabled_and_uninstalled_plugin_projections had no caller, and it could only see servers still present in the local store, so a projection left behind by an uninstalled Plugin survived forever and broke any Agent that read that config.

Evidence

codex app-server + thread/start with the exact config Dimo injects:

  • Before: mcpServer/startupStatus/updated → status: "failed", handshaking with MCP server failed: expect initialized result, but received: Some(CallToolResult(...)).
    After: Dimo-superagent-mcp: starting → ready, dimo-browser-browser-tools: starting → ready.

DSH via a real deepseek-acp@0.13.0 handshake:

  • Before: mcp-client(a1_Dimo-superagent-mcp): initial connection or tool synchronization failed, session/new failed.
    After: session/new returns a session id; the adapter logs mounted 2 local MCP server(s) with no mcp-client error.

Tests:

  • cargo test -p dimo-mcp --bin dimo-mcp → 56 passed
  • cargo test -p server --lib spec_runtime_paths → 2 passed
  • cargo test -p agents (mcp_wire, agents_that_skip_session_mcp) → passed
  • cargo check -p server → clean; node scripts/check-arch-invariants.mjs → 0 violations
  • pnpm run electron:package → installer builds against the patched binaries

Merge Danger

Door: two-way — every change is protocol emission or projection scope, and each reverts independently.

Blast Radius: MCP tool availability for every Agent session. The projection change also stops writing Dimo-superagent-mcp into Agent config files for CLIs Dimo does not launch (Claude Code, Cursor, Antigravity, Codex, DSH); those CLIs lose the companion outside Dimo, where it could never carry a conversation identity. The orphan sweep only removes entries that carry a Dimo Plugin marker and whose absolute runtime paths no longer exist, so user-configured servers are untouched.

kjcui added 4 commits December 3, 2026 17:24
MCP 2026-07-28 makes ttlMs and cacheScope required on list-shaped results. rmcp decodes a discover reply strictly, so a missing pair falls through to another result variant and the modern handshake fails with 'expect initialized result'. Report a private, non-cacheable catalog instead: the tool set depends on the session's --features and conversation scope.
…CP servers

Both plugin wire servers answered discover and tools/list with the legacy shape, so a modern client rejected the whole catalog. A build ships the bundled dist alongside the runtime source.
…rver name

DeepSeek Harness mounts the session/new list through its ACP adapter, so excluding it from delivery only removed the tools. Its companion stays on disk for the agent's own runs, and the Host injects the same servers per session. Sources can name one server twice, and adapters reject a repeated name, so the merged list keeps the first occurrence.
…an plugin projections

Only Cline never mounts session MCP, so only Cline needs a config-file companion; every other Agent gets it per session, where --conversation-id exists. The disabled/uninstalled reconcile had no caller, and it could only see servers still in the local store, so a projection left behind by an uninstalled Plugin survived forever. Wire it into plugin startup and sweep projections whose runtime paths are gone.
@kinddde kinddde closed this Dec 3, 2026
@kinddde
kinddde deleted the fix/mcp-modern-protocol-handshake branch December 3, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants