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/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 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/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: 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()) 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" 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