Repository navigation
Description
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:
- 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) - 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
src/basic_memory/mcp/tools/project_management.py:470—_resolve_workspace_routing()only resolves the selector whenis_factory_mode()(cloud-hosted MCP) or explicit--cloudrouting with credentials. Otherwise it passes the raw selector through.src/basic_memory/mcp/async_client.py:361—get_client(workspace=...)only honorsworkspaceon the factory path, the explicit--cloudpath, or the per-project CLOUD-mode path. On the default fallback the parameter is silently discarded and a local ASGI client is returned.- The inline comment at
project_management.py:557-560says "cloud factory routes the create request" — the workspace feature (added in feat(mcp): create projects by workspace slug #789 for create_memory_project MCP tool cannot target a non-default workspace #781/create_memory_project has no way to target a non-default workspace #788) assumed factory mode and never covered local stdio servers with OAuth.
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
- create_memory_project MCP tool cannot target a non-default workspace #781 / create_memory_project has no way to target a non-default workspace #788 → fixed by feat(mcp): create projects by workspace slug #789 (
feat(mcp): create projects by workspace slug) — but only for factory-mode (hosted) servers - delete_project missing workspace parameter for cross-workspace targeting #800 / fix(mcp): add workspace routing to delete_project #803 — same gap pattern for
delete_projectworkspace targeting (worth re-checking the same scenario there)
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
claude commentedon Jun 11, 2026
Claude finished @phernandez's task in 1m 36s —— View job
Issue Triage
Classification
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:
The common OAuth-only stdio setup (
is_factory_mode()=False, no--cloudflag) falls into theelsebranch which returns the raw workspace selector unchanged — neither resolved nor rejected.Gap 2 —
get_client()(async_client.py:361)The
workspaceparameter is honored on the factory path (line 374) and explicit--cloudpath (lines 392-401), but the default fallback at lines 431-434 unconditionally returns a local ASGI client, silently discarding the workspace entirely:The two gaps combine to produce the two failure modes described:
/manual): local ASGI tries to mkdir the cloud path →Read-only file systemerrorlist_workspacesandlist_memory_projectscorrectly show the cloud workspace viaget_cloud_control_plane_client()/get_cloud_proxy_client()(which bypassget_client()entirely)Duplicate Check
No duplicate of this specific scenario. Related history confirmed:
feat(mcp): create projects by workspace slug) but only for factory-mode serversdelete_project; worth re-validating in the same OAuth stdio scenarioFix 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
workspaceis non-None and OAuth credentials exist, route the create request through the cloud proxy client — consistent with howlist_workspacesandlist_memory_projectsalready 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 eitherget_client()(to handle OAuth routing when workspace is provided) or via an alternative code path that explicitly usesget_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 againstdelete_project(#800).Regression tests should cover the local stdio + OAuth + workspace selector combination.
test(mcp): pin the new workspace-selector contract in integration tests
test(mcp): port project management tests to bm_project (#1961)