Skip to content

Hooks and MCP server break in projects with Python venv (hardcoded python3) #1049

@sergesha

Description

@sergesha

Problem

All hook scripts in .claude-plugin/hooks/ and the MCP server definition in plugin.json call bare python3:

Hooks (mempal-stop-hook.sh, mempal-precompact-hook.sh):

echo "$INPUT" | python3 -m mempalace hook run --hook stop --harness claude-code

MCP server (plugin.json):

"mcpServers": {
  "mempalace": {
    "command": "python3",
    "args": ["-m", "mempalace.mcp_server"]
  }
}

In projects with an active Python .venv, python3 resolves to .venv/bin/python3, which doesn't have mempalace installed. This causes the stop hook to fail on every session exit:

.venv/bin/python3: No module named mempalace

The MCP server also fails to start for the same reason.

Environment

  • mempalace 3.3.1 (pip) / 3.3.0 (plugin)
  • Python installed via mise, mempalace installed in mise python
  • Project has its own .venv which shadows python3 in PATH

Proposed fix

Support a MEMPALACE_PYTHON environment variable with fallback to python3:

Hooks:

MEMPALACE_PYTHON="${MEMPALACE_PYTHON:-python3}"
echo "$INPUT" | "$MEMPALACE_PYTHON" -m mempalace hook run --hook stop --harness claude-code

plugin.json: Harder to fix since JSON is static. Options:

  1. A wrapper script (mempalace-run) that reads MEMPALACE_PYTHON
  2. Document that users with venvs need to set MEMPALACE_PYTHON in Claude Code settings.jsonenv

This lets users set MEMPALACE_PYTHON in Claude Code's settings.jsonenv to point to the python where mempalace is installed, without affecting other hooks or tools.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/hooksClaude Code hook scripts (Stop, PreCompact, SessionStart)area/mcpMCP server and toolsbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions