Skip to content

fix: skip workspace resolution when client factory is active#630

Merged
phernandez merged 1 commit intomainfrom
fix-factory-mode-workspace-resolution
Feb 27, 2026
Merged

fix: skip workspace resolution when client factory is active#630
phernandez merged 1 commit intomainfrom
fix-factory-mode-workspace-resolution

Conversation

@jope-bm
Copy link
Contributor

@jope-bm jope-bm commented Feb 27, 2026

Summary

  • When the cloud MCP server runs in-process with set_client_factory(), get_project_client() was still entering the cloud workspace resolution path for cloud-mode projects
  • This called get_cloud_control_plane_client() which hit the production API at /workspaces/, failing with 401 since the in-process server has no credentials to call itself externally
  • Added an early is_factory_mode() check that short-circuits before workspace resolution — the transport layer has already resolved workspace and tenant context

Test plan

  • Added test_factory_mode_skips_workspace_resolution — sets up a factory client, patches resolve_workspace_parameter and get_cloud_control_plane_client to fail if called, verifies neither is invoked
  • All 25 existing test_project_context.py tests pass
  • Verified fix resolves 401 errors on read_note, search_notes, and list_directory MCP tools in cloud server

🤖 Generated with Claude Code

When the cloud MCP server runs in-process, it calls set_client_factory()
so that get_client() routes requests through TenantASGITransport. However,
get_project_client() was still entering the cloud workspace resolution
path for cloud-mode projects, which calls get_cloud_control_plane_client()
to hit the production API at /workspaces/. This fails with 401 because
the in-process server has no credentials for calling itself externally.

Add an early is_factory_mode() check in get_project_client() that
short-circuits before workspace resolution. When a factory is set, the
transport layer has already resolved workspace and tenant context.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Joe P <joe@basicmemory.com>
@phernandez
Copy link
Member

@claude could we also check
BASIC_MEMORY_CLOUD_MODE = "true"

here instead of this weird factor_mode notion?

@claude
Copy link
Contributor

claude bot commented Feb 27, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

1 similar comment
@claude
Copy link
Contributor

claude bot commented Feb 27, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

@phernandez phernandez merged commit 4ea5396 into main Feb 27, 2026
27 checks passed
@phernandez phernandez deleted the fix-factory-mode-workspace-resolution branch February 27, 2026 20:40
phernandez added a commit that referenced this pull request Feb 28, 2026
Add write_note overwrite guard (#632) to new capabilities, 8 bug fixes
(#631, #630, #30, #31, #28, plus schema_validate/Post/frontmatter fixes),
and write_note idempotency breaking change to upgrade notes. Bump commit
count from 80+ to 90+.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: phernandez <paul@basicmachines.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants