From 85fdeaf2804fe9d3c8b0bac4aefcaca002d4387c Mon Sep 17 00:00:00 2001 From: ziadarafat Date: Wed, 25 Nov 2026 19:04:09 -0700 Subject: [PATCH] mcp: make the lapis server start on hosts without a local LaPis store The free-pi lapis entry pointed at /home/ziadarafat/.pi/agent/.../memory-store.js, an arceus path. On the Deck that file does not exist, so the server never started and no lapis tools were offered for the whole session - memory had to be reached by shelling out to arceus by hand. bin/mcp-lapis is now a single wrapper that picks a strategy per host: run the local store when the checkout is present (arceus), otherwise bridge stdio over ssh to the host that has it (the Deck). The free-pi entry runs it through sh so $HOME resolves on either machine. Verified with an MCP handshake: lapis 1.4.0, tools/list returns memory-save and friends. --- bin/mcp-lapis | 34 +++++++++++++++++++++++++++++++--- config/free-pi/mcp.json | 11 ++++++----- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/bin/mcp-lapis b/bin/mcp-lapis index 22cbf53..dd71946 100755 --- a/bin/mcp-lapis +++ b/bin/mcp-lapis @@ -1,6 +1,34 @@ #!/bin/sh -# LaPis memory MCP server (stdio) for Cursor and Antigravity. +# LaPis memory MCP server (stdio). +# +# LaPis keeps one SQLite store, on arceus (~/.pi/memory/memory.db). Hosts that +# have the checkout run it directly; hosts that do not (the Deck) bridge stdio +# over ssh to the host that does. One wrapper, so every agent config can point +# at the same path regardless of machine. set -eu + LAPIS="${LAPIS_DIR:-$HOME/.pi/agent/git/github.com/GeneGulanesJr/LaPis}" -cd "$LAPIS" -exec node "$LAPIS/cli.js" mcp + +node_bin() { + if command -v node >/dev/null 2>&1; then + command -v node + return + fi + for candidate in "$HOME"/.local/share/mise/installs/node/*/bin/node; do + [ -x "$candidate" ] && { printf %s "$candidate"; return; } + done + return 1 +} + +if [ -f "$LAPIS/memory-store.js" ]; then + NODE=$(node_bin) || { echo "mcp-lapis: no node found for the local LaPis store" >&2; exit 1; } + exec "$NODE" "$LAPIS/memory-store.js" mcp +fi + +# No local store: bridge to the host that has one. LAPIS_REMOTE defaults to the +# personal homelab host; keep it a plain "user@host" so ProxyJump/ssh config apply. +REMOTE="${LAPIS_REMOTE:-ziadarafat@10.0.0.23}" +REMOTE_LAPIS="${LAPIS_REMOTE_DIR:-/home/ziadarafat/.pi/agent/git/github.com/GeneGulanesJr/LaPis}" + +exec ssh -T -o BatchMode=yes -o ServerAliveInterval=30 "$REMOTE" \ + "/home/ziadarafat/.local/share/mise/installs/node/24.22.3/bin/node $REMOTE_LAPIS/memory-store.js mcp" diff --git a/config/free-pi/mcp.json b/config/free-pi/mcp.json index 28bfb3c..6351028 100644 --- a/config/free-pi/mcp.json +++ b/config/free-pi/mcp.json @@ -12,12 +12,13 @@ } }, "lapis": { - "command": "node", + "command": "sh", "args": [ - "/home/ziadarafat/.pi/agent/git/github.com/GeneGulanesJr/LaPis/memory-store.js", - "mcp" + "-c", + "exec \"$HOME/.dotfiles/bin/mcp-lapis\"" ], - "description": "LaPis local persistent memory (SQLite ~/.pi/memory/memory.db): memory-save, memory-search, memory-get, memory-code and memory-doc for the current project." + "description": "LaPis persistent memory (SQLite ~/.pi/memory/memory.db): memory-save, memory-search, memory-get, memory-code and memory-doc for the current project.", + "exposure": "codemode" } } -} +} \ No newline at end of file