fix(mcp): report cloud projects as source=cloud in factory mode#752
Conversation
In factory mode (cloud MCP server), list_memory_projects passed cloud-fetched projects as local_list to _merge_projects(), causing all projects to report source="local" with no cloud metadata. Fix passes projects as cloud_list and resolves workspace metadata via the workspace provider, so cloud MCP clients see correct source labels and workspace info. Fixes basicmachines-co/basic-memory-cloud#479 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Joe P <joe@basicmemory.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 16304569bc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if workspace: | ||
| matched = next((ws for ws in workspaces if ws.tenant_id == workspace), None) | ||
| if matched is None: |
There was a problem hiding this comment.
Honor workspace when fetching factory-mode project list
When workspace is provided in factory mode, this branch only uses it to pick metadata (matched) but the project fetch above still runs through get_client() without a workspace override, so the returned projects can come from the connection/default workspace while being labeled with a different workspace’s metadata. This mismatch is observable for users who can access multiple workspaces and can lead clients to act on the wrong project set; pass the same workspace into the factory client request (or avoid applying workspace metadata unless the fetch was scoped).
Useful? React with 👍 / 👎.
Pass the workspace param through to get_client() in factory mode so the fetched projects match the workspace metadata. Also fix pyright type errors in tests (missing isinstance assertion, missing organization_id param). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Joe P <joe@basicmemory.com>
Summary
list_memory_projectsreportingsource: "local"for all projects when called via cloud MCP servercloud_list(notlocal_list) to_merge_projects()workspace_name,workspace_type,workspace_tenant_id) is resolved via the existing workspace providerTest plan
test_list_memory_projects_factory_modeto assertsource: "cloud"test_list_memory_projects_factory_mode_json_includes_workspace— verifies JSON output has workspace fieldstest_list_memory_projects_factory_mode_workspace_lookup_failure— graceful degradation when workspace provider failstest_list_memory_projects_factory_mode_explicit_workspace— explicit workspace param selects correct workspace🤖 Generated with Claude Code