Skip to content

fix: add mempalace-mcp entry point for pipx/uv compatibility#340

Open
messelink wants to merge 6 commits intoMemPalace:developfrom
messelink:fix/mcp-pipx-compat
Open

fix: add mempalace-mcp entry point for pipx/uv compatibility#340
messelink wants to merge 6 commits intoMemPalace:developfrom
messelink:fix/mcp-pipx-compat

Conversation

@messelink
Copy link
Copy Markdown

@messelink messelink commented Apr 9, 2026

Summary

Two related fixes for installation-method compatibility:

  1. Adds a mempalace-mcp console_scripts entry point in pyproject.toml so 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 use mempalace-mcp instead of python3 -m mempalace.mcp_server. Updates docs (README, examples, instructions) to reflect the new command.
  2. Updates hook scripts to use the mempalace CLI (hooks/mempal-precompact-hook.sh, hooks/mempal-stop-hook.sh, .codex-plugin/hooks/mempal-hook.sh) instead of python3 -m mempalace hook run .... Same root cause, same class of fix.

Problem

When mempalace is installed via pipx or uv, both python -m mempalace.mcp_server (MCP server config) and python3 -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) with No module named mempalace.

Solution

Console scripts installed by setuptools/hatchling go on PATH for pip, pipx, and uv alike — just like the existing mempalace CLI entry point. A new mempalace-mcp entry point exposes the MCP server the same way. Hook scripts switch to calling the mempalace CLI directly (which pipx/uv put on PATH) instead of python3 -m mempalace.

Test plan

  • pip install -e . and verify mempalace-mcp starts the MCP server
  • pipx install . and verify mempalace-mcp is on PATH and works
  • pipx install . and verify stop/precompact hooks run without No module named mempalace errors
  • claude mcp add mempalace -- mempalace-mcp connects successfully

Notes on rebase

This branch has been rebased onto current develop (v3.3.0+). The [project.scripts] section conflicted because develop refactored mempalace = "mempalace:main"mempalace = "mempalace.cli:main". Resolution combines both: the new cli entry point path is preserved, and mempalace-mcp is added alongside it.

⚠️ Known limitation: restart MCP servers after upgrading

This fix makes the MCP server runnable via pipx/uv, which surfaces a latent Python process-lifecycle issue. Long-running MCP server processes cache mempalace and chromadb in sys.modules at 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 mempalace or any of its dependencies (especially chromadb, 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:

  • Claude Code: disable and re-enable the mempalace plugin's MCP in settings (the /mcp command 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.
  • Alternative: restart Claude Code entirely (exit and relaunch). The bulletproof method, also handles plugin reload edge cases.

Without restarting, stale MCP servers can write rows with legacy storage formats (e.g., seq_id as 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 affect pip install -U mempalace users without pipx/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

@nzkdevsaider
Copy link
Copy Markdown

Hi! I’ve been working on expanding the README.md to include installation steps for MCP in this PR. Please take a look!

@messelink messelink force-pushed the fix/mcp-pipx-compat branch from 9e40b1f to 15a6af2 Compare April 9, 2026 15:16
Copy link
Copy Markdown

@web3guru888 web3guru888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@messelink messelink force-pushed the fix/mcp-pipx-compat branch 3 times, most recently from 2c4022c to 8ecd0a2 Compare April 10, 2026 16:06
@messelink messelink force-pushed the fix/mcp-pipx-compat branch from 8ecd0a2 to 95f514d Compare April 11, 2026 16:39
@bensig bensig changed the base branch from main to develop April 11, 2026 22:22
@bensig bensig requested a review from igorls as a code owner April 11, 2026 22:22
@igorls igorls added area/hooks Claude Code hook scripts (Stop, PreCompact, SessionStart) area/install pip/uv/pipx/plugin install and packaging area/mcp MCP server and tools bug Something isn't working labels Apr 14, 2026
messelink and others added 2 commits April 14, 2026 15:13
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>
messelink and others added 2 commits April 15, 2026 07:05
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>
messelink and others added 2 commits April 16, 2026 12:40
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/hooks Claude Code hook scripts (Stop, PreCompact, SessionStart) area/install pip/uv/pipx/plugin install and packaging area/mcp MCP server and tools bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants