devcontainer-mcp
Allows creating and managing local dev containers using Docker, including running commands, reading/writing files, and lifecycle management.
Provides tools for creating and managing GitHub Codespaces, executing commands via SSH, and handling GitHub authentication for cloud-based development environments.
Enables using Kubernetes as a provider for DevPod workspaces, allowing agents to deploy and manage dev containers on Kubernetes clusters.
devcontainer-mcp
Give your AI agent its own dev environment — not yours.
devcontainer-mcp is an MCP server that lets AI coding agents create, manage, and work inside dev containers across three backends: local Docker, DevPod, and GitHub Codespaces. The agent builds, tests, and ships code in an isolated container — your laptop stays clean.
Works with GitHub Copilot, Claude, Cursor, opencode, and any MCP-compatible client.
The Problem
When AI agents write code, they need to run it somewhere. Today that means your host machine:
🔴 Host contamination — agents install packages, modify PATH, leave behind build artifacts
🔴 "Works on my machine" — agents assume your local toolchain matches production
🔴 No isolation — one project's dependencies break another
🔴 Security risk — agents run arbitrary commands with your user privileges
🔴 Hardware constraints — you're limited to your local machine's resources
Related MCP server: Agentic Control Framework (ACF)
The Solution
The devcontainer spec already defines reproducible, container-based dev environments. Every major project ships a .devcontainer/devcontainer.json. But AI agents can't use them — until now.
devcontainer-mcp exposes 45 MCP tools that let any AI agent:
Spin up a dev container from any repo — locally, on a cloud VM, or in Codespaces
Run commands inside the container — builds, tests, linting, anything
Manage the lifecycle — stop, restart, delete when done
Authenticate against cloud providers — GitHub, AWS, Azure, GCP — without ever seeing a raw token
Agent: "Let me build this project..."
→ auth_status("github") → picks account
→ codespaces_create(auth: "github-you", repo: "your/repo")
→ codespaces_ssh(auth: "github-you", codespace: "...", command: "cargo build")
→ ✅ Built in the cloud. Your laptop did nothing.Quick Install
Linux / macOS
curl -fsSL https://raw.githubusercontent.com/aniongithub/devcontainer-mcp/main/install.sh | bashWindows (via WSL)
Invoke-RestMethod https://github.com/aniongithub/devcontainer-mcp/releases/latest/download/install.ps1 | Invoke-ExpressionHow it works: The binary runs inside WSL; MCP clients on Windows launch it via
wsl ~/.local/bin/devcontainer-mcp serve. The stdio transport works transparently across the WSL boundary. WSL 2 is required — install it withwsl --installif you haven't already.
Backend CLIs (devpod, devcontainer, gh) are detected at runtime — if one is missing, the MCP server returns a helpful error with install instructions.
Binaries available for linux-x64, linux-arm64, darwin-x64, and darwin-arm64.
Host Protection & Opt-Out
The installer configures two agent hooks (Claude Code & GitHub Copilot CLI) that activate only in a directory containing .devcontainer/devcontainer.json:
devcontainer-guard(PreToolUse) — blocks shell/command execution on the host so the agent routes builds, tests, and runs through the MCP tools instead. Host-safe commands (git,gh) are allowlisted, and both hooks fail open — ifjqis missing or a payload can't be parsed, commands are allowed rather than blocked.devcontainer-skill-loader(SessionStart) — injects theSKILL.mdusage guide as context.
Turning it off for a repo
Sometimes a project ships a stale or unmaintained .devcontainer that you don't actually want to route work through. To disable both hooks for that repo, drop a marker file at the repo root:
touch .devcontainer-mcp-disableWhen .devcontainer-mcp-disable is present, the guard allows host commands through and the skill-loader skips context injection — the agent works locally as if no devcontainer were declared. Commit it (or add it to .gitignore for a local-only opt-out).
One-off bypass: to run a single host command without disabling the guard, include USER_CONFIRMED_HOST_OPERATION=1 anywhere in the command.
Architecture
graph TD
A[AI Agent / MCP Client] -->|stdio JSON-RPC| B[devcontainer-mcp]
subgraph "devcontainer-mcp"
B --> C[33 MCP Tools]
C --> D[Auth Broker]
C --> E[devcontainer-mcp-core]
end
D -->|opaque handles| C
E -->|subprocess| F[DevPod CLI]
E -->|subprocess| G[devcontainer CLI]
E -->|subprocess| H[gh CLI]
E -->|bollard API| I[Docker Engine]
F --> J[Docker / K8s / Cloud VMs]
G --> K[Local Docker]
H --> L[GitHub Codespaces]Three Backends, One Interface
Backend | Best for | Requires | Auth needed? |
devcontainer CLI ( | Local Docker — fast, simple | @devcontainers/cli + Docker | No |
DevPod ( | Multi-cloud: Docker, K8s, AWS, Azure, GCP | Optional (cloud providers) | |
Codespaces ( | GitHub-hosted cloud environments | Yes ( |
Auth Broker
The agent never sees raw tokens. Instead:
auth_status(provider)— list available accounts and scopesauth_login(provider, scopes?)— initiate login, opens browser, handles device codesauth_select(id)— switch the active accountauth_logout(id)— revoke credentials
Codespaces tools require an auth handle (e.g. "github-aniongithub"). The MCP server resolves it to the real token on each call via the CLI's native keyring.
Supported providers: GitHub, AWS, Azure, GCP, Kubernetes
MCP Tools (46 total)
Auth (4 tools)
Tool | Description |
| Check auth for a provider — returns handles, accounts, scopes |
| Initiate login or refresh scopes — browser + device code flow |
| Switch the active account for a provider |
| Revoke credentials for an account |
DevPod (19 tools)
Tool | Description |
| Create and start a workspace from a git URL, local path, or image |
| Stop a running workspace |
| Delete a workspace and its resources |
| Build a workspace image without starting it |
| Get workspace state ( |
| List all workspaces with IDs, sources, providers, and status |
| Execute a command inside a workspace via SSH |
| Get workspace logs |
| List all configured providers |
| Add a new provider |
| Remove a provider |
| List all contexts |
| Switch to a different context |
| Docker inspect — labels, ports, mounts, state |
| Stream container logs via Docker API |
| Read file content with optional line range |
| Create or overwrite a file (auto-creates parent dirs) |
| Surgical string replacement — old_str → new_str |
| List directory contents (non-hidden, 2 levels deep) |
devcontainer CLI (12 tools)
Tool | Description |
| Create and start a local dev container |
| Execute a command inside a running dev container |
| Build a dev container image |
| Read merged devcontainer configuration as JSON |
| Discover all devcontainer.json files in a workspace (single + multi-container) |
| Stop a dev container (via Docker API) |
| Remove a dev container and its resources |
| Get dev container state by workspace folder |
| Read file content with optional line range |
| Create or overwrite a file (auto-creates parent dirs) |
| Surgical string replacement — old_str → new_str |
| List directory contents (non-hidden, 2 levels deep) |
GitHub Codespaces (11 tools) — require auth handle
Tool | Description |
| Create a new codespace for a repository |
| List your codespaces with state and machine info |
| Execute a command inside a codespace via SSH |
| Stop a running codespace |
| Delete a codespace |
| View detailed codespace info (state, machine, config) |
| List forwarded ports with visibility and URLs |
| Read file content with optional line range |
| Create or overwrite a file (auto-creates parent dirs) |
| Surgical string replacement — old_str → new_str |
| List directory contents (non-hidden, 2 levels deep) |
MCP Server Configuration
Linux / macOS
{
"mcpServers": {
"devcontainer-mcp": {
"command": "devcontainer-mcp",
"args": ["serve"]
}
}
}Windows (WSL bridge)
{
"mcpServers": {
"devcontainer-mcp": {
"command": "wsl",
"args": ["~/.local/bin/devcontainer-mcp", "serve"]
}
}
}Prerequisites
Install backend CLIs as needed — the MCP server detects them at runtime and returns helpful errors if missing:
devcontainer CLI:
npm install -g @devcontainers/cli+ DockerDevPod: DevPod CLI + Docker (or another provider)
Codespaces: GitHub CLI — auth is handled by the
auth_logintool
Self-Healing
When devcontainer_up, devpod_up, or codespaces_create fails, the full build output (including errors) is returned to the agent. The agent can read the error, fix the Dockerfile or devcontainer.json, and retry — making the dev environment a dynamic, agent-managed asset rather than a static prerequisite.
Multi-container workspaces
The devcontainer spec supports connecting to multiple containers in one workspace by placing per-service configs at .devcontainer/<name>/devcontainer.json, each pointing at a shared docker-compose.yml. devcontainer-mcp supports this pattern end-to-end:
Discovery —
devcontainer_list_configsreturns every config it finds (root.devcontainer.json,.devcontainer/devcontainer.json, and each.devcontainer/*/devcontainer.json) with its kind (image/dockerfile/compose), service name, and absolute path.Targeting — Every devcontainer tool (
up,exec,build,stop,remove,status,read_config,file_*) accepts an optionalconfigparameter pointing at a specificdevcontainer.json. Single-container workflows continue to work unchanged —configdefaults to whatever the devcontainer CLI auto-detects.Ambiguity handling — When a workspace has multiple configs and no
configis provided, lookup-style tools (status,exec,stop,remove,file_*) return a structuredAmbiguousresult listing every matching container so the agent can pick the right one.statusreports this as{"state":"Ambiguous","candidates":[...],"hint":"..."}.Robust container matching — Sibling compose containers are identified via
com.docker.compose.service+com.docker.compose.project.config_files(not the unreliabledevcontainer.local_folderlabel, which is only stamped on the first container).
Development
This project eats its own dogfood — development happens inside its own devcontainer.
# Using the devcontainer CLI
devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . cargo build --workspace
devcontainer exec --workspace-folder . cargo test --workspace
devcontainer exec --workspace-folder . cargo build --release -p devcontainer-mcp
# Or using DevPod
devpod up . --id devcontainer-mcp --provider docker --open-ide=false
devpod ssh devcontainer-mcp --command "cd /workspaces/devcontainer-mcp && cargo build --workspace"CI/CD
Pull Requests —
cargo check,cargo test,cargo clippy,cargo fmtrun automaticallyReleases — Creating a GitHub release builds binaries for all 4 platforms
License
This server cannot be deployed
Maintenance
Related MCP Connectors
327 dev tools via REST API and MCP. Generate Dockerfiles, schemas, K8s, APIs, and more.
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
MCP-first toolbox for agents: KV storage, auth, queue, and utility tools. Free in early access.
65+ AI tools as MCP: research, write, code, scrape, translate, RAG, agent memory, workflows
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI-powered creation, configuration, and management of DevContainer environments using natural language prompts. Supports 11+ templates for popular development stacks and provides container lifecycle operations through VS Code, Cursor, or any MCP-compatible editor.62MIT
- AlicenseDqualityDmaintenanceAI-native orchestration layer with 80+ tools for task management, code editing, browser automation, terminal control, and persistent memory across CLI, local MCP, and cloud deployments.694 npm31ISC
- AlicenseNot gradedqualityAmaintenanceProvides 7 MCP servers with 95 tools for git, GitHub, .NET, Ollama, Rust, template sync, and Python, enabling natural-language commands to perform real development operations.1MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI coding assistants to manage persistent memory, search project context, generate tests, review architecture, and orchestrate workflows through 15 MCP tools, enhancing context-aware code generation.-