feat: multi-sandbox support — per-session isolated Sandbox CRDs#53
Merged
feat: multi-sandbox support — per-session isolated Sandbox CRDs#53
Conversation
Each MCP HTTP session now gets its own Sandbox CRD (agents.x-k8s.io), with a dedicated pod, service, and gRPC connection. This provides full session isolation instead of sharing a single sandbox across all clients. Key changes: - SandboxManager class maps sessions to Sandbox CRDs via K8s API - Per-session McpServer instances to avoid cross-session interference - Session-aware client resolver threaded through runSandbox tool - Idle timeout reaper cleans up abandoned sessions (default 10 min) - Max concurrent sessions cap (default 10) - Startup orphan cleanup for stale CRDs from prior crashes - Explicit DELETE, SSE stream drop, and idle timeout all trigger cleanup - RBAC for Sandbox CRD management in all K8s/OpenShift manifests - ConfigMap-based library config in k8s/mcp-server.yaml - Removed legacy src/kube/ (unused wrapper code) - 21 new tests covering SandboxManager, idle reaper, session routing - Architecture diagram added to README and docs New env vars: SANDBOX_MODE, SANDBOX_NAMESPACE, SANDBOX_IMAGE, SANDBOX_IDLE_TIMEOUT_MS, SANDBOX_MAX_SESSIONS Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agents.x-k8s.io/v1alpha1), with a dedicated pod, service, and gRPC connection — full session isolation instead of sharing a single sandboxSandboxManagerclass handles lifecycle: create on session init, cleanup on DELETE / SSE drop / idle timeout / server shutdownMcpServerinstances fix cross-session response interference when multiple clients connect concurrentlysrc/kube/code (unused wrapper)SANDBOX_MODE=multiNew env vars:
SANDBOX_MODE,SANDBOX_NAMESPACE,SANDBOX_IMAGE,SANDBOX_IDLE_TIMEOUT_MS,SANDBOX_MAX_SESSIONSTest plan
npm run buildpasses🤖 Generated with Claude Code