mirror of
https://github.com/mksglu/context-mode.git
synced 2026-09-19 03:27:16 +08:00
next
1 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6b1775736a |
fix(openclaw): register MCP sidecar on install so ctx_* tools surface to agent (#339)
* fix(openclaw): register MCP sidecar on install so ctx_* tools surface to agent context-mode's ctx_* tools live in server.bundle.mjs and are exposed over stdio MCP. Other adapters (Claude Code, Codex, Cursor) spawn the bundle via their platform's mcpServers config. The OpenClaw install script wrote plugins.allow / plugins.entries to openclaw.json but never added mcp.servers.context-mode, so the gateway never spawned the sidecar and the agent never saw the ctx_* tool list — while openclaw plugins list, openclaw doctor, and scripts/ctx-debug.sh all reported healthy state. Changes - scripts/lib/register-openclaw-config.mjs (new): extracts step 5 of the install script into a testable helper. Writes plugins.allow / .entries / cleans legacy plugins.load.paths (existing behavior) and additionally registers mcp.servers.context-mode pointing at <pluginRoot>/server.bundle.mjs. Idempotent: re-running is a no-op; stale server paths are refreshed. - scripts/install-openclaw-plugin.sh: step 5 delegates to the helper. - tests/plugins/openclaw.test.ts: 5 unit tests for the helper (MCP entry presence, idempotency, stale-path refresh, plugins.allow/entries contract, legacy plugins.load.paths cleanup). - docs/adapters/openclaw.md: new troubleshooting entry documenting the MCP sidecar requirement and the manual openclaw mcp set recovery command. Verification - npm run typecheck: clean - vitest tests/plugins/openclaw.test.ts tests/adapters/openclaw.test.ts: 117/117 pass (baseline 112 + 5 new) - Live: on OpenClaw 2026.4.22 + context-mode 1.0.89, after the fix the agent tool inventory includes context-mode__ctx_execute, context-mode__ctx_search, context-mode__ctx_fetch_and_index, and the rest of the ctx_* surface (OpenClaw prefixes MCP-sourced tools with the server name). Debugging walkthrough (initial wrong diagnosis, cross-check with @benzntech, server.ts trace that surfaced the registerTool calls, final resolution): https://gist.github.com/murataslan1/cd7b27577fcb535d56fe318c2339b400 Companion to issue #45 (follow-up comment: https://github.com/mksglu/context-mode/issues/45#issuecomment-4313313422). Pre-existing test failures in tests/hooks/integration.test.ts (Security Policy Enforcement) are present on main too (reproduced by git-stashing this PR and re-running), so they are not caused by this change. They appear related to the PreToolUse relaxation commits ( |