warden

warden

A sandboxed MCP server that executes shell commands inside ephemeral, locked-down Docker containers with no network by default, dropped capabilities, and an audit log, enabling secure agent-driven command execution.

Category
Visit Server

README

Warden

License: MIT Node MCP

A sandboxed, egress-controlled MCP server. It exposes tools that let an agent (Claude, or any MCP client) execute shell commands, but every execution happens inside a locked-down, ephemeral Docker container instead of on the host, with no network access by default, no secrets baked into the image, and a full audit trail written before the command runs.

Built as a direct extension of TIF Score MCP, the first MCP server I authored. That one exposed trusted, internal scoring logic. This one is built for the harder case: giving an agent the ability to run arbitrary commands, where the interesting engineering problem is containing what happens if that ability is misused.

Demo

Every claim below was checked against a real, running Docker container in the same session this repo was built — not assumed working. The clip below is real captured terminal output, not staged.

Real terminal output: warden's sandbox verification checks running and passing against a live Docker container

A short narrated video walkthrough (same real footage, with captions) is at docs/demo/walkthrough-video.mp4.

Tools

Tool What it does
run_sandboxed Runs a shell command inside a locked-down container and returns stdout/stderr/exit code.
list_audit_log Returns the last N execution attempts and their results.
set_egress_allowlist Updates which domains a sandbox may reach. Empty by default — no outbound access.

Setup

npm install
cp .env.example .env    # fill in sandbox image / limits, never commit this file
docker pull alpine:3.20 # or your chosen base image
npm start                # runs the MCP server over stdio

Register it in your MCP client config (e.g. Claude Desktop claude_desktop_config.json, or a project-scoped .mcp.json — see this repo's own .mcp.json for a working example):

{
  "mcpServers": {
    "warden": {
      "command": "node",
      "args": ["/absolute/path/to/warden/src/index.js"]
    }
  }
}

Security model

Every control below is implemented in src/sandbox.js and src/egress.js, not just described here — read those files, they're short and commented inline with the reasoning for each flag. Every one of them was also verified against a real running container this session; see Project docs below for the evidence and the two real bugs that verification actually found and fixed.

  • No network by default. A sandbox can't exfiltrate data or call out to an attacker-controlled host unless a network mode is explicitly requested, and even then only through a domain allowlist.
  • Non-root, capabilities dropped. Runs as UID 1000 with --cap-drop=ALL and --security-opt=no-new-privileges. A compromised process inside the sandbox has no privileged Linux capabilities to escalate with.
  • Read-only root filesystem. Only a 64MB tmpfs scratch directory is writable. Nothing persists past the container's lifetime.
  • Resource limits. Memory, CPU, and PID caps prevent a runaway or fork-bombing process from affecting the host. Memory-swap is pinned equal to the memory limit, so there's no implicit 2x headroom from Docker's default swap behavior.
  • Hard timeout. A wall-clock kill switch independent of the process's own behavior — the container is force-stopped by name, not just the local docker client process, since a killed client doesn't otherwise guarantee the container stops.
  • Secrets never touch the image. All configuration (sandbox image name, resource limits, timeout) comes from environment variables via .env, which is gitignored. Nothing is hardcoded, nothing is logged.
  • Audit-before-execute. Every call to run_sandboxed is logged with its full parameters before the container starts, so a killed or crashed sandbox still leaves a record of what was attempted — the same gate-before-action pattern used in production TCS agents, applied here at the sandbox-execution layer.

Tradeoffs (the buy-vs-build reasoning)

Why Docker isolation and not a microVM (Firecracker, gVisor)?

Docker's isolation is namespace- and cgroup-based: it shares the host kernel. A microVM sandbox (Firecracker, as used by AWS Lambda and Fly.io; gVisor, used by Google Cloud Run) runs a minimal guest kernel per sandbox, which closes off an entire class of kernel-exploit escapes that Docker isolation doesn't.

For this project, Docker was the right call, not because it's equally safe, but because the threat model is bounded: this isn't running arbitrary untrusted code from the public internet at scale, it's running agent-requested commands in a controlled, single-operator context, where the combination of no-network-by-default + dropped capabilities + read-only filesystem + resource limits closes the realistic attack surface for that context. Reaching for Firecracker here would be solving a problem this deployment doesn't have yet, at real cost in setup and operational complexity.

The kill criterion for that decision: if this ever ran commands from untrusted, external, internet-facing input instead of a single operator's own agent, that's the point where the extra week for a microVM layer becomes worth spending, and I'd revisit this file and swap the isolation layer rather than patch around it.

Not yet built (documented honestly, not hidden)

  • The egress allowlist is stored and served to warden-cli allowlist, but the actual iptables/proxy enforcement on the warden-egress Docker network is not wired up yet — this is the next real piece of work, not a finished control.
  • No persistent identity/auth layer on the MCP server itself; it assumes a trusted local MCP client (Claude Code/Desktop), the same trust boundary as tif-score-mcp.

CLI

node cli/warden-cli.js status       # list running sandboxes
node cli/warden-cli.js logs 50      # last 50 audit log entries
node cli/warden-cli.js kill <id>    # force-kill a running sandbox
node cli/warden-cli.js allowlist    # show current egress allowlist

Project docs

Everything from the verification session that built and hardened this repo — nothing summarized away:

  • docs/BEHIND_THE_SCENES.pdf — the full build story, plain language, plan to finish.
  • docs/learning/ — technical write-ups of every real bug verification found: a container-leak on timeout, an implicit 2x memory-swap headroom, and a follow-up adversarial pressure-test pass (fork bombs, corrupted logs, unbounded stdout, misreported containers) that found and fixed four more, all with before/after evidence.
  • docs/evidence/ — raw captured command output backing every claim above.
  • docs/plan/PLAN.md — the plan this session was executed against.
  • docs/skills-used/ — what built this, and how.
  • scripts/ — the standalone verification scripts themselves; rerun them yourself against your own Docker daemon.

Stack

Node.js, @modelcontextprotocol/sdk, Zod, Docker CLI (invoked via child_process, no Docker Engine API dependency).

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured