Honor configured tenancy for Desktop MCP credentials

AG
3d ago
+52-14

A synthetic verified Desktop sign-in in multi-tenant mode reproduced the reported Cursor registration failure on main: adding a second organization caused POST to answer 403 workspace_access_changed. Both registration and child-token resolution required the entire database to contain exactly one organization.

Pass the store's configured tenancy mode into both DesktopMcpCredentials instances. The global singleton condition still applies in single mode. The multi-mode SQL retains the exact workspace/organization/user membership joins, parent proof, locks, revocation and lease checks.

The HTTP regression covers registration, MCP authentication, renewal, a different organization's workspace, and loss of the original membership. A single-mode fixture also checks refusal after a second organization appears. Existing tests cover parent revocation and token-class restrictions. No Alpha environment access or deployment was used.


Run Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes Desktop MCP credential registration and child-token resolution failing in multi-tenant mode. The credential store enforced a whole-database single-organization invariant regardless of configured tenancy, so adding a second organization caused MCP authentication to return 403 workspace_access_changed.

  • Threads the store's configured tenancy mode into both DesktopMcpCredentials instances; single-tenant mode keeps the global single-organization check, multi-tenant mode scopes to the verified workspace and live membership.
  • Adds regression coverage for multi-tenant registration, MCP authentication, token renewal, rejection of a different organization's workspace, and loss of the original membership.
  • Adds a single-tenant test asserting refusal after a second organization appears.
  • Hardens the Replicas verifier test so a corrupted signature always fails verification instead of accidentally passing.