Skip to content

build_context resolves the first URL segment as a project even when project is passed #1814

Closed

Description

@phernandez

Found during live testing of main at 0276799.

build_context(project="basic-memory-testing-20261022-1842", url="memory://graph/node-a") logs, on every call:

Client error: POST /v2/projects/resolve: Project not found: 'graph'

The explicit project is given, yet the first URL segment is still tried as a project name. This costs an extra round trip per call and puts a misleading client error in the log. When project/project_id is passed, the URL should be read as project-relative without a project lookup.

Activity

  1. added
    bug
    on Oct 23, 2026
  2. claude commented on Oct 23, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 21s —— View job


    Triage

    • Type: Bug
    • Component: MCP tools (build_context). It isn't Cloud-specific.
    • Priority: Medium. Results are correct, but every call makes a wasted POST /v2/projects/resolve and logs a misleading client error.
    • Complexity: Simple to medium.
    • Duplicates: I searched for existing issues and found none.

    Analysis

    In src/basic_memory/mcp/tools/build_context.py:380, build_context always calls resolve_project_and_path(client, url, active_project.name, context). That function (mcp/project_context.py:800) treats the leading segment of any memory:// URL as a possible project prefix. It does this even though get_project_client(project, project_id=...) has already pinned the project.

    The prefix auto-detection at lines 323-332 is correctly skipped when project or project_id is passed. The later resolve_project_and_path call isn't gated the same way. That is why memory://graph/node-a triggers a lookup for a project named graph.

    The likely fix is to skip project-prefix resolution when the caller passed project or project_id, and read the URL as project-relative. I haven't verified that this is safe. If permalinks_include_project is on, a caller's own project name may legitimately appear as the first segment, so that case needs to still be stripped. resolve_project_and_path is also shared with other tools, so the change should be scoped to build_context or made opt-in.

    A regression test could assert that no /v2/projects/resolve request is made when project is given with a non-project-looking first segment.

    This is triage only; no fix has been implemented.

  3. phernandez commented on Oct 23, 2026

    @phernandez
    MemberAuthor

    Folded into the 1.0 tool surface work: #1829 (tracking #1827). This issue stays open until that lands, with a regression test for the behavior described here.

  4. added this to the v1.0 milestone on Oct 29, 2026
  5. phernandez commented on Oct 29, 2026

    @phernandez
    MemberAuthor

    Fixed in the 1.0 tool surface (bd0eaaf): bm_context reads the URL as project-relative when project is passed, with no extra project lookup. Regression test in tests/mcp/test_tool_bm_context.py.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions