Per-Request Workspace Isolation
story: Per-Request Workspace Isolation
Role
Operator — responsible for tenant safety when multiple users or workspaces connect to the same deployment.
Key
multi-workspace-safetyWant
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
NotionClientfor a request is set via aContextVarat auth-resolution time and cleared at request end - [ ]
notion_mcp.server.get_clientand 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
NotionClientexists 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.
Related Architecture
arch-domain-notion-mcp-remote— AccessToken binds to a single NotionWorkspace and Userarch-dataflow-notion-mcp-remote— per-request ContextVar set in the tool-call sequence
Related
project-notion-mcp-remoteboard-notion-mcp-remote