Skip to content

MCP project listing attaches local state to same-name Team workspace projects #848

Closed

Description

@groksrc

Bug Description

list_memory_projects merges local project metadata into cloud projects by project permalink only. When two cloud workspaces contain projects with the same permalink, a local project with that permalink can be reported as attached to the wrong workspace project.

This is especially misleading for Team/organization workspaces, where local rclone bisync is not supported. A Team workspace project can appear as local+cloud and show a local path even though it should be cloud-only.

Steps to Reproduce

  1. Configure a local project named main.
  2. Authenticate with cloud access to multiple workspaces.
  3. Ensure both a Personal workspace and a Team/organization workspace contain a cloud project whose permalink is main.
  4. Call the MCP project listing tool, e.g. list_memory_projects / Hermes bm_projects().
  5. Inspect the Team/organization workspace main project entry.

Expected Behavior

Local metadata should be attached only to the cloud workspace/project that actually owns the local config state.

For a same-name Team/organization workspace project, the MCP listing should report something equivalent to:

{
  "qualified_name": "<team-workspace-slug>/main",
  "source": "cloud",
  "local_path": null,
  "cloud_path": "/..."
}

Actual Behavior

The Team/organization workspace project can be reported as local+cloud and include the local path for the unrelated local project with the same permalink.

Likely Root Cause

src/basic_memory/mcp/tools/project_management.py::_merge_workspace_projects() indexes local projects by permalink:

local_by_permalink[project.permalink] = project

Then every cloud workspace project with that permalink gets merged with the local project:

local_proj = local_by_permalink.get(permalink)
source = "local+cloud" if local_proj else "cloud"
local_path = local_proj.path if local_proj else None

The CLI project listing has more careful "attached row" logic and does not show local/sync state on Team workspace rows. The MCP project listing should use the same ownership model.

Notes

No personal paths, tenant IDs, or project IDs are required to reproduce this; the key condition is duplicate project permalinks across workspaces plus a local project with the same permalink.

Activity

  1. added
    bug
    on May 24, 2026
  2. claude commented on May 24, 2026

    @claude
    Contributor

    Claude finished @groksrc's task in 5m 41s —— View job


    Triage & Fix

    Triage:

    • Type: Bug (code defect)
    • Priority: Medium — incorrect data shown in MCP project listing; affects users with multiple cloud workspaces containing same-name projects
    • Component: MCP tools, cloud functionality
    • Complexity: Medium

    Root cause confirmed: _merge_workspace_projects() in project_management.py:139 indexes local projects by permalink only, so every cloud workspace project sharing a permalink incorrectly receives the local metadata. The CLI (project.py:511) has a _select_attached_row_key() that selects exactly ONE row per permalink to own local state — the MCP tool now uses the same model.

    • Analyze issue and gather context
    • Read source files (project_management.py and CLI equivalent)
    • Triage: classify, prioritize, label
    • Implement fix: add _select_attached_cloud_entry() and update _merge_workspace_projects()
    • Add tests (8 new tests for duplicate-permalink cross-workspace scenario)
    • Run tests (just fast-check) — requires push to CI
    • Commit signed (DCO)
    • Push to remote — blocked: github-actions[bot] lacks push permission to this repo

    Changes Made

    src/basic_memory/mcp/tools/project_management.py

    Added _select_attached_cloud_entry() helper that mirrors the CLI ownership model:

    1. Per-project config.workspace_id (set via bm project set-cloud --workspace)
    2. Global config.default_workspace
    3. The workspace flagged is_default by the cloud (typically Personal)
    4. Personal workspace over team/organization
    5. Alphabetical tiebreak

    Updated _merge_workspace_projects() to group cloud entries by permalink, select the single "attached" entry per local project via the helper, and only merge local_path / source: "local+cloud" into that one entry. All other workspace rows with the same permalink remain source: "cloud" with local_path: null.

    Updated call site to pass config so workspace ownership can be resolved.

    tests/mcp/test_tool_project_management.py

    Added 8 unit tests covering: empty/single candidate handling, each ownership priority level, the primary regression scenario (team workspace stays cloud-only), and the config-workspace-wins scenario.

    Push Failure

    The push was blocked with Permission to basicmachines-co/basic-memory.git denied to github-actions[bot]. The commit is ready locally on branch claude/issue-848-20260524-1511 but cannot be pushed without write access. A maintainer can cherry-pick or push the commit manually.

  3. phernandez commented on May 24, 2026

    @phernandez
    Member

    I was thinking we may have to do something with permalinks like the web-v2 does:

    cloud | workspace | project | path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions