Transform Claude Code from a CLI tool into an orchestratable service through the Model Context Protocol
An MCP (Model Context Protocol) server that manages containerized Claude Code sessions, enabling AI assistants to create and control isolated Claude Code instances programmatically. Unlike simple containerization solutions, this provides a clean API for AI-to-AI workflows and enterprise integrations.
This is an unofficial containerization of Claude Code. Users are responsible for compliance with Anthropic's Terms of Service. By using this software, you acknowledge that you have read and agreed to Anthropic's terms.
- 🐳 Docker-based Isolation: Each Claude Code instance runs in its own container
- 🔄 Session Management: Create, execute, and destroy Claude Code sessions
- 📁 Volume Mounting: Persistent storage for project files
- 🔒 Security: Container isolation protects the host system
- 🚀 Scalability: Run multiple sessions simultaneously
- 🛠️ Extended Tools: File transfer, command execution, and log access
- ☁️ AWS Bedrock Support: Use Claude through AWS Bedrock for enterprise deployments
- 🔑 Flexible Authentication: Support for both Anthropic API keys and AWS credentials
// Create sessions for different microservices
const frontend = await createSession({ projectPath: '/app/frontend' });
const backend = await createSession({ projectPath: '/app/backend' });
// Work on both simultaneously
await executeInSession({
sessionId: frontend.id,
prompt: 'Update React components to use new design system'
});
await executeInSession({
sessionId: backend.id,
prompt: 'Implement new REST endpoints for user management'
});// Pull request review workflow
const session = await createSession({ projectPath: '/tmp/pr-1234' });
const review = await executeInSession({
sessionId: session.id,
prompt: 'Review this code for security vulnerabilities and performance issues'
});
// Post review comments back to GitHub// Update multiple projects with new security policy
for (const project of projects) {
const session = await createSession({
projectPath: project.path,
useBedrock: true,
awsRegion: 'us-east-1'
});
await executeInSession({
sessionId: session.id,
prompt: 'Update dependencies and apply new security headers'
});
}# GitHub Actions example
- name: AI Code Review
run: |
npx claude-code-mcp create-session ./
npx claude-code-mcp execute "Review code changes and suggest improvements"This is a fork of steipete/claude-code-mcp that adds containerization capabilities. Instead of running Claude Code directly, this server manages Docker containers running Claude Code, providing:
- Better isolation between different projects
- Ability to run multiple Claude Code instances
- Protection of the host system
- Easy cleanup of resources
- Support for AWS Bedrock as an alternative to Anthropic API
| Feature | claude-code-mcp (This Project) |
claudebox | claude-docker | Base claude-code |
|---|---|---|---|---|
| Containerization | ✅ Full isolation | ✅ Full isolation | ✅ Full isolation | ✅ Basic |
| MCP Interface | ✅ Full API | ❌ CLI only | ❌ CLI only | ❌ None |
| Multi-Session | ✅ Unlimited | 🟡 Limited | ❌ Single | ❌ None |
| AWS Bedrock | ✅ Native | ❌ No | ❌ No | ❌ No |
| Session API | ✅ Complete | ❌ None | ❌ None | ❌ None |
| AI Orchestration | ✅ Built-in | ❌ Manual | ❌ Manual | ❌ None |
While other projects focus on running Claude Code in Docker, we provide programmatic control through MCP:
// Other solutions: Manual Docker commands
docker run -it claude-code
// Our solution: Programmable API
await mcp.tool('create_session', { projectPath: '/app' });
await mcp.tool('execute_in_session', { prompt: 'refactor this code' });This enables:
- AI-to-AI workflows: Claude can manage multiple Claude Code sessions
- CI/CD integration: Automated code reviews and testing
- Enterprise automation: Bulk operations across projects
This MCP server requires access to the Docker daemon, which has significant security implications:
- Root-equivalent permissions: Docker access can be used to gain root privileges
- Container isolation: While Claude Code runs isolated, the MCP server has Docker control
- Network security: Containers can access network resources based on Docker configuration
-
Run the MCP server in a container (double isolation):
docker run -v /var/run/docker.sock:/var/run/docker.sock claude-code-mcp
-
Use Docker security options:
--security-opt=no-new-privileges --cap-drop=ALL
-
Restrict network access in production environments
-
Monitor container activity and implement audit logging
For maximum security, consider running this in a dedicated VM or container host.
- Node.js v20 or later
- Docker installed and running
- Either:
- Anthropic API key, OR
- AWS credentials with Bedrock access
To reduce external dependencies, we provide a custom Docker image:
# Build the custom image
./scripts/build-custom-image.sh
# This creates: claude-code-custom:latestgit clone https://github.com/democratize-technology/claude-code-container-mcp.git
cd claude-code-container-mcp
npm install
npm run build{
"claude-code-container": {
"command": "node",
"args": ["/path/to/claude-code-mcp/dist/container-server.js"],
"env": {
"ANTHROPIC_API_KEY": "your-api-key"
}
}
}{
"claude-code-container": {
"command": "node",
"args": ["/path/to/claude-code-mcp/dist/container-server.js"],
"env": {
"CLAUDE_CODE_USE_BEDROCK": "1",
"AWS_REGION": "us-east-1",
"AWS_ACCESS_KEY_ID": "your-access-key",
"AWS_SECRET_ACCESS_KEY": "your-secret-key",
"ANTHROPIC_MODEL": "us.anthropic.claude-opus-4-20250514-v1:0",
"ANTHROPIC_SMALL_FAST_MODEL": "us.anthropic.claude-3-5-haiku-20241022-v1:0"
}
}
}See your client's documentation for MCP server configuration.
Creates a new Claude Code container session.
Arguments:
projectPath(string, required): Path to mount in the containersessionName(string, optional): Human-friendly session nameapiKey(string, optional): Anthropic API key for this sessionuseBedrock(boolean, optional): Use AWS Bedrock instead of Anthropic APIawsRegion(string, optional): AWS region for BedrockawsAccessKeyId(string, optional): AWS access key IDawsSecretAccessKey(string, optional): AWS secret access keyawsSessionToken(string, optional): AWS session token (for temporary credentials)bedrockModel(string, optional): Bedrock model IDbedrockSmallModel(string, optional): Bedrock small/fast model IDmcpMounts(array, optional): MCP server directories to mount in the container- Each mount object contains:
hostPath(string, required): Path on Docker host to mountcontainerPath(string, required): Path in container where to mountreadOnly(boolean, optional): Mount as read-only (default: true)
- Each mount object contains:
mcpConfig(object, optional): MCP configuration passed to container as MCP_CONFIG environment variable⚠️ Note: The Claude Code container does NOT automatically process this configuration- The MCP_CONFIG is set as a base64-encoded environment variable but requires manual processing
- Contains:
mcpServers(object, required): MCP servers configuration
Executes a Claude Code command in an existing session.
Arguments:
sessionId(string, required): Session IDprompt(string, required): Prompt for Claude Codetools(array of strings, optional): Specific tools to enable
Lists all active sessions with their status.
Destroys a Claude Code session and removes the container.
Arguments:
sessionId(string, required): Session ID to destroy
Transfers files between host and container.
Arguments:
sessionId(string, required): Session IDdirection(string, required): 'to_container' or 'from_container'sourcePath(string, required): Source pathdestPath(string, required): Destination path
Executes an arbitrary command in the container.
Arguments:
sessionId(string, required): Session IDcommand(string, required): Command to execute
Retrieves container logs for debugging.
Arguments:
sessionId(string, required): Session IDtail(number, optional): Number of lines to tail (default: 100)
Create a new Claude Code session for the project at /home/user/my-project
Create a new Claude Code session for /home/user/my-project using Bedrock with AWS region us-west-2
In session abc123, refactor the main.py file to use async/await
List all active sessions
Destroy session abc123
The mcpMounts parameter allows you to mount MCP server directories into the container:
{
"tool": "create_session",
"arguments": {
"projectPath": "/home/user/my-project",
"sessionName": "with-mcp-mounts",
"mcpMounts": [
{
"hostPath": "/opt/mcp-servers",
"containerPath": "/opt/mcp-servers",
"readOnly": true
}
]
}
}mcpConfig parameter requires a custom Docker image. The default Claude Code container does not process the MCP_CONFIG environment variable.
-
Build the custom image with MCP support:
./scripts/build-custom-image.sh
The custom image includes:
- MCP configuration processor (processes
MCP_CONFIGenvironment variable) jqfor JSON processinguvfor Python-based MCP serversnpx(from base image) for JavaScript/TypeScript MCP servers
- MCP configuration processor (processes
-
Configure your MCP server to use the custom image:
{ "claude-code-container": { "env": { "DEFAULT_CLAUDE_IMAGE": "claude-code-mcp:latest" } } }
Once the custom image is built and configured, you can pass MCP server configuration:
{
"tool": "create_session",
"arguments": {
"projectPath": "/home/user/my-project",
"sessionName": "with-mcp-config",
"mcpConfig": {
"mcpServers": {
"sequential-thinking": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-sequential-thinking"]
}
}
}
}
}MCP_CONFIG environment variable. To use this configuration, you must manually merge it into .claude.json after creating the session:
# Inside the container, run:
echo $MCP_CONFIG | base64 -d | python3 -c "
import json, sys
config = json.load(open('/root/.claude.json'))
mcp = json.load(sys.stdin)
config['projects']['/app']['mcpServers'] = mcp['mcpServers']
json.dump(config, open('/root/.claude.json', 'w'), indent=2)
"The MCP server supports multiple ways to provide AWS credentials:
-
Environment Variables (Global default):
export CLAUDE_CODE_USE_BEDROCK=1 export AWS_REGION=us-east-1 export AWS_ACCESS_KEY_ID=your-key export AWS_SECRET_ACCESS_KEY=your-secret
-
Per-Session Credentials: When creating a session, you can provide specific AWS credentials that will only be used for that session.
-
IAM Roles (if running on AWS): If the MCP server is running on an EC2 instance or ECS, it can use IAM roles.
Your AWS credentials need the following Bedrock permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream"
],
"Resource": [
"arn:aws:bedrock:*::foundation-model/anthropic.claude-*"
]
}
]
}Ensure you have requested and been granted access to Claude models in AWS Bedrock:
- Go to AWS Console > Bedrock > Model access
- Request access to Anthropic Claude models
- Wait for approval (usually automatic for Claude models)
# Clone the repository
git clone https://github.com/democratize-technology/claude-code-mcp.git
cd claude-code-mcp
# Install dependencies
npm install
# Build
npm run build
# Run locally
npm start# Copy environment file
cp .env.example .env
# Edit .env with your API key or AWS credentials
# Start the service
docker-compose up -d
# View logs
docker-compose logs -f mcp-serverDEFAULT_CLAUDE_IMAGE: Docker image to use (default: claude-code-custom:latest)MCP_CLAUDE_DEBUG: Enable debug logging (true/false)DOCKER_HOST: Docker daemon socket (default: unix:///var/run/docker.sock)
The default base image has hardcoded /app paths. We provide a custom image that properly uses /workspace:
# Build the custom image
./build-custom-image.sh
# This creates: claude-code-custom:latestIf you prefer the original image, set:
export DEFAULT_CLAUDE_IMAGE=ghcr.io/zeeno-atl/claude-code:latestANTHROPIC_API_KEY: Your Anthropic API key
CLAUDE_CODE_USE_BEDROCK: Set to "1" to use Bedrock by defaultAWS_REGION: AWS region where Bedrock is availableAWS_ACCESS_KEY_ID: AWS access keyAWS_SECRET_ACCESS_KEY: AWS secret keyAWS_SESSION_TOKEN: AWS session token (for temporary credentials)ANTHROPIC_MODEL: Bedrock model ID for primary modelANTHROPIC_SMALL_FAST_MODEL: Bedrock model ID for small/fast model
- This server requires access to the Docker daemon, which has security implications
- Each Claude Code instance runs in an isolated container
- Containers have limited access to the host system
- Always review the code Claude Code generates before executing
- Consider running the MCP server itself in a container for additional isolation
- When using AWS Bedrock, follow AWS security best practices for credential management
- Ensure Docker is running:
docker ps - Check if the image is accessible:
docker pull ghcr.io/Zeeno-atl/claude-code:latest - Verify your user has Docker permissions
- Check container logs: Use the
get_session_logstool - Verify the container is running: Use
list_sessions - For Anthropic API: Ensure the API key is valid
- For AWS Bedrock: Check AWS credentials and model access
- Verify AWS credentials:
aws sts get-caller-identity - Check Bedrock model access in AWS Console
- Ensure the AWS region supports Bedrock
- Check IAM permissions for Bedrock InvokeModel
- The container runs with your user ID to prevent permission problems
- Ensure the project path is accessible
- Check Docker socket permissions
Contributions are welcome! Please read our Contributing Guidelines first.
- Additional cloud provider support (Google Vertex AI, Azure)
- Enhanced security features
- Performance optimizations
- Additional MCP tools
- Documentation improvements
- ✅ Complete containerization architecture
- ✅ Multi-session management
- ✅ AWS Bedrock support
- ✅ Custom Docker image support
- ✅ File transfer capabilities
- ✅ Session logging
- Comprehensive test coverage
- Google Vertex AI support
- Advanced session orchestration
- Resource usage monitoring
- Session templates
- Kubernetes operator
- Web UI for session management
- Plugin system for custom tools
MIT
- Original claude-code-mcp by Peter Steinberger - for the initial MCP implementation idea
- Zeeno-atl/claude-code - for demonstrating Claude Code containerization
- Anthropic - for Claude and the Model Context Protocol
- AWS - for Bedrock service
- Our contributors and the open source community
- 🐛 Issue Tracker
- 📖 README
Built with ❤️ by Democratize Technology