From 61250e2bea0a50bae633f90e321e4f71382ba1db Mon Sep 17 00:00:00 2001 From: kei shingu Date: Sat, 25 Apr 2026 08:03:11 +0900 Subject: [PATCH] fix(cli-runtime): merge user mcp.servers into claude-cli bundle config prepareCliBundleMcpConfig was not including cfg.mcp.servers when building the temporary mcp.json that gets passed to claude-cli via --mcp-config. This meant user-defined MCP servers (e.g. mcp.servers.omi in openclaw.json) were silently dropped, even though --strict-mcp-config prevents any other path for those servers to reach the CLI session. The Pi runtime path (loadEmbeddedPiMcpConfig) already merges cfg.mcp.servers after the bundle layer. This commit applies the same merge to the CLI runtime path, with identical precedence: bundle defaults < user mcp.servers < additionalConfig (loopback). The loopback entry remains last so it cannot be overridden by user config. Fixes: user-configured MCP servers not appearing as mcp____* tools in claude-cli sessions started by OpenClaw. --- src/agents/cli-runner/bundle-mcp.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/agents/cli-runner/bundle-mcp.ts b/src/agents/cli-runner/bundle-mcp.ts index 4d3875ee87c..1189dba253a 100644 --- a/src/agents/cli-runner/bundle-mcp.ts +++ b/src/agents/cli-runner/bundle-mcp.ts @@ -3,6 +3,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { applyMergePatch } from "../../config/merge-patch.js"; +import { normalizeConfiguredMcpServers } from "../../config/mcp-config.js"; import type { CliBackendConfig } from "../../config/types.js"; import type { OpenClawConfig } from "../../config/types.openclaw.js"; import { @@ -415,6 +416,10 @@ export async function prepareCliBundleMcpConfig(params: { params.warn?.(`bundle MCP skipped for ${diagnostic.pluginId}: ${diagnostic.message}`); } mergedConfig = applyMergePatch(mergedConfig, bundleConfig.config) as BundleMcpConfig; + const configuredMcp = normalizeConfiguredMcpServers(params.config?.mcp?.servers); + if (Object.keys(configuredMcp).length > 0) { + mergedConfig = applyMergePatch(mergedConfig, { mcpServers: configuredMcp }) as BundleMcpConfig; + } if (params.additionalConfig) { mergedConfig = applyMergePatch(mergedConfig, params.additionalConfig) as BundleMcpConfig; }