How adner/azurecontainerappssandboxes works
Purpose and entry points
Experimental host-side MCP service for delegating prompts to isolated, ephemeral Azure Container Apps Sandboxes, then streaming and aggregating worker outputs. Start the service with scripts/run_mcp_server.py; direct fan-out execution is available through scripts/run_fanout_demo.py. The MCP endpoint exposes run_agents and await_results.
MCP host and run boundary
src/mcp_server/app.py initializes the host MCP application. src/mcp_server/registry.py owns asynchronous run state, worker events/results, and replayable streams. src/mcp_server/http_routes.py serves run-oriented HTTP routes consumed by the live app panel. This process is the orchestration and client-facing boundary; it is not production-authenticated.
• src/mcp_server/app.py
• src/mcp_server/registry.py
• src/mcp_server/http_routes.py
Fan-out lifecycle
The orchestration library converts delegated prompts into one sandbox worker each, creates workers from a configured warm snapshot, reasserts egress/exposes worker ports, consumes their SSE output, aggregates completion, and cleans up sandboxes regardless of outcome. The ACA CLI and configured Azure subscription/resource group/sandbox group are infrastructure dependencies.
• src/sandbox_fanout/fanout.py
• src/sandbox_fanout/lifecycle.py
• src/sandbox_fanout/backend.py
Worker execution plane
A snapshot contains a single-use FastAPI worker agent. Each worker accepts its assigned prompt, invokes OpenAI model tooling, can execute local Python/shell tools, and emits trace, final result, and optional visualization events over SSE. Workers are hardware-isolated ACA Sandboxes and are intended to be deleted after the batch.
• src/sandbox_agent/server.py
• src/sandbox_agent/agent.py
• scripts/build_snapshot.sh
Event and result flow
Client request → MCP host creates a registry run → fan-out provisions workers → each worker streams SSE events → fan-out/registry persist and relay events → MCP client polls/awaits results while the UI consumes /runs/* streams. Results retain textual answers and constrained, renderer-safe visualization payloads rather than allowing arbitrary UI content.
• src/sandbox_fanout/sse.py
• src/sandbox_fanout/models.py
• src/mcp_server/registry.py
MCP App presentation
The bundled MCP App renders a live pane per worker, displays traces, and validates/renders ECharts visualizations. The built panel is committed for host serving; TypeScript source supports UI iteration.
• src/mcp_server/ui/dist/panel.html
• src/mcp_server/ui/src/main.ts
• src/mcp_server/ui/src/visualization.ts
Optional Dataverse delegation
Dataverse access is optional and deliberately host-owned: encrypted MSAL/PKCE state remains outside snapshots, while workers receive only short-lived delegated tokens for a batch. Workers use OpenAI’s optional native remote-MCP path to reach the Dataverse MCP server. This is a single operator identity model, not multi-user authorization.
• src/dataverse_auth/provider.py
• src/dataverse_auth/config.py
• scripts/auth_dataverse.py
M365 integration and security posture
FanoutAgent packages an optional Microsoft 365 Copilot declarative-agent wrapper that calls the host MCP service. Deployment commonly requires a protected tunnel, but the current implementation has no production-grade inbound auth; exposed worker ports and run streams are explicitly unsafe for public or sensitive deployments.
• FanoutAgent/appPackage/manifest.json
• FanoutAgent/appPackage/mcp-tools.json
• cloud_auth_spec.md
Main entry points: app.py MCP application · server.py Worker API · fanout.py Fanout orchestration · provider.py Delegated token provider
Components 22
Host MCP service
Client-facing orchestration boundary.
- MCP server launcher
scripts/run_mcp_server.py - MCP application · Exposes run_agents and await_results.
src/mcp_server/app.py - Run registry · Stores runs, worker events, results, and replayable streams.
src/mcp_server/registry.py - Run HTTP routes · Serves live-panel run streams.
src/mcp_server/http_routes.py
Sandbox fan-out
Creates, streams, aggregates, and removes workers.
- Fan-out demo
scripts/run_fanout_demo.py - Fanout orchestration · Maps delegated prompts to sandbox workers.
src/sandbox_fanout/fanout.py - Sandbox lifecycle · Creates from snapshots and always cleans up.
src/sandbox_fanout/lifecycle.py - Azure backend · Uses configured Azure subscription, resource group, and sandbox group.
src/sandbox_fanout/backend.py - Worker SSE consumer
src/sandbox_fanout/sse.py - Result models · Constrains renderer-safe visualization payloads.
src/sandbox_fanout/models.py
Worker execution plane
Ephemeral isolated sandbox agents.
- Worker snapshot build
scripts/build_snapshot.sh - Worker API · Single-use prompt endpoint and SSE event producer.
src/sandbox_agent/server.py - Worker agent · Uses model tooling plus local Python and shell tools.
src/sandbox_agent/agent.py
Live app panel
- Served panel · Committed panel served by the host.
src/mcp_server/ui/dist/panel.html - Panel application · Renders a live pane per worker.
src/mcp_server/ui/src/main.ts - Visualization renderer · Validates and renders visualization events.
src/mcp_server/ui/src/visualization.ts
Optional Dataverse delegation
Host-owned delegated authorization.
- Delegated token provider · Keeps encrypted authorization state on the host.
src/dataverse_auth/provider.py - Dataverse auth config
src/dataverse_auth/config.py - Dataverse auth bootstrap
scripts/auth_dataverse.py
M365 integration
- Copilot agent package · Calls the host MCP service.
FanoutAgent/appPackage/manifest.json - MCP tool declaration
FanoutAgent/appPackage/mcp-tools.json - Deployment security posture · No production-grade inbound authentication; public exposure is unsafe.
cloud_auth_spec.md
Connections 26
- MCP server launcher → MCP application: starts
- MCP application → Run registry: creates and awaits runs
- MCP application → Fanout orchestration: delegates prompts
- Fan-out demo → Fanout orchestration: invokes directly
- Fanout orchestration → Sandbox lifecycle: provisions and cleans up
- Sandbox lifecycle → Azure backend: uses ACA CLI
- Worker snapshot build → Worker API: builds snapshot containing
- Sandbox lifecycle → Worker API: creates isolated workers
- Worker API → Worker agent: executes assigned prompt
- Worker API → Worker SSE consumer: streams SSE events
- Worker SSE consumer → Run registry: persists and relays
- Fanout orchestration → Result models: aggregates typed results
- Result models → Run registry: stores completion
- MCP application → Run HTTP routes: serves
- Run HTTP routes → Run registry: reads run streams
- Served panel → Panel application: bundles
- Panel application → Run HTTP routes: consumes /runs streams
- Panel application → Visualization renderer: renders safe payloads
- Dataverse auth bootstrap → Delegated token provider: establishes operator auth
- Delegated token provider → Dataverse auth config: uses
- MCP application → Delegated token provider: issues batch delegated tokens
- Delegated token provider → Worker agent: passes short-lived token
- Copilot agent package → MCP tool declaration: includes tool contract
- MCP tool declaration → MCP application: calls host MCP
- Deployment security posture → MCP application: documents inbound-auth risk
- Deployment security posture → Worker API: documents exposed-port risk