Keep workspace-write access on cross-session MCP resume

Merged
RH
2mo ago
+124-17

When a model calls resume from a different MCP session than the one that started the execution (for example after an mcp-remote reconnect), the requester's session forwards the resume to the owning session via resumeExecutionForModel. That RPC ran engine.resume with no CurrentOrgWriteAccess bound, so the engine rebound the paused execution to the fail-closed "denied" default. An admin's pending addServer / addSpec / updateSpec then failed with org_write_denied.

  • The forwarded identity (McpModelResumeCaller) now carries the requester's orgWriteAccess, read from its own request context.
  • The owning session binds that value around engine.resume. A caller from the previous deploy that omits it is treated as denied.

Prod telemetry over the last 14 days: every always-gated admin write resumed through the cross-session path was denied. Same-session resumes were almost never denied.

Tests: new cases in agent-session-model-resume.test.ts cover allowed, denied, and a legacy caller. The allowed case fails without the fix. Typecheck is clean for @executor-js/cloudflare, apps/cloud, and apps/host-cloudflare.