Skip to content

install writes MCP config to wrong key path for OpenClaw (mcpServers vs mcp.servers) — server never loads #653

Description

@DerekEXS

Summary

codebase-memory-mcp install writes the MCP server config to the wrong JSON key path for OpenClaw, so OpenClaw never loads the server. The config lands at the top-level mcpServers key, but OpenClaw's config schema expects it nested under mcp.servers.

Environment

  • codebase-memory-mcp: installed via install (standard build, stdio transport)
  • OpenClaw: 2026.6.10 (config schema McpConfigSchema expects mcp.servers)
  • OS: Linux

Root cause

In src/cli/cli.c:

  • install_editor_agent_configs (around line 3233) routes OpenClaw through install_generic_agent_config(..., cbm_install_editor_mcp).
  • cbm_install_editor_mcp (line 789) writes the server entry under the top-level mcpServers key (lines 815-818):
/* Get or create mcpServers object */
yyjson_mut_val *servers = yyjson_mut_obj_get(root, "mcpServers");
...
yyjson_mut_obj_add_val(mdoc, root, "mcpServers", servers);

This mcpServers (camelCase, top-level) shape is correct for Cursor / Windsurf / Gemini / VS Code / Zed / KiloCode, which is why cbm_install_editor_mcp is shared across them. But OpenClaw's schema reads mcp.servers (dotted/nested), not top-level mcpServers. So the written entry is silently ignored.

Observed behavior

After running install with OpenClaw detected:

  • Install reports: OpenClaw: mcp: ~/.openclaw/openclaw.json
  • But ~/.openclaw/openclaw.json only gains a top-level mcpServers object.
  • openclaw mcp list does NOT list codebase-memory-mcp.
  • openclaw mcp probe reports 0 tools from the server.
  • The MCP server is effectively not installed for OpenClaw.

Expected behavior

For OpenClaw, the install should write the nested form:

{
  "mcp": {
    "servers": {
      "codebase-memory-mcp": {
        "enabled": true,
        "command": "<binary_path>",
        "args": []
      }
    }
  }
}

OpenClaw's mcp.servers entries use command + args (stdio) or url + transport (http), with an optional enabled flag — not the flat mcpServers map.

Suggested fix

Give OpenClaw its own install path (similar to how Codex/Aider get section-based configs) instead of reusing cbm_install_editor_mcp. Either:

  1. Add a dedicated cbm_install_openclaw_mcp that writes the nested mcp.servers shape, and route OpenClaw to it in install_editor_agent_configs; or
  2. Make cbm_install_editor_mcp schema-aware per agent (pass the target key path as a parameter).

The uninstall path (uninstall_agent_mcp_instr for OpenClaw, around line 3711) likely has the mirror issue and should be checked together.

Workaround

Manually inject the nested entry (e.g. with jq) and restart the OpenClaw gateway:

jq '.mcp.servers["codebase-memory-mcp"] = {
  "enabled": true,
  "command": "<binary_path>",
  "args": []
}' ~/.openclaw/openclaw.json > /tmp/oc.json.new && mv /tmp/oc.json.new ~/.openclaw/openclaw.json

After restart, openclaw mcp probe correctly reports codebase-memory-mcp: 14 tools.

Additional context

  • OpenClaw and the editor agents (Cursor et al.) genuinely use different config schemas, so sharing cbm_install_editor_mcp across all of them is the underlying mismatch.
  • The same top-level mcpServers write is fine for the other editors; only OpenClaw is affected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions