Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-5843 fix(agent): stop silently dropping MCP servers on ACP runtimes (#6555)
Bohan Jiangad2d2eb8b415
diff --git a/CLI_AND_DAEMON.md b/CLI_AND_DAEMON.mdindex 4e33627a80..d5f5c7b329 100644--- a/CLI_AND_DAEMON.md+++ b/CLI_AND_DAEMON.md@@ -289,6 +289,19 @@ If a previously generated `~/.multica/hooks` wrapper is first on `PATH` and callThe daemon launches Qoder and Qoder CN as `qodercli --yolo --acp` and `qoderclicn --yolo --acp`, respectively, matching their ACP “bypass permissions” mode so tool runs do not block on interactive approval in headless runs.The daemon launches Qwen Code as `qwen -p <prompt> --output-format stream-json`. It writes the task brief to `QWEN.md`; when an agent has managed `mcp_config`, the daemon writes a 0600 per-run JSON file and passes it through `--mcp-config <path>`, then removes it after the process exits. A null config preserves Qwen Code native MCP settings.+#### `mcp_config` on ACP runtimes++ACP-family runtimes — Hermes, Kimi, Kiro, Grok, Qoder, Reasonix, Trae, Qwenpaw, and any custom runtime profile whose `protocol_family` is one of them — receive MCP servers **over the ACP session protocol**, not through a config file. The daemon translates the agent's `mcp_config` into ACP's `McpServer` array and sends it with `session/new`, and again with that runtime's resume request (`session/resume` on Hermes, Kimi, Qoder and Reasonix; `session/load` on Kiro, Grok, Trae and Qwenpaw) so a resumed task keeps the same tools.++Nothing is written to the runtime's own config file, and the runtime's own file is not read or merged. `~/.hermes/…`, `~/.jcode/mcp.json` and the like stay untouched; an agent's servers travel with its tasks instead of being installed per machine.++Two consequences are worth knowing before debugging a missing MCP tool:++- **`mcp_config` must use the canonical envelope**, `{"mcpServers": {"<name>": {…}}}`. Runtime-native config files that nest servers under `servers`, `mcp`, or `mcp_servers` are stored as-is but yield no servers; the daemon logs a warning naming the key it found. Entries themselves use the Claude-style shape (`command`/`args`/`env` for stdio, `url`/`headers`/`type` for remote).+- **Remote transports depend on what the runtime declares.** ACP v1 requires an omitted capability to be treated as unsupported, so `http` and `sse` entries are dropped with a warning unless the `initialize` response declares `agentCapabilities.mcpCapabilities` with that transport set to true. The built-in Hermes runtime is a verified exception: it declares no `mcpCapabilities` yet accepts both transports, so remote entries are still forwarded to it. That exception covers the Hermes binary only — a custom runtime profile with `protocol_family: hermes` runs a different implementation and keeps the standard rule. Stdio is never gated.++If a configured server produces no tools, check the daemon log for those warnings first, then confirm the runtime itself exposes the server's tools to the model — some ACP adapters apply their own tool-profile filtering after connecting.+The daemon launches QwenPaw as `qwenpaw acp --workspace <per-task dir>`. It writes the task brief to `AGENTS.md`, and materialises the run's bound skills into `<per-task dir>/skills/` plus a `skill.json` manifest, so QwenPaw discovers them through its own workspace skill discovery. `acp` and `--workspace` are reserved: `custom_args` cannot override them. QwenPaw is the one runtime with no `MULTICA_QWENPAW_MODEL`: its `session/set_model` writes to a shared, persistent agent config rather than the session, so Multica never sends it a model and leaves that choice to QwenPaw's own configuration.diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.goindex cb0327b4a2..c42df8bfbd 100644--- a/server/internal/daemon/daemon.go+++ b/server/internal/daemon/daemon.go@@ -5605,7 +5605,13 @@ func (d *Daemon) runTask(ctx context.Context, task Task, provider string, slot i// resolves to, paired with the path by resolveAgentEntry so a just-upgraded// codex is never launched under the previous version's policy (MUL-4486).var resolvedVersion string+ // usesCustomProfileCommand distinguishes "this provider's own binary" from+ // "some other binary speaking this provider's protocol". Backends need it+ // for compatibility exceptions verified against a specific vendor's CLI,+ // which must not extend to arbitrary commands sharing a protocol family.+ var usesCustomProfileCommand boolif customSpec, isCustom := d.customProfileLaunchForRuntime(task.RuntimeID); isCustom {+ usesCustomProfileCommand = trueentry.Path = customSpec.pathresolvedVersion = customSpec.versionprofileFixedArgs = customSpec.fixedArgs@@ -6073,6 +6079,7 @@ func (d *Daemon) runTask(ctx context.Context, task Task, provider string, slot iRuntimeID: task.RuntimeID,DaemonVersion: d.cfg.CLIVersion,CodexVersion: codexVersion,+ BuiltinRuntime: !usesCustomProfileCommand,})if err != nil {return TaskResult{}, fmt.Errorf("create agent backend: %w", err)diff --git a/server/pkg/agent/agent.go b/server/pkg/agent/agent.goindex d93121a1c5..33a4245adc 100644--- a/server/pkg/agent/agent.go+++ b/server/pkg/agent/agent.go@@ -232,6 +232,16 @@ type Config struct {RuntimeID stringDaemonVersion stringCodexVersion string+ // BuiltinRuntime reports that ExecutablePath is the provider's own+ // discovered binary rather than a custom runtime profile's command. A+ // custom profile keeps its protocol family as the provider, so the+ // provider name cannot distinguish the two: `protocol_family: hermes`+ // with `command_name: jcode` arrives as "hermes" while being an+ // unrelated implementation. Backends use this to scope+ // compatibility exceptions that were verified against a specific+ // vendor's binary; it defaults to false so an unset caller fails+ // closed onto standard behavior.+ BuiltinRuntime bool}// New creates a Backend for the given agent type.diff --git a/server/pkg/agent/grok.go b/server/pkg/agent/grok.goindex 4c3c7718e8..edf950c4c0 100644--- a/server/pkg/agent/grok.go+++ b/server/pkg/agent/grok.go@@ -312,7 +312,7 @@ func (b *grokBackend) Execute(ctx context.Context, prompt string, opts ExecOptio// Drop MCP entries whose remote transport the runtime didn't advertise.// See hermes.go for why sending an unsupported transport tanks session/new.- mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "grok", b.cfg.Logger)+ mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "grok", b.cfg)cwd := opts.Cwdif cwd == "" {diff --git a/server/pkg/agent/hermes.go b/server/pkg/agent/hermes.goindex 1b04efbb43..b617c3ffee 100644--- a/server/pkg/agent/hermes.go+++ b/server/pkg/agent/hermes.go@@ -386,7 +386,7 @@ func (b *hermesBackend) Execute(ctx context.Context, prompt string, opts ExecOpt// agentCapabilities.mcpCapabilities; sending an http/sse entry to// a runtime that says it only supports stdio reliably rejects the// whole session/new request.- mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "hermes", b.cfg.Logger)+ mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "hermes", b.cfg)// 2. Create or resume a session.cwd := opts.Cwd@@ -1891,6 +1891,7 @@ func buildACPMcpServers(raw json.RawMessage, logger *slog.Logger) ([]any, error)return nil, fmt.Errorf("parse mcp_config json: %w", err)}if len(parsed.McpServers) == 0 {+ warnNonCanonicalMcpConfigKey(trimmed, logger)return []any{}, nil}@@ -1914,6 +1915,50 @@ func buildACPMcpServers(raw json.RawMessage, logger *slog.Logger) ([]any, error)return out, nil}+// acpAltMcpConfigKeys are top-level keys that runtime-native MCP config+// files use instead of Multica's canonical `mcpServers`: jcode and Kiro+// nest under `servers`, OpenCode under `mcp`, Codex's TOML under+// `mcp_servers`.+var acpAltMcpConfigKeys = []string{"servers", "mcp", "mcp_servers"}++// warnNonCanonicalMcpConfigKey logs when an mcp_config carries no+// `mcpServers` key but does hold servers under a runtime-native one.+//+// mcp_config is stored as opaque JSON, so pasting a runtime's own config+// file in is both easy and — until this warning — completely silent: the+// config saves, the daemon forwards an empty array, and the agent runs+// with no MCP tools and nothing logged anywhere (#6540). We only warn+// rather than adopt the entries, because the surrounding entry shapes are+// not guaranteed to match ACP's and guessing risks forwarding a+// half-understood config.+func warnNonCanonicalMcpConfigKey(raw json.RawMessage, logger *slog.Logger) {+ if logger == nil {+ return+ }+ var top map[string]json.RawMessage+ if err := json.Unmarshal(raw, &top); err != nil {+ return+ }+ if _, ok := top["mcpServers"]; ok {+ return+ }+ for _, key := range acpAltMcpConfigKeys {+ nested, ok := top[key]+ if !ok {+ continue+ }+ var entries map[string]json.RawMessage+ if err := json.Unmarshal(nested, &entries); err != nil || len(entries) == 0 {+ continue+ }+ logger.Warn("mcp_config has no \"mcpServers\" key, so no MCP servers will be sent to the runtime",+ "found_key", key,+ "server_count", len(entries),+ "hint", `mcp_config must be shaped {"mcpServers": {"<name>": {...}}}; a runtime's own config file is not accepted verbatim`)+ return+ }+}+// convertACPMcpServer converts a single Claude-style entry into the ACP// McpServer wire shape. Returns an error for entries that can't be// classified (no command and no url).@@ -1997,57 +2042,163 @@ func sortedStringMapKeys(m map[string]string) []string {// runtime advertised in its `initialize` response. Stdio is always// supported (it's the baseline transport and the spec does not gate it),// so it's not represented here.+// acpMcpCapabilityDeclaration classifies what an ACP `initialize` response+// told us about remote MCP transports. All three states filter identically+// under ACP v1 — an undeclared transport is unsupported — but the+// omitted-capabilities exception may only key off genuine silence, so+// "the runtime said nothing" has to stay distinguishable from "we could not+// read what the runtime said".+type acpMcpCapabilityDeclaration int++const (+ // acpMcpCapabilitiesInvalid is the zero value on purpose: a response we+ // could not parse, a non-object block, or one whose fields have the+ // wrong types. Anything that reaches this state fails closed, so an+ // accidental zero value can never widen access.+ acpMcpCapabilitiesInvalid acpMcpCapabilityDeclaration = iota+ // acpMcpCapabilitiesOmitted is a well-formed response that carries no+ // mcpCapabilities block at all — the only state the exception accepts.+ acpMcpCapabilitiesOmitted+ // acpMcpCapabilitiesDeclared is a usable block, whose HTTP/SSE fields+ // are authoritative (including when both are false).+ acpMcpCapabilitiesDeclared+)+type acpMcpTransportCapabilities struct {- HTTP bool- SSE bool+ Declaration acpMcpCapabilityDeclaration+ HTTP bool+ SSE bool}// extractACPMcpCapabilities reads `agentCapabilities.mcpCapabilities.http`-// and `.sse` out of an ACP `initialize` response. Missing or false fields-// stay false, matching the spec default: the runtime must opt-in to-// remote MCP transports. Unparseable responses degrade to "neither-// supported" so we fail closed on remote entries.+// and `.sse` out of an ACP `initialize` response.//-// See https://agentclientprotocol.com/protocol/initialization — clients-// MUST NOT send `mcpServers` entries with a type the agent did not-// advertise support for.+// Per ACP v1 capability negotiation, "Clients and Agents MUST treat all+// capabilities omitted in the initialize request as UNSUPPORTED", and+// `http` / `sse` have no default beyond false. Every state therefore+// resolves to "neither transport supported"; the classification only+// decides whether the omitted-capabilities exception may apply.+//+// Each level is decoded as raw JSON rather than straight into the target+// struct, because encoding/json leaves a non-pointer destination untouched+// and reports no error when it decodes `null`. A single Unmarshal would+// therefore read `null`, `{"agentCapabilities":null}` and a genuinely+// silent response as the same thing, letting an unreadable response take+// the exception. ACP's InitializeResponse is an object and+// `agentCapabilities` is not nullable, so those two are malformed, not+// silent.+//+// See https://agentclientprotocol.com/protocol/v1/initialization#capabilities+// and https://pkg.go.dev/encoding/json#Unmarshal for the null rule.func extractACPMcpCapabilities(result json.RawMessage) acpMcpTransportCapabilities {- var r struct {- AgentCapabilities struct {- McpCapabilities struct {- HTTP bool `json:"http"`- SSE bool `json:"sse"`- } `json:"mcpCapabilities"`- } `json:"agentCapabilities"`+ invalid := acpMcpTransportCapabilities{Declaration: acpMcpCapabilitiesInvalid}+ omitted := acpMcpTransportCapabilities{Declaration: acpMcpCapabilitiesOmitted}++ var top map[string]json.RawMessage+ if err := json.Unmarshal(result, &top); err != nil || top == nil {+ return invalid}- if err := json.Unmarshal(result, &r); err != nil {- return acpMcpTransportCapabilities{}+ rawAgentCaps, ok := top["agentCapabilities"]+ if !ok {+ // A well-formed response that declares no capabilities at all.+ return omitted+ }+ var agentCaps map[string]json.RawMessage+ if err := json.Unmarshal(rawAgentCaps, &agentCaps); err != nil || agentCaps == nil {+ return invalid+ }+ rawMcp, ok := agentCaps["mcpCapabilities"]+ if !ok {+ // The real hermes 0.18.2 shape: capabilities declared, this block+ // genuinely absent. Only this state can reach the exception.+ return omitted+ }+ rawMcp = bytes.TrimSpace(rawMcp)+ if bytes.Equal(rawMcp, []byte("null")) {+ return invalid+ }+ var caps struct {+ HTTP bool `json:"http"`+ SSE bool `json:"sse"`+ }+ // A malformed block (wrong field types, non-object) is unusable. An+ // unusable declaration is not silence, so it must not reach the+ // omitted-capabilities exception — it fails closed instead.+ if err := json.Unmarshal(rawMcp, &caps); err != nil {+ return invalid}return acpMcpTransportCapabilities{- HTTP: r.AgentCapabilities.McpCapabilities.HTTP,- SSE: r.AgentCapabilities.McpCapabilities.SSE,+ Declaration: acpMcpCapabilitiesDeclared,+ HTTP: caps.HTTP,+ SSE: caps.SSE,}}+// acpRuntimesToleratingOmittedMcpCapabilities lists the ACP providers whose+// own shipped binary was verified to accept http/sse McpServer entries on+// session/new even though its initialize response carries no+// mcpCapabilities block.+//+// ACP v1 requires an omitted capability to be read as unsupported, so this+// is a deliberate, narrow exception to the spec default rather than a+// replacement for it. hermes 0.18.2 declares no mcpCapabilities yet accepts+// both remote transports, so applying the default there silently discarded+// every remote MCP server its users configured, with the drop visible only+// in the daemon log (#6540).+//+// Only add a provider here with evidence from its real binary — an ACP+// implementation that omits capabilities *and* rejects remote entries would+// turn a missing tool into a failed session, so the fail-closed default has+// to stay the rule for everything unverified.+var acpRuntimesToleratingOmittedMcpCapabilities = map[string]bool{+ "hermes": true,+}++// acpToleratesOmittedMcpCapabilities reports whether this launch may fall+// back to the omitted-capabilities exception.+//+// The provider name alone is not enough to answer that. A custom runtime+// profile keeps its protocol family as the provider and only swaps in its+// own command, so `protocol_family: hermes` with `command_name: jcode`+// reaches this backend as "hermes" while being a binary nobody verified —+// exactly the unverified implementation the allowlist exists to exclude.+// Config.BuiltinRuntime is the daemon's report of which case this is, and+// it defaults to false so any caller that doesn't set it fails closed.+func acpToleratesOmittedMcpCapabilities(backend string, cfg Config) bool {+ return cfg.BuiltinRuntime && acpRuntimesToleratingOmittedMcpCapabilities[backend]+}+// filterACPMcpServersByCapability drops remote MCP entries whose transport-// the runtime didn't advertise in its initialize response. Stdio entries+// the runtime did not advertise in its initialize response. Stdio entries// (no `type` field) always pass through.//// Sending an http/sse entry to a runtime that doesn't support it is a-// protocol violation per the ACP spec, and Hermes / Kimi observed in-// practice reject the whole session/new request with a JSON-RPC error.-// Dropping the offending entries with a warning lets the rest of the-// session start and surfaces the problem in the daemon log instead of-// tanking every task on that agent.+// protocol violation per the ACP spec and can reject the whole session/new+// request with a JSON-RPC error. Dropping the offending entries lets the+// rest of the session start instead of tanking every task on that agent.+//+// The single exception is a launch that acpToleratesOmittedMcpCapabilities+// accepts whose response declared no capabilities at all; see there and+// acpRuntimesToleratingOmittedMcpCapabilities for why that case is carved+// out and why it stays narrow. A response we could not read is not silence+// and never qualifies.func filterACPMcpServersByCapability(servers []any,caps acpMcpTransportCapabilities,backend string,- logger *slog.Logger,+ cfg Config,) []any {+ logger := cfg.Loggerif len(servers) == 0 {return servers}+ if caps.Declaration == acpMcpCapabilitiesOmitted && acpToleratesOmittedMcpCapabilities(backend, cfg) {+ if logger != nil && acpHasRemoteMcpEntry(servers) {+ logger.Info("runtime declared no mcpCapabilities; forwarding remote MCP servers under this runtime's verified exception",+ "backend", backend)+ }+ return servers+ }filtered := make([]any, 0, len(servers))for _, raw := range servers {entry, ok := raw.(map[string]any)@@ -2079,6 +2230,21 @@ func filterACPMcpServersByCapability(return filtered}+// acpHasRemoteMcpEntry reports whether any entry uses a remote transport,+// i.e. whether the capability question is relevant at all for this config.+func acpHasRemoteMcpEntry(servers []any) bool {+ for _, raw := range servers {+ entry, ok := raw.(map[string]any)+ if !ok {+ continue+ }+ if transport, _ := entry["type"].(string); transport == "http" || transport == "sse" {+ return true+ }+ }+ return false+}+// hermesToolNameFromTitle extracts a tool name from the ACP tool call title.// Hermes ACP titles look like "terminal: ls -la", "read: /path/to/file", etc.// Some titles have no colon (e.g. "execute code").diff --git a/server/pkg/agent/hermes_test.go b/server/pkg/agent/hermes_test.goindex ac0d66afc3..5fc3d1ab8f 100644--- a/server/pkg/agent/hermes_test.go+++ b/server/pkg/agent/hermes_test.go@@ -1,6 +1,7 @@package agentimport (+ "bytes""context""encoding/json""fmt"@@ -400,6 +401,69 @@ func TestBuildACPMcpServersReturnsErrorOnMalformedJSON(t *testing.T) {}}+// ── non-canonical mcp_config top-level keys ──++// buildACPMcpServersLogs runs the translation with a capturing logger and+// returns everything written, so the tests below can assert on the operator+// signal rather than only on the (still empty) server list.+func buildACPMcpServersLogs(t *testing.T, raw string) (string, []any) {+ t.Helper()+ var logs bytes.Buffer+ got, err := buildACPMcpServers(json.RawMessage(raw), slog.New(slog.NewJSONHandler(&logs, nil)))+ if err != nil {+ t.Fatalf("buildACPMcpServers(%s) error: %v", raw, err)+ }+ return logs.String(), got+}++// A runtime-native config pasted into mcp_config used to produce an empty+// server list and no log line at all — the agent just ran with no MCP tools+// (#6540). It still produces no servers, but it must no longer be silent.+func TestBuildACPMcpServersWarnsOnRuntimeNativeTopLevelKey(t *testing.T) {+ t.Parallel()+ // The exact shape from the #6540 reporter's jcode mcp.json.+ raw := `{"servers":{"codebase-memory":{"command":"/usr/local/bin/codebase-memory-mcp","args":[],"shared":true}}}`+ logs, got := buildACPMcpServersLogs(t, raw)+ if len(got) != 0 {+ t.Fatalf("servers: got %d, want 0 (entries are not adopted, only reported)", len(got))+ }+ if !strings.Contains(logs, "mcpServers") {+ t.Errorf("warning should name the canonical key; got %q", logs)+ }+ if !strings.Contains(logs, `"found_key":"servers"`) {+ t.Errorf("warning should name the key actually found; got %q", logs)+ }+}++func TestBuildACPMcpServersWarnsOnOtherRuntimeNativeKeys(t *testing.T) {+ t.Parallel()+ for _, key := range []string{"mcp", "mcp_servers"} {+ raw := fmt.Sprintf(`{%q:{"fetch":{"command":"uvx"}}}`, key)+ logs, got := buildACPMcpServersLogs(t, raw)+ if len(got) != 0 {+ t.Errorf("%s: servers got %d, want 0", key, len(got))+ }+ if !strings.Contains(logs, fmt.Sprintf(`"found_key":%q`, key)) {+ t.Errorf("%s: warning should name the key found; got %q", key, logs)+ }+ }+}++// A deliberately empty managed config is a valid state (it means "this agent+// has no MCP servers"), so it must not be reported as a misconfiguration.+func TestBuildACPMcpServersDoesNotWarnOnCanonicalOrEmptyConfig(t *testing.T) {+ t.Parallel()+ for _, raw := range []string{`{"mcpServers":{}}`, `{}`, `null`, `{"servers":{}}`} {+ logs, got := buildACPMcpServersLogs(t, raw)+ if len(got) != 0 {+ t.Errorf("%s: servers got %d, want 0", raw, len(got))+ }+ if strings.Contains(logs, "found_key") {+ t.Errorf("%s: should not warn, got %q", raw, logs)+ }+ }+}+// ── hermesToolNameFromTitle ──func TestHermesToolNameFromTitle(t *testing.T) {@@ -2736,50 +2800,132 @@ func TestExtractACPMcpCapabilities(t *testing.T) {tests := []struct {name stringraw string+ want acpMcpCapabilityDeclarationwantHTTP boolwantSSE bool}{{name: "both true",raw: `{"protocolVersion":1,"agentCapabilities":{"mcpCapabilities":{"http":true,"sse":true}}}`,+ want: acpMcpCapabilitiesDeclared,wantHTTP: true,wantSSE: true,},{name: "http only",raw: `{"agentCapabilities":{"mcpCapabilities":{"http":true}}}`,+ want: acpMcpCapabilitiesDeclared,wantHTTP: true,wantSSE: false,},{name: "sse only",raw: `{"agentCapabilities":{"mcpCapabilities":{"sse":true}}}`,+ want: acpMcpCapabilitiesDeclared,wantHTTP: false,wantSSE: true,},{- name: "block missing",+ name: "block present but both false",+ raw: `{"agentCapabilities":{"mcpCapabilities":{"http":false,"sse":false}}}`,+ want: acpMcpCapabilitiesDeclared,+ wantHTTP: false,+ wantSSE: false,+ },+ {+ name: "empty block counts as declared",+ raw: `{"agentCapabilities":{"mcpCapabilities":{}}}`,+ want: acpMcpCapabilitiesDeclared,+ wantHTTP: false,+ wantSSE: false,+ },+ {+ // hermes 0.18.2's real initialize response: no block at all.+ name: "block omitted",raw: `{"agentCapabilities":{}}`,+ want: acpMcpCapabilitiesOmitted,wantHTTP: false,wantSSE: false,},{name: "agentCapabilities missing",raw: `{"protocolVersion":1}`,+ want: acpMcpCapabilitiesOmitted,+ wantHTTP: false,+ wantSSE: false,+ },+ {+ // An explicit null is not silence and must not reach the+ // omitted-capabilities exception.+ name: "explicit null block",+ raw: `{"agentCapabilities":{"mcpCapabilities":null}}`,+ want: acpMcpCapabilitiesInvalid,+ wantHTTP: false,+ wantSSE: false,+ },+ {+ // encoding/json decodes `null` into a non-pointer destination+ // without touching it and without erroring, so these two used to+ // be indistinguishable from a genuinely silent response and took+ // the exception. ACP's InitializeResponse is an object and+ // agentCapabilities is not nullable — both are malformed.+ name: "whole result is null",+ raw: `null`,+ want: acpMcpCapabilitiesInvalid,+ wantHTTP: false,+ wantSSE: false,+ },+ {+ name: "agentCapabilities is null",+ raw: `{"protocolVersion":1,"agentCapabilities":null}`,+ want: acpMcpCapabilitiesInvalid,+ wantHTTP: false,+ wantSSE: false,+ },+ {+ name: "agentCapabilities is not an object",+ raw: `{"agentCapabilities":[]}`,+ want: acpMcpCapabilitiesInvalid,+ wantHTTP: false,+ wantSSE: false,+ },+ {+ name: "whole result is an array",+ raw: `[]`,+ want: acpMcpCapabilitiesInvalid,+ wantHTTP: false,+ wantSSE: false,+ },+ {+ // Unusable blocks must land in Invalid, not Omitted: Omitted is+ // the one state the compatibility exception accepts, and a+ // response we could not read is not evidence of silence.+ name: "block with wrong field types",+ raw: `{"agentCapabilities":{"mcpCapabilities":{"http":"yes"}}}`,+ want: acpMcpCapabilitiesInvalid,+ wantHTTP: false,+ wantSSE: false,+ },+ {+ name: "block is not an object",+ raw: `{"agentCapabilities":{"mcpCapabilities":"http"}}`,+ want: acpMcpCapabilitiesInvalid,wantHTTP: false,wantSSE: false,},{name: "malformed json",raw: `not json`,+ want: acpMcpCapabilitiesInvalid,wantHTTP: false,wantSSE: false,},}for _, tc := range tests {got := extractACPMcpCapabilities(json.RawMessage(tc.raw))- if got.HTTP != tc.wantHTTP || got.SSE != tc.wantSSE {- t.Errorf("%s: got {HTTP:%v SSE:%v}, want {HTTP:%v SSE:%v}", tc.name, got.HTTP, got.SSE, tc.wantHTTP, tc.wantSSE)+ if got.Declaration != tc.want || got.HTTP != tc.wantHTTP || got.SSE != tc.wantSSE {+ t.Errorf("%s: got {Declaration:%v HTTP:%v SSE:%v}, want {Declaration:%v HTTP:%v SSE:%v}",+ tc.name, got.Declaration, got.HTTP, got.SSE, tc.want, tc.wantHTTP, tc.wantSSE)}}}@@ -2793,12 +2939,119 @@ func TestFilterACPMcpServersByCapabilityStdioAlwaysPassesThrough(t *testing.T) {servers := []any{map[string]any{"name": "fetch", "command": "uvx"},}- got := filterACPMcpServersByCapability(servers, acpMcpTransportCapabilities{}, "hermes", slog.Default())+ got := filterACPMcpServersByCapability(servers, acpMcpTransportCapabilities{Declaration: acpMcpCapabilitiesDeclared}, "hermes", builtinACPConfig())if len(got) != 1 {t.Fatalf("len: got %d, want 1", len(got))}}+func mixedTransportACPServers() []any {+ return []any{+ map[string]any{"name": "stdio", "command": "uvx"},+ map[string]any{"type": "http", "name": "http", "url": "https://x/mcp"},+ map[string]any{"type": "sse", "name": "sse", "url": "https://x/sse"},+ }+}++// builtinACPConfig is the launch shape of a provider's own discovered+// binary — the only one the omitted-capabilities exception may apply to.+func builtinACPConfig() Config {+ return Config{Logger: slog.Default(), BuiltinRuntime: true}+}++// customProfileACPConfig is a custom runtime profile: the protocol family+// still arrives as the provider name, but the binary is someone else's.+func customProfileACPConfig() Config {+ return Config{Logger: slog.Default(), BuiltinRuntime: false}+}++func assertOnlyStdioSurvives(t *testing.T, label string, got []any) {+ t.Helper()+ if len(got) != 1 {+ t.Errorf("%s: len got %d, want 1 (only stdio survives)", label, len(got))+ return+ }+ if got[0].(map[string]any)["name"] != "stdio" {+ t.Errorf("%s: kept wrong entry: %v", label, got[0])+ }+}++// TestFilterACPMcpServersByCapabilityOmittedForwardsOnListedRuntime pins the+// #6540 exception: hermes 0.18.2 declares no mcpCapabilities yet accepts both+// remote transports, so applying the ACP default there silently discarded+// every remote server its users configured.+func TestFilterACPMcpServersByCapabilityOmittedForwardsOnListedRuntime(t *testing.T) {+ t.Parallel()+ caps := acpMcpTransportCapabilities{Declaration: acpMcpCapabilitiesOmitted}+ got := filterACPMcpServersByCapability(mixedTransportACPServers(), caps, "hermes", builtinACPConfig())+ if len(got) != 3 {+ t.Fatalf("len: got %d, want 3 (built-in hermes is a verified exception)", len(got))+ }+}++// ...and the exception must stay scoped to runtimes with real evidence.+// Everything else keeps the ACP v1 default, where an omitted capability is+// UNSUPPORTED — forwarding there could turn a missing tool into a failed+// session on an implementation nobody has tested.+func TestFilterACPMcpServersByCapabilityOmittedStillDropsOnUnlistedRuntimes(t *testing.T) {+ t.Parallel()+ caps := acpMcpTransportCapabilities{Declaration: acpMcpCapabilitiesOmitted}+ for _, backend := range []string{"kimi", "kiro", "grok", "qoder", "reasonix", "traecli", "qwenpaw"} {+ assertOnlyStdioSurvives(t, backend,+ filterACPMcpServersByCapability(mixedTransportACPServers(), caps, backend, builtinACPConfig()))+ }+}++// TestFilterACPMcpServersByCapabilityOmittedStillDropsOnCustomProfile pins+// the scope of the exception to the vendor's own binary. A custom runtime+// profile keeps its protocol family as the provider, so `protocol_family:+// hermes` with `command_name: jcode` reaches this filter as "hermes" while+// being an implementation nobody verified — it must not inherit hermes'+// compatibility exception.+func TestFilterACPMcpServersByCapabilityOmittedStillDropsOnCustomProfile(t *testing.T) {+ t.Parallel()+ caps := acpMcpTransportCapabilities{Declaration: acpMcpCapabilitiesOmitted}+ assertOnlyStdioSurvives(t, "custom profile on hermes family",+ filterACPMcpServersByCapability(mixedTransportACPServers(), caps, "hermes", customProfileACPConfig()))+}++// TestFilterACPMcpServersByCapabilityInvalidNeverTakesTheException walks the+// real path — extract, then filter — for every response shape that is+// unreadable rather than silent. An unusable declaration is not evidence+// that the runtime declared nothing, so none of these may reach the+// exception even on a listed, built-in runtime.+func TestFilterACPMcpServersByCapabilityInvalidNeverTakesTheException(t *testing.T) {+ t.Parallel()+ for _, raw := range []string{+ `{"agentCapabilities":{"mcpCapabilities":{"http":"yes"}}}`,+ `{"agentCapabilities":{"mcpCapabilities":{"sse":1}}}`,+ `{"agentCapabilities":{"mcpCapabilities":"http"}}`,+ `{"agentCapabilities":{"mcpCapabilities":[]}}`,+ `{"agentCapabilities":{"mcpCapabilities":null}}`,+ // The null-decoding shapes: encoding/json accepts these silently,+ // so only explicit per-level validation keeps them out of the+ // exception.+ `null`,+ `{"protocolVersion":1,"agentCapabilities":null}`,+ `{"agentCapabilities":[]}`,+ `[]`,+ `not json`,+ } {+ caps := extractACPMcpCapabilities(json.RawMessage(raw))+ assertOnlyStdioSurvives(t, raw,+ filterACPMcpServersByCapability(mixedTransportACPServers(), caps, "hermes", builtinACPConfig()))+ }+}++// An explicit all-false block is a declaration, not silence, so even a+// listed runtime honours it — the exception covers absence only.+func TestFilterACPMcpServersByCapabilityExplicitOptOutStillDrops(t *testing.T) {+ t.Parallel()+ caps := acpMcpTransportCapabilities{Declaration: acpMcpCapabilitiesDeclared}+ assertOnlyStdioSurvives(t, "explicit opt-out",+ filterACPMcpServersByCapability(mixedTransportACPServers(), caps, "hermes", builtinACPConfig()))+}+func TestFilterACPMcpServersByCapabilityDropsUnsupportedHttp(t *testing.T) {t.Parallel()servers := []any{@@ -2806,7 +3059,7 @@ func TestFilterACPMcpServersByCapabilityDropsUnsupportedHttp(t *testing.T) {map[string]any{"type": "http", "name": "http-drop", "url": "https://x/mcp"},map[string]any{"type": "sse", "name": "sse-keep", "url": "https://x/sse"},}- got := filterACPMcpServersByCapability(servers, acpMcpTransportCapabilities{SSE: true}, "hermes", slog.Default())+ got := filterACPMcpServersByCapability(servers, acpMcpTransportCapabilities{Declaration: acpMcpCapabilitiesDeclared, SSE: true}, "hermes", builtinACPConfig())if len(got) != 2 {t.Fatalf("len: got %d, want 2 (http should be dropped, sse kept)", len(got))}@@ -2825,7 +3078,7 @@ func TestFilterACPMcpServersByCapabilityDropsUnsupportedSse(t *testing.T) {map[string]any{"type": "sse", "name": "sse-drop", "url": "https://x/sse"},map[string]any{"type": "http", "name": "http-keep", "url": "https://x/mcp"},}- got := filterACPMcpServersByCapability(servers, acpMcpTransportCapabilities{HTTP: true}, "kimi", slog.Default())+ got := filterACPMcpServersByCapability(servers, acpMcpTransportCapabilities{Declaration: acpMcpCapabilitiesDeclared, HTTP: true}, "kimi", builtinACPConfig())if len(got) != 1 {t.Fatalf("len: got %d, want 1", len(got))}@@ -2841,7 +3094,7 @@ func TestFilterACPMcpServersByCapabilityKeepsAllWhenBothSupported(t *testing.T)map[string]any{"type": "http", "name": "http", "url": "https://x/mcp"},map[string]any{"type": "sse", "name": "sse", "url": "https://x/sse"},}- got := filterACPMcpServersByCapability(servers, acpMcpTransportCapabilities{HTTP: true, SSE: true}, "kiro", slog.Default())+ got := filterACPMcpServersByCapability(servers, acpMcpTransportCapabilities{Declaration: acpMcpCapabilitiesDeclared, HTTP: true, SSE: true}, "kiro", builtinACPConfig())if len(got) != 3 {t.Fatalf("len: got %d, want 3", len(got))}@@ -2849,7 +3102,7 @@ func TestFilterACPMcpServersByCapabilityKeepsAllWhenBothSupported(t *testing.T)func TestFilterACPMcpServersByCapabilityEmptyInputReturnsEmpty(t *testing.T) {t.Parallel()- got := filterACPMcpServersByCapability(nil, acpMcpTransportCapabilities{HTTP: true, SSE: true}, "hermes", slog.Default())+ got := filterACPMcpServersByCapability(nil, acpMcpTransportCapabilities{Declaration: acpMcpCapabilitiesDeclared, HTTP: true, SSE: true}, "hermes", builtinACPConfig())if len(got) != 0 {t.Errorf("len: got %d, want 0", len(got))}@@ -3192,18 +3445,126 @@ func TestHermesResumeIncludesMcpServers(t *testing.T) {}}-// TestHermesDropsRemoteMcpWhenCapabilityNotAdvertised pins the contract-// that when the runtime's initialize response advertises no http/sse-// support, those entries are filtered out of session/new — sending them-// anyway is a protocol violation that reliably tanks the request.-func TestHermesDropsRemoteMcpWhenCapabilityNotAdvertised(t *testing.T) {+// TestHermesForwardsRemoteMcpUnderOmittedCapabilitiesException pins the+// #6540 fix end to end. Real hermes 0.18.2 responds exactly like this fake —+// no mcpCapabilities block — while accepting both remote transports, so it+// is on the verified exception list and its users' http/sse servers must+// reach session/new instead of vanishing into a daemon log. Runtimes off+// that list keep the ACP v1 default; see the qoder counterpart.+func TestHermesForwardsRemoteMcpUnderOmittedCapabilitiesException(t *testing.T) {t.Parallel()recordPath := filepath.Join(t.TempDir(), "frames.jsonl")fakePath := filepath.Join(t.TempDir(), "hermes")- // agentCapabilities = {} → neither http nor sse advertised.+ // agentCapabilities = {} → no mcpCapabilities block at all.writeTestExecutable(t, fakePath, []byte(fakeACPRecordingScript(recordPath, "ses_new", `{}`)))+ backend, err := New("hermes", Config{ExecutablePath: fakePath, Logger: slog.Default(), BuiltinRuntime: true})+ if err != nil {+ t.Fatalf("new hermes backend: %v", err)+ }++ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)+ defer cancel()+ session, err := backend.Execute(ctx, "prompt-ignored", ExecOptions{+ Timeout: 30 * time.Second,+ McpConfig: json.RawMessage(`{"mcpServers":{+ "local":{"command":"uvx"},+ "remote-http":{"type":"http","url":"https://x/mcp"},+ "remote-sse":{"type":"sse","url":"https://x/sse"}+ }}`),+ })+ if err != nil {+ t.Fatalf("execute: %v", err)+ }+ go func() {+ for range session.Messages {+ }+ }()+ select {+ case <-session.Result:+ case <-time.After(10 * time.Second):+ t.Fatal("timeout waiting for result")+ }++ frame := findRecordedFrame(t, recordPath, "session/new")+ params := frame["params"].(map[string]any)+ servers, ok := params["mcpServers"].([]any)+ if !ok {+ t.Fatalf("session/new.mcpServers: got %T, want []any", params["mcpServers"])+ }+ if len(servers) != 3 {+ t.Fatalf("session/new.mcpServers: got %d entries, want 3 (nothing declared means nothing declined)", len(servers))+ }+}++// TestHermesCustomProfileDropsRemoteMcpWhenCapabilityOmitted is the same+// runtime family and the same silent initialize response, launched the way+// the daemon launches a custom runtime profile. jcode reaches this backend+// as "hermes" while being a binary nobody verified, so it must get the ACP+// v1 default rather than hermes' compatibility exception.+func TestHermesCustomProfileDropsRemoteMcpWhenCapabilityOmitted(t *testing.T) {+ t.Parallel()++ recordPath := filepath.Join(t.TempDir(), "frames.jsonl")+ fakePath := filepath.Join(t.TempDir(), "jcode")+ writeTestExecutable(t, fakePath, []byte(fakeACPRecordingScript(recordPath, "ses_new", `{}`)))++ // BuiltinRuntime stays false: this is a custom profile's command, not+ // the hermes binary the exception was verified against.+ backend, err := New("hermes", Config{ExecutablePath: fakePath, Logger: slog.Default()})+ if err != nil {+ t.Fatalf("new hermes backend: %v", err)+ }++ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)+ defer cancel()+ session, err := backend.Execute(ctx, "prompt-ignored", ExecOptions{+ Timeout: 30 * time.Second,+ McpConfig: json.RawMessage(`{"mcpServers":{+ "local":{"command":"uvx"},+ "remote-http":{"type":"http","url":"https://x/mcp"},+ "remote-sse":{"type":"sse","url":"https://x/sse"}+ }}`),+ })+ if err != nil {+ t.Fatalf("execute: %v", err)+ }+ go func() {+ for range session.Messages {+ }+ }()+ select {+ case <-session.Result:+ case <-time.After(10 * time.Second):+ t.Fatal("timeout waiting for result")+ }++ frame := findRecordedFrame(t, recordPath, "session/new")+ params := frame["params"].(map[string]any)+ servers, ok := params["mcpServers"].([]any)+ if !ok {+ t.Fatalf("session/new.mcpServers: got %T, want []any", params["mcpServers"])+ }+ if len(servers) != 1 {+ t.Fatalf("session/new.mcpServers: got %d entries, want 1 (a custom profile does not inherit the exception)", len(servers))+ }+ if servers[0].(map[string]any)["name"] != "local" {+ t.Errorf("kept the wrong entry: %v", servers[0])+ }+}++// TestHermesDropsRemoteMcpWhenCapabilityExplicitlyDeclined pins the other+// half of the contract: an mcpCapabilities block that is present and says+// false IS a declaration, and sending those entries anyway is the protocol+// violation the filter exists to prevent.+func TestHermesDropsRemoteMcpWhenCapabilityExplicitlyDeclined(t *testing.T) {+ t.Parallel()++ recordPath := filepath.Join(t.TempDir(), "frames.jsonl")+ fakePath := filepath.Join(t.TempDir(), "hermes")+ writeTestExecutable(t, fakePath, []byte(fakeACPRecordingScript(recordPath, "ses_new", `{"mcpCapabilities":{"http":false,"sse":false}}`)))+backend, err := New("hermes", Config{ExecutablePath: fakePath, Logger: slog.Default()})if err != nil {t.Fatalf("new hermes backend: %v", err)@@ -3239,7 +3600,7 @@ func TestHermesDropsRemoteMcpWhenCapabilityNotAdvertised(t *testing.T) {t.Fatalf("session/new.mcpServers: got %T, want []any", params["mcpServers"])}if len(servers) != 1 {- t.Fatalf("session/new.mcpServers: got %d entries, want 1 (only stdio should remain)", len(servers))+ t.Fatalf("session/new.mcpServers: got %d entries, want 1 (only stdio survives an explicit opt-out)", len(servers))}if servers[0].(map[string]any)["name"] != "local" {t.Errorf("kept the wrong entry: %v", servers[0])diff --git a/server/pkg/agent/kimi.go b/server/pkg/agent/kimi.goindex 8e00d9e29d..165e2629bb 100644--- a/server/pkg/agent/kimi.go+++ b/server/pkg/agent/kimi.go@@ -231,7 +231,7 @@ func (b *kimiBackend) Execute(ctx context.Context, prompt string, opts ExecOptio// advertise. See the matching comment in hermes.go for the why —// shipping an http/sse entry to a stdio-only runtime tanks the// whole session/new.- mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "kimi", b.cfg.Logger)+ mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "kimi", b.cfg)// 2. Create or resume a session.cwd := opts.Cwddiff --git a/server/pkg/agent/kiro.go b/server/pkg/agent/kiro.goindex 073ca4d2c6..07d3b99b8f 100644--- a/server/pkg/agent/kiro.go+++ b/server/pkg/agent/kiro.go@@ -253,7 +253,7 @@ func (b *kiroBackend) Execute(ctx context.Context, prompt string, opts ExecOptio// advertise. See the matching comment in hermes.go for why// unconditionally sending http/sse to a stdio-only ACP runtime// tanks the whole session/new.- mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "kiro", b.cfg.Logger)+ mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "kiro", b.cfg)cwd := opts.Cwdif cwd == "" {diff --git a/server/pkg/agent/qoder.go b/server/pkg/agent/qoder.goindex 4bae2a12cf..ee3dd56f7d 100644--- a/server/pkg/agent/qoder.go+++ b/server/pkg/agent/qoder.go@@ -244,7 +244,7 @@ func (b *qoderBackend) Execute(ctx context.Context, prompt string, opts ExecOpti// advertise. See the matching comment in hermes.go for why// unconditionally sending http/sse to a stdio-only ACP runtime// tanks the whole session/new.- mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "qoder", b.cfg.Logger)+ mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "qoder", b.cfg)cwd := opts.Cwdif cwd == "" {diff --git a/server/pkg/agent/qoder_test.go b/server/pkg/agent/qoder_test.goindex 33721cc666..5c0f967e13 100644--- a/server/pkg/agent/qoder_test.go+++ b/server/pkg/agent/qoder_test.go@@ -759,6 +759,9 @@ func TestQoderForwardsMcpAuthHeaderToSessionNew(t *testing.T) {}}+// Qoder is not on the omitted-capabilities exception list, so it keeps the+// ACP v1 default: capabilities the runtime never advertised are unsupported+// and remote entries are filtered out of session/new.func TestQoderFiltersRemoteMcpWhenInitializeDoesNotAdvertiseCapability(t *testing.T) {t.Parallel()diff --git a/server/pkg/agent/qwenpaw.go b/server/pkg/agent/qwenpaw.goindex e105159eae..3abd484d0b 100644--- a/server/pkg/agent/qwenpaw.go+++ b/server/pkg/agent/qwenpaw.go@@ -203,7 +203,7 @@ func (b *qwenpawBackend) Execute(ctx context.Context, prompt string, opts ExecOpreturn}- mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "qwenpaw", b.cfg.Logger)+ mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "qwenpaw", b.cfg)// 2. Create or resume a session.cwd := opts.Cwddiff --git a/server/pkg/agent/reasonix.go b/server/pkg/agent/reasonix.goindex 7d6a7987bd..f75fa5a6c9 100644--- a/server/pkg/agent/reasonix.go+++ b/server/pkg/agent/reasonix.go@@ -266,7 +266,7 @@ func (b *reasonixBackend) Execute(ctx context.Context, prompt string, opts ExecO// advertise. See the matching comment in hermes.go for the why —// shipping an http/sse entry to a stdio-only runtime tanks the// whole session/new.- mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "reasonix", b.cfg.Logger)+ mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "reasonix", b.cfg)// 2. Create or resume a session.cwd := opts.Cwddiff --git a/server/pkg/agent/traecli.go b/server/pkg/agent/traecli.goindex 9bce64ad0c..63ea45a511 100644--- a/server/pkg/agent/traecli.go+++ b/server/pkg/agent/traecli.go@@ -252,7 +252,7 @@ func (b *traecliBackend) Execute(ctx context.Context, prompt string, opts ExecOp// Drop MCP entries whose remote transport the runtime didn't advertise// (traecli advertises mcpCapabilities {http, sse}). See hermes.go for// why sending an unsupported transport tanks the whole session/new.- mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "traecli", b.cfg.Logger)+ mcpServers = filterACPMcpServersByCapability(mcpServers, extractACPMcpCapabilities(initResult), "traecli", b.cfg)cwd := opts.Cwdif cwd == "" {