docs+installer: how to register mempalace with opencode MCP, probe for it
Two missing pieces bundled here:
1. The README described the MCP server wrapper (mempalace-mcp-server,
a 3-line shell script that exec's the venv's python) as the
canonical answer on a uv-tool install. That is over-engineered and
out of step with the live reference box: opencode.json there uses
['mempalace-mcp'] directly, which is the shim uv tool install
already creates. Rewrote the section to put the simple canonical
answer first and demote the wrapper to a legacy-fallback sidebar.
New 'Registering mempalace with opencode' section covers:
- The one-entry JSON stanza to paste into the mcp object.
- A full minimal opencode.json for someone starting fresh (with
the 'instructions' array pointing at the wake-up protocol).
- Custom palace path variant.
- Claude Code one-liner (claude mcp add mempalace -- mempalace-mcp).
- Pointer at 'mempalace mcp' subcommand which prints the currently-
recommended snippets — useful when upstream updates conventions.
- Troubleshooting table (tools absent / server unavailable /
ModuleNotFoundError) with per-symptom fixes.
The legacy-fallback subsection explains what the wrapper script
was for (the pip-install → uv-tool-install transition era), shows
its 3-line implementation for completeness, and is explicit about
not using it for new installs.
Verification checklist updated: now runs 'which mempalace-mcp' and
'mempalace-mcp --help' against the shim, not the wrapper.
2. install.sh gains a matching probe: after the existing wake-up
protocol check, it grep-checks ~/.config/opencode/opencode.json
for 'mempalace' + 'mempalace-mcp' substrings. Present → clean
success line. Missing → actionable warning that prints the exact
JSON stanza to add plus a pointer to the README anchor and the
'mempalace mcp' CLI helper. Skipped when opencode.json doesn't
exist (non-opencode hosts).
Textual grep rather than strict JSON parse: we don't want to
hard-depend on python/jq at install time, and the two substrings
together are specific enough to avoid false positives.
Prerequisites list gets a 5th bullet flagging MCP registration as
required and pointing at the new section + the installer probe.
Smoke-tested both scenarios on the reference box — config with
mempalace entry present (all ticks green), config with entry removed
(actionable warning, correct snippet shown), config restored to
original state.
This commit is contained in:
+35
@@ -186,6 +186,39 @@ check_wake_up_protocol() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# ── Verify mempalace is registered as an MCP server in opencode.json ──
|
||||
# Even with mempalace installed and the wake-up protocol in place, opencode
|
||||
# won't actually launch the MCP server (so mempalace_* tools won't appear in
|
||||
# the agent's toolset) unless ~/.config/opencode/opencode.json declares a
|
||||
# server under .mcp.mempalace with command ["mempalace-mcp"] (or the legacy
|
||||
# wrapper equivalent).
|
||||
#
|
||||
# This is a lightweight textual check — we don't parse JSON strictly, just
|
||||
# look for the expected substring. False negatives are acceptable (a weirdly
|
||||
# formatted but valid config), false positives less so but very unlikely
|
||||
# given the specific shim name. Skipped on non-opencode hosts.
|
||||
check_opencode_mcp() {
|
||||
local opencode_config="$HOME/.config/opencode/opencode.json"
|
||||
[[ -f "$opencode_config" ]] || return 0 # no config → nothing to check
|
||||
|
||||
if grep -q '"mempalace"[[:space:]]*:' "$opencode_config" 2>/dev/null \
|
||||
&& grep -q 'mempalace-mcp' "$opencode_config" 2>/dev/null; then
|
||||
ok "mempalace MCP server registered in opencode.json"
|
||||
return 0
|
||||
fi
|
||||
|
||||
warn "mempalace MCP server NOT registered in $opencode_config"
|
||||
printf ' Without this, opencode loads the skill but no mempalace_* tools\n'
|
||||
printf ' are reachable at runtime, so search/diary/KG calls silently fail.\n'
|
||||
printf ' Add this entry under the top-level "mcp" object:\n'
|
||||
printf ' "mempalace": { "type": "local", "command": ["mempalace-mcp"] }\n'
|
||||
printf ' Or open a fresh config with:\n'
|
||||
printf ' mempalace mcp # prints current recommended snippets\n'
|
||||
printf ' Full details (including Claude Code one-liner) in:\n'
|
||||
printf ' README.md#registering-mempalace-with-opencode-or-other-mcp-clients\n'
|
||||
return 0
|
||||
}
|
||||
|
||||
do_install() {
|
||||
echo
|
||||
echo "mempalace-toolkit installer"
|
||||
@@ -205,6 +238,8 @@ do_install() {
|
||||
echo
|
||||
check_wake_up_protocol
|
||||
echo
|
||||
check_opencode_mcp
|
||||
echo
|
||||
ok "Done."
|
||||
echo
|
||||
echo "Next: ./bin/mempalace-session --dry-run"
|
||||
|
||||
Reference in New Issue
Block a user