Skip to content

fix(http+mcp): tenant isolation for cross-project recall#220

Merged
wtthornton merged 7 commits into
mainfrom
fix/cross-project-recall-tenant
Jul 2, 2026
Merged

fix(http+mcp): tenant isolation for cross-project recall#220
wtthornton merged 7 commits into
mainfrom
fix/cross-project-recall-tenant

Conversation

@wtthornton

Copy link
Copy Markdown
Owner

Summary

  • REST data-plane routes resolve tenant-scoped MemoryStore from X-Project-Id (ADR-010)
  • MCP Streamable HTTP session tasks honor per-request headers over stale initialize contextvar
  • Tool filter refreshes tenant contextvars on each tools/call

Test plan

  • Unit tests for header tenant fallback and stale-init override
  • Live MCP: save tapps-mcp, get nlt-orchestrator → not_found
  • Live REST cross-tenant recall isolated

Made with Cursor

wtthornton and others added 7 commits July 1, 2026 16:47
…p is Cursor-only) with Linux project-root headers

Co-authored-by: Cursor <cursoragent@cursor.com>
REST handlers were passing X-Project-Id into memory_service while reusing the
process-default cfg.store, breaking tenant isolation for cross-project recall.
Resolve per-request stores via _get_store_for_project (same helper as MCP
_StoreProxy) and only use the startup async store when it matches the tenant.

Co-authored-by: Cursor <cursoragent@cursor.com>
…asks

MCP session tasks inherit a stale REQUEST_PROJECT_ID from initialize, so
cross-tenant tools/call must resolve tenant identity from the inbound HTTP
request on request_ctx before the contextvar. Also refresh contextvars in
the tool_filter wrapper when headers override the session default.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
_resolve_wrapped_default_store avoids MagicMock auto-creating _default_store,
which broke _async_store_covers_tenant. Integration tests patch
_get_store_for_project to return injected mock stores.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@wtthornton wtthornton merged commit 81d0540 into main Jul 2, 2026
3 checks passed
@wtthornton wtthornton deleted the fix/cross-project-recall-tenant branch July 2, 2026 16:39
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.

1 participant