From 9f5b8f5fd691c91b504d290d45273bbe532eaf7e Mon Sep 17 00:00:00 2001 From: Pim Messelink <274674234+messelink@users.noreply.github.com> Date: Thu, 9 Apr 2026 06:39:44 +0000 Subject: [PATCH 1/5] fix: add mempalace-mcp console entry point for pipx/uv compatibility The MCP server config used `python -m mempalace.mcp_server` which fails when mempalace is installed via pipx or uv, since the system python cannot find the module in the isolated venv. Adding a `mempalace-mcp` console_scripts entry point ensures the MCP server works regardless of installation method (pip, pipx, uv, conda). Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude-plugin/.mcp.json | 6 +----- .claude-plugin/plugin.json | 6 +----- .codex-plugin/plugin.json | 6 +----- examples/mcp_setup.md | 4 ++-- mempalace/instructions/init.md | 2 +- mempalace/mcp_server.py | 2 +- pyproject.toml | 1 + 7 files changed, 8 insertions(+), 19 deletions(-) diff --git a/.claude-plugin/.mcp.json b/.claude-plugin/.mcp.json index b1e81ed81..dd7d55d74 100644 --- a/.claude-plugin/.mcp.json +++ b/.claude-plugin/.mcp.json @@ -1,9 +1,5 @@ { "mempalace": { - "command": "python3", - "args": [ - "-m", - "mempalace.mcp_server" - ] + "command": "mempalace-mcp" } } diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index ba5759afc..150431458 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -9,11 +9,7 @@ "commands": [], "mcpServers": { "mempalace": { - "command": "python3", - "args": [ - "-m", - "mempalace.mcp_server" - ] + "command": "mempalace-mcp" } }, "keywords": [ diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index 9017d9b14..7a2278ad0 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -21,11 +21,7 @@ "hooks": "./hooks.json", "mcpServers": { "mempalace": { - "command": "python3", - "args": [ - "-m", - "mempalace.mcp_server" - ] + "command": "mempalace-mcp" } }, "interface": { diff --git a/examples/mcp_setup.md b/examples/mcp_setup.md index 9bc26dd61..2b7e1c3bf 100644 --- a/examples/mcp_setup.md +++ b/examples/mcp_setup.md @@ -5,13 +5,13 @@ Run the MCP server: ```bash -python -m mempalace.mcp_server +mempalace-mcp ``` Or add it to Claude Code: ```bash -claude mcp add mempalace -- python -m mempalace.mcp_server +claude mcp add mempalace -- mempalace-mcp ``` ## Available Tools diff --git a/mempalace/instructions/init.md b/mempalace/instructions/init.md index 40f0c20dd..570a52541 100644 --- a/mempalace/instructions/init.md +++ b/mempalace/instructions/init.md @@ -49,7 +49,7 @@ If this fails, report the error and stop. Run the following command to register the MemPalace MCP server with Claude: - claude mcp add mempalace -- python -m mempalace.mcp_server + claude mcp add mempalace -- mempalace-mcp If this fails, report the error but continue to the next step (MCP configuration can be done manually later). diff --git a/mempalace/mcp_server.py b/mempalace/mcp_server.py index 06355c46e..6fe8225e1 100644 --- a/mempalace/mcp_server.py +++ b/mempalace/mcp_server.py @@ -2,7 +2,7 @@ """ MemPalace MCP Server — read/write palace access for Claude Code ================================================================ -Install: claude mcp add mempalace -- python -m mempalace.mcp_server [--palace /path/to/palace] +Install: claude mcp add mempalace -- mempalace-mcp [--palace /path/to/palace] Tools (read): mempalace_status — total drawers, wing/room breakdown diff --git a/pyproject.toml b/pyproject.toml index 1f60a2d7e..1935c321f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ Repository = "https://github.com/MemPalace/mempalace" [project.scripts] mempalace = "mempalace.cli:main" +mempalace-mcp = "mempalace.mcp_server:main" [project.entry-points."mempalace.backends"] chroma = "mempalace.backends.chroma:ChromaBackend" From be89e49add5e163f5897956d0ed619dec76271b4 Mon Sep 17 00:00:00 2001 From: Pim Messelink <274674234+messelink@users.noreply.github.com> Date: Thu, 9 Apr 2026 06:54:55 +0000 Subject: [PATCH 2/5] fix: use mempalace CLI in hook scripts instead of python3 -m Hook scripts used `python3 -m mempalace` which fails when mempalace is installed via pipx or uv. Using the `mempalace` CLI command directly works for all installation methods. Dev users running from source should use `pip install -e .` as documented in CONTRIBUTING.md. Co-Authored-By: Claude Opus 4.6 (1M context) --- .codex-plugin/hooks/mempal-hook.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codex-plugin/hooks/mempal-hook.sh b/.codex-plugin/hooks/mempal-hook.sh index 1cc005014..6d1113a41 100644 --- a/.codex-plugin/hooks/mempal-hook.sh +++ b/.codex-plugin/hooks/mempal-hook.sh @@ -3,7 +3,7 @@ set -euo pipefail HOOK_NAME="${1:?Usage: mempal-hook.sh }" INPUT_FILE=$(mktemp) || { echo "Failed to create temp file" >&2; exit 1; } cat > "$INPUT_FILE" -cat "$INPUT_FILE" | python3 -m mempalace hook run --hook "$HOOK_NAME" --harness codex +cat "$INPUT_FILE" | mempalace hook run --hook "$HOOK_NAME" --harness codex EXIT_CODE=$? rm -f "$INPUT_FILE" 2>/dev/null exit $EXIT_CODE From 67a067701ef25a3b62a722d3c45e2e60f3dd5c20 Mon Sep 17 00:00:00 2001 From: Pim Messelink <274674234+messelink@users.noreply.github.com> Date: Thu, 16 Apr 2026 04:50:39 +0000 Subject: [PATCH 3/5] fix: use mempalace CLI in top-level hook scripts hooks/mempal_precompact_hook.sh and hooks/mempal_save_hook.sh used python3 -m mempalace mine which fails when mempalace is installed via pipx or uv. Switch to the mempalace CLI entry point which pipx/uv put on PATH. Also removes the now-unused PYTHON variable from mempal_save_hook.sh. Co-Authored-By: Claude Opus 4.6 (1M context) --- hooks/mempal_precompact_hook.sh | 2 +- hooks/mempal_save_hook.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hooks/mempal_precompact_hook.sh b/hooks/mempal_precompact_hook.sh index 3a74ca54e..25d918c42 100755 --- a/hooks/mempal_precompact_hook.sh +++ b/hooks/mempal_precompact_hook.sh @@ -65,7 +65,7 @@ echo "[$(date '+%H:%M:%S')] PRE-COMPACT triggered for session $SESSION_ID" >> "$ if [ -n "$MEMPAL_DIR" ] && [ -d "$MEMPAL_DIR" ]; then SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_DIR="$(dirname "$SCRIPT_DIR")" - python3 -m mempalace mine "$MEMPAL_DIR" >> "$STATE_DIR/hook.log" 2>&1 + mempalace mine "$MEMPAL_DIR" >> "$STATE_DIR/hook.log" 2>&1 fi # Silent: return empty JSON to not block. "decision": "allow" is invalid — diff --git a/hooks/mempal_save_hook.sh b/hooks/mempal_save_hook.sh index d8e7cc248..c2ea745e0 100755 --- a/hooks/mempal_save_hook.sh +++ b/hooks/mempal_save_hook.sh @@ -144,7 +144,6 @@ if [ "$SINCE_LAST" -ge "$SAVE_INTERVAL" ] && [ "$EXCHANGE_COUNT" -gt 0 ]; then # 1. TRANSCRIPT_PATH (from Claude Code) — mine the directory it lives in # 2. MEMPAL_DIR (user-configured) — mine that directory # At least one should work. If neither is set, nothing mines. - PYTHON="$(command -v python3)" MINE_DIR="" if [ -n "$TRANSCRIPT_PATH" ] && [ -f "$TRANSCRIPT_PATH" ]; then MINE_DIR="$(dirname "$TRANSCRIPT_PATH")" @@ -153,7 +152,7 @@ if [ "$SINCE_LAST" -ge "$SAVE_INTERVAL" ] && [ "$EXCHANGE_COUNT" -gt 0 ]; then MINE_DIR="$MEMPAL_DIR" fi if [ -n "$MINE_DIR" ]; then - "$PYTHON" -m mempalace mine "$MINE_DIR" >> "$STATE_DIR/hook.log" 2>&1 & + mempalace mine "$MINE_DIR" >> "$STATE_DIR/hook.log" 2>&1 & fi # MEMPAL_VERBOSE toggle: From 982d42151007bc3ca51818e569285e5bdcd5f1a1 Mon Sep 17 00:00:00 2001 From: Pim Messelink <274674234+messelink@users.noreply.github.com> Date: Thu, 16 Apr 2026 12:40:46 +0000 Subject: [PATCH 4/5] fix: update mempalace mcp command to use mempalace-mcp entry point cmd_mcp() in cli.py was still printing `python -m mempalace.mcp_server` as the setup command. Update to use the mempalace-mcp console entry point added in the previous commit. Co-Authored-By: Claude Opus 4.6 (1M context) --- mempalace/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mempalace/cli.py b/mempalace/cli.py index a5d3c7dda..621b295fd 100644 --- a/mempalace/cli.py +++ b/mempalace/cli.py @@ -367,7 +367,7 @@ def cmd_instructions(args): def cmd_mcp(args): """Show how to wire MemPalace into MCP-capable hosts.""" - base_server_cmd = "python -m mempalace.mcp_server" + base_server_cmd = "mempalace-mcp" if args.palace: resolved_palace = str(Path(args.palace).expanduser()) From 9e53228ea3b3e9e5fcced7661e594a7fc81bc856 Mon Sep 17 00:00:00 2001 From: Pim Messelink <274674234+messelink@users.noreply.github.com> Date: Thu, 16 Apr 2026 15:31:21 +0000 Subject: [PATCH 5/5] test: update test_cli assertions for mempalace-mcp entry point Three assertions in test_mcp_command_* were still checking for the old `python -m mempalace.mcp_server` output string. Update to match the new `mempalace-mcp` command printed by cmd_mcp(). Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/test_cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index c4b420307..1c4dfbda3 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -334,9 +334,9 @@ def test_mcp_command_prints_setup_guidance(monkeypatch, capsys): captured = capsys.readouterr() assert "MemPalace MCP quick setup:" in captured.out - assert "claude mcp add mempalace -- python -m mempalace.mcp_server" in captured.out + assert "claude mcp add mempalace -- mempalace-mcp" in captured.out assert "\nOptional custom palace:\n" in captured.out - assert "python -m mempalace.mcp_server --palace /path/to/palace" in captured.out + assert "mempalace-mcp --palace /path/to/palace" in captured.out assert "[--palace /path/to/palace]" not in captured.out assert captured.err == "" @@ -349,7 +349,7 @@ def test_mcp_command_uses_custom_palace_path_when_provided(monkeypatch, capsys): captured = capsys.readouterr() expanded = str(Path("~/tmp/my palace").expanduser()) - assert "python -m mempalace.mcp_server --palace" in captured.out + assert "mempalace-mcp --palace" in captured.out assert expanded in captured.out assert "Optional custom palace:" not in captured.out assert "[--palace /path/to/palace]" not in captured.out