Skip to content

wizard: _detect_project_install doesn't verify memtomem is in project dependencies #436

@memtomem

Description

@memtomem

Summary

mm init classifies any cwd with a pyproject.toml (and no packages/ dir) as a project install and writes an .mcp.json assuming memtomem is already a dependency of that project — but the wizard never checks pyproject.toml to verify that, nor does it run uv add memtomem itself. Result: on an empty uv init-style project, the wizard happily writes a workspace-style .mcp.json that only works because the user also has a global uv tool install memtomem providing the memtomem-server bin on PATH (PATH fallback from uv run).

Repro

mkdir -p /tmp/mmtest && cd /tmp/mmtest
uv init                     # creates pyproject.toml with dependencies = []
mm init                     # walk through wizard, pick any MCP option
cat .mcp.json               # workspace form: "uv run --directory ... memtomem-server"
grep memtomem pyproject.toml # nothing — dep was never added

Connecting this from Claude Code works only if uv tool install memtomem is also present globally — otherwise uv run --directory <empty project> memtomem-server fails with "command not found".

Observed

.mcp.json written by the wizard:

{"mcpServers":{"memtomem":{"command":"uv","args":["run","--directory","/tmp/mmtest","memtomem-server"]}}}

Project state:

[project]
dependencies = []

Where

packages/memtomem/src/memtomem/cli/init_cmd.py:93-107_detect_project_install() walks up looking for a pyproject.toml without a sibling packages/ dir, but the dependency check is structural only:

if (check / "pyproject.toml").exists() and not (check / "packages").exists():
    return check

The docstring (line 95) says this is meant to detect "uv add memtomem in someone else's project", but that assumption is never validated by parsing the pyproject. Downstream (init_cmd.py:1953-1955) then writes the workspace form unconditionally.

Suggested fix (hypothesis — needs confirmation)

Two axes the wizard could pick between:

  1. Tighten the detector: _detect_project_install should also parse pyproject.toml and confirm memtomem is in [project].dependencies (or [tool.uv.sources]). If not, fall through to the "pypi" / tool branch which writes "command": "memtomem-server" — no uv run indirection.
  2. Offer to add the dep: keep the current detector but, when classified as project, run uv add memtomem (or prompt first). This keeps the workspace form honest.

Option 1 is lower-risk (no new side effect in the wizard). Related invariant: feedback_install_context_axes.md — CWD-filesystem and runtime-interpreter axes need to reconcile, not be inferred independently.

Out of scope

  • The legacy .server.pid flock leak observed alongside this (a second server kept the lock after Claude Code's handshake failed) — filing separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions