fix: add mempalace-mcp entry point for pipx/uv compatibility#340
fix: add mempalace-mcp entry point for pipx/uv compatibility#340messelink wants to merge 6 commits intoMemPalace:developfrom
Conversation
|
Hi! I’ve been working on expanding the README.md to include installation steps for MCP in this PR. Please take a look! |
9e40b1f to
15a6af2
Compare
web3guru888
left a comment
There was a problem hiding this comment.
Clean and well-scoped fix. The python3 -m mempalace.mcp_server pattern is exactly the kind of thing that breaks in isolated venvs (pipx, uv) — we hit this ourselves when deploying across different environments.
The change is straightforward: one new console_scripts entry point + consistent updates across all plugin configs and docs. LGTM.
One thing to flag: #410 (armujahid) does mempalace mcp-serve as a subcommand instead of a separate mempalace-mcp entry point. Both solve the same problem but with different UX. The separate entry point approach here is simpler and follows the pattern other MCP servers use, while the subcommand approach avoids adding another binary to PATH. Maintainers will want to pick one and close the other.
From an integration standpoint, the separate entry point is slightly preferable — it means MCP configs don't need to know about argument parsing, just a single command name.
🔭 Reviewed as part of the MemPalace-AGI integration project — autonomous research with perfect memory. Community interaction updates are posted regularly on the dashboard.
2c4022c to
8ecd0a2
Compare
8ecd0a2 to
95f514d
Compare
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) <noreply@anthropic.com>
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) <noreply@anthropic.com>
95f514d to
b394221
Compare
The upstream develop branch rewrote the README (176 → 741 lines) with honest benchmark notes, corrected AAAK claims, and delegated MCP setup to the docs site. Our previous README patch (python -m → mempalace-mcp) no longer applies — that context was removed. The actual fix lives in pyproject.toml and plugin.json entries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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) <noreply@anthropic.com>
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) <noreply@anthropic.com>
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) <noreply@anthropic.com>
Summary
Two related fixes for installation-method compatibility:
mempalace-mcpconsole_scripts entry point inpyproject.tomlso the MCP server works with all installation methods (pip, pipx, uv, conda). Updates plugin configs (.claude-plugin/.mcp.json,.claude-plugin/plugin.json,.codex-plugin/plugin.json) to usemempalace-mcpinstead ofpython3 -m mempalace.mcp_server. Updates docs (README, examples, instructions) to reflect the new command.mempalaceCLI (hooks/mempal-precompact-hook.sh,hooks/mempal-stop-hook.sh,.codex-plugin/hooks/mempal-hook.sh) instead ofpython3 -m mempalace hook run .... Same root cause, same class of fix.Problem
When mempalace is installed via
pipxoruv, bothpython -m mempalace.mcp_server(MCP server config) andpython3 -m mempalace hook run ...(hook scripts) fail because the system Python can't find the module inside the isolated venv. The MCP plugin fails to connect, and stop/precompact hooks fail silently (or loudly) withNo module named mempalace.Solution
Console scripts installed by setuptools/hatchling go on PATH for pip, pipx, and uv alike — just like the existing
mempalaceCLI entry point. A newmempalace-mcpentry point exposes the MCP server the same way. Hook scripts switch to calling themempalaceCLI directly (which pipx/uv put on PATH) instead ofpython3 -m mempalace.Test plan
pip install -e .and verifymempalace-mcpstarts the MCP serverpipx install .and verifymempalace-mcpis on PATH and workspipx install .and verify stop/precompact hooks run withoutNo module named mempalaceerrorsclaude mcp add mempalace -- mempalace-mcpconnects successfullyNotes on rebase
This branch has been rebased onto current
develop(v3.3.0+). The[project.scripts]section conflicted becausedeveloprefactoredmempalace = "mempalace:main"→mempalace = "mempalace.cli:main". Resolution combines both: the new cli entry point path is preserved, andmempalace-mcpis added alongside it.This fix makes the MCP server runnable via
pipx/uv, which surfaces a latent Python process-lifecycle issue. Long-running MCP server processes cachemempalaceandchromadbinsys.modulesat startup and never reload them. After any subsequent upgrade —pipx install --force -e .,pip install -U mempalace,uv pip install -U, etc. — already-running MCP server processes continue serving tool calls with the stale libraries, even though the CLI (fresh Python each invocation) picks up the new version immediately.In practice this means: after upgrading
mempalaceor any of its dependencies (especiallychromadb, which has had breaking format changes between 0.6.x and 1.5.x), you must restart any active Claude Code MCP servers to pick up the new code. Ways to do this:/mcpcommand or the Settings → MCP UI). This closes the stdio pipe, the Python process exits, and Claude Code respawns a fresh one on the next tool call.Without restarting, stale MCP servers can write rows with legacy storage formats (e.g.,
seq_idas BLOB under chromadb 0.6.x) that cause fresh processes to crash during compaction on read. Not caused by this PR — the same bug would affectpip install -U mempalaceusers withoutpipx/uv— but this PR makes more users able to actually run the MCP server, so the bug is more visible in practice.Tracked as: #899 (MCP server silently serves with stale library versions after package upgrade). The long-term fix is a version check at tool-call time or an automatic self-restart mechanism; this PR only documents the manual workaround until a code fix lands.
🤖 Generated with Claude Code