Per-Request Workspace Isolation

story-notion-mcp-remote-multi-workspace-safety User Story

active user-story

story: Per-Request Workspace Isolation

Role

Operator — responsible for tenant safety when multiple users or workspaces connect to the same deployment.

Key

multi-workspace-safety

Want

As an operator, I want each OAuth-authenticated request to use only its own user's Notion token.

So That

So that one deployment can serve multiple users and workspaces without any cross-tenant data bleed.

Acceptance Criteria

  • [ ] The NotionClient for a request is set via a ContextVar at auth-resolution time and cleared at request end
  • [ ] notion_mcp.server.get_client and all 6 tool modules are patched to read the ContextVar, not a shared global
  • [ ] Two concurrent requests with different workspaces return the correct per-request data in tests
  • [ ] No global singleton NotionClient exists anywhere in the runtime path

Success Metric

Zero cross-tenant incidents. A concurrency test with 2+ workspaces returns workspace-correct results 100% of the time.
  • arch-domain-notion-mcp-remote — AccessToken binds to a single NotionWorkspace and User
  • arch-dataflow-notion-mcp-remote — per-request ContextVar set in the tool-call sequence
  • project-notion-mcp-remote
  • board-notion-mcp-remote