Skip to content

create_memory_project silently drops workspace selector on local MCP server (OAuth-only), creates project locally #954

Closed

Description

@phernandez

Summary

create_memory_project accepts a workspace selector and its docstring tells callers to discover workspaces via list_workspaces and pass a slug. But on a local stdio MCP server with OAuth-only credentials (the standard Claude Desktop / Claude Code setup: no global cloud mode, no cloud_api_key), the workspace selector is silently dropped and the create request is routed to the local ASGI API instead of the cloud workspace.

Two user-visible failure modes:

  1. Cloud-style path (e.g. /manual) → Failed to create directory /manual: [Errno 30] Read-only file system (local API tries to mkdir the cloud path on the user's machine)
  2. Writable path → silent wrong-destination write: a local project is created when the user explicitly asked for a project in a cloud team workspace

Mode 2 is the bad one: the same MCP session happily lists cloud workspaces and cloud projects (reads route via OAuth), so the model has every reason to believe the create landed in the team workspace.

Reproduction

Environment: local basic-memory mcp stdio server, cloud_api_key: null, valid OAuth token (bm cloud status → "Cloud connected"), no global cloud mode. v0.21.6 / main @ 650f88a.

list_workspaces()
# → returns team workspace slug "basic-memory-7020de4e..." (via OAuth control-plane client)

create_memory_project(
    project_name="manual",
    project_path="/manual",
    workspace="basic-memory-7020de4e925843c68c9056c60d101d9e",
)
# → Error: Failed to create directory /manual: [Errno 30] Read-only file system: '/manual'
# (local file_service.py tried to create the cloud path on the local machine)

Root cause

Meanwhile the read side (list_workspaces, list_memory_projects) bypasses get_client() entirely via get_cloud_control_plane_client() / get_cloud_proxy_client(), which resolve OAuth tokens — so discovery works, creating the inconsistent "you can see it but writes go elsewhere" behavior.

Expected

Either of:

  • workspace=<selector> implies cloud routing when cloud credentials exist (consistent with how reads work, and with the docstring contract), or
  • fail fast: "workspace selector requires cloud routing; run with --cloud / enable cloud mode" — never silently create a local project at a cloud path

Fail-fast at minimum; silent fallback violates the house style and the tool's own documentation.

Related history

Context

Found during live verification for #952 (Basic Memory manual pages) — first command exercised, first bug found. A fix with a regression test is in progress on a worktree branch.

Activity

  1. added
    bug
    cloud
    on Jun 11, 2026
  2. claude commented on Jun 11, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 1m 36s —— View job


    Issue Triage

    • Analyze issue and classify type/priority/component/complexity
    • Read relevant source files to understand root cause
    • Check for duplicate issues
    • Apply appropriate labels
    • Provide triage summary

    Classification

    Dimension Assessment
    Type Bug — code defect (silent wrong-destination write + misleading error)
    Priority High — silent data misrouting in the default OAuth stdio setup
    Component MCP tools + Cloud routing
    Complexity Complex — requires layered routing architecture changes + regression tests

    Note: Attempted to add high, complex, mcp labels but they don't exist in this repo. The existing bug + cloud labels are appropriate. A high-priority or similar label would be worth adding if available.


    Root Cause Confirmed

    After reading the source I can confirm both code paths described in the issue:

    Gap 1 — _resolve_workspace_routing() (project_management.py:470)

    The guard at line 480 only allows workspace slug resolution in two cases:

    should_resolve_workspace = is_factory_mode() or (
        explicit_cloud_routing and has_cloud_credentials(config)
    )

    The common OAuth-only stdio setup (is_factory_mode()=False, no --cloud flag) falls into the else branch which returns the raw workspace selector unchanged — neither resolved nor rejected.

    Gap 2 — get_client() (async_client.py:361)

    The workspace parameter is honored on the factory path (line 374) and explicit --cloud path (lines 392-401), but the default fallback at lines 431-434 unconditionally returns a local ASGI client, silently discarding the workspace entirely:

    # --- Default fallback ---
    async with _asgi_client(timeout) as client:
        yield client

    The two gaps combine to produce the two failure modes described:

    • Mode 1 (cloud path like /manual): local ASGI tries to mkdir the cloud path → Read-only file system error
    • Mode 2 (writable path): a local project is created silently at the wrong destination, while list_workspaces and list_memory_projects correctly show the cloud workspace via get_cloud_control_plane_client() / get_cloud_proxy_client() (which bypass get_client() entirely)

    Duplicate Check

    No duplicate of this specific scenario. Related history confirmed:


    Fix Approach

    The issue proposes two valid options; the house style ("fail fast") and the docstring contract both point toward Option A as the right fix:

    Option A (preferred): When workspace is non-None and OAuth credentials exist, route the create request through the cloud proxy client — consistent with how list_workspaces and list_memory_projects already work on the read side.

    Option B (minimum): Fail-fast with a clear error: "workspace selector requires cloud routing; re-run with --cloud or enable cloud mode" — never silently create a local project.

    Option A is preferable because it makes writes consistent with reads in the same MCP session, which is the behavior the model (and user) would expect.

    The fix requires changes in both _resolve_workspace_routing() and either get_client() (to handle OAuth routing when workspace is provided) or via an alternative code path that explicitly uses get_cloud_proxy_client() when workspace is non-None and OAuth credentials are available — analogous to how the read tools work. The same fix should be validated against delete_project (#800).

    Regression tests should cover the local stdio + OAuth + workspace selector combination.

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

    bugcloud

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions