7.8 KiB
MC - Monadical Container Tool
MC (Monadical Container) is a command-line tool for managing ephemeral containers that run AI tools and development environments. It works with both local Docker and a dedicated remote web service that manages containers in a Docker-in-Docker (DinD) environment. MC also supports connecting to MCP (Model Control Protocol) servers to extend AI tools with additional capabilities.
Requirements
Installation
# Clone the repository
git clone https://github.com/monadical/mcontainer.git
# Install the tool locally
# (with editable, so you can update the code and work with it)
cd mcontainer
uv tool install --with-editable . .
# Then you could use the tool as `mc`
mc --help
Basic Usage
# Create a new session with the default driver
# mc create session -- is the full command
mc
# List all active sessions
mc session list
# Connect to a specific session
mc session connect SESSION_ID
# Close a session when done
mc session close SESSION_ID
# Create a session with a specific driver
mc session create --driver goose
# Create a session with environment variables
mc session create -e VAR1=value1 -e VAR2=value2
# Mount custom volumes (similar to Docker's -v flag)
mc session create -v /local/path:/container/path
mc session create -v ~/data:/data -v ./configs:/etc/app/config
# Connect to external Docker networks
mc session create --network teamnet --network dbnet
# Connect to MCP servers for extended capabilities
mc session create --mcp github --mcp jira
# Shorthand for creating a session with a project repository
mc github.com/username/repo
# Shorthand with MCP servers
mc github.com/username/repo --mcp github
Driver Management
MC includes a driver management system that allows you to build, manage, and use Docker images for different AI tools:
# List available drivers
mc driver list
# Get detailed information about a driver
mc driver info goose
# Build a driver image
mc driver build goose
# Build and push a driver image
mc driver build goose --push
Drivers are defined in the mcontainer/drivers/ directory, with each subdirectory containing:
Dockerfile: Docker image definitionentrypoint.sh: Container entrypoint scriptmc-init.sh: Standardized initialization scriptmc-driver.yaml: Driver metadata and configurationREADME.md: Driver documentation
MC automatically discovers and loads driver definitions from the YAML files.
Development
# Run the tests
uv run -m pytest
# Run linting
uvx ruff check .
# Run type checking
uvx mypy .
# Format code
uvx ruff format .
Configuration
MC supports user-specific configuration via a YAML file located at ~/.config/mc/config.yaml. This allows you to set default values and configure service credentials.
Managing Configuration
# View all configuration
mc config list
# Get a specific configuration value
mc config get langfuse.url
# Set configuration values
mc config set langfuse.url "https://cloud.langfuse.com"
mc config set langfuse.public_key "pk-lf-..."
mc config set langfuse.secret_key "sk-lf-..."
# Set API keys for various services
mc config set openai.api_key "sk-..."
mc config set anthropic.api_key "sk-ant-..."
# Reset configuration to defaults
mc config reset
Default Networks Configuration
You can configure default networks that will be applied to every new session:
# List default networks
mc config network list
# Add a network to defaults
mc config network add teamnet
# Remove a network from defaults
mc config network remove teamnet
Default Volumes Configuration
You can configure default volumes that will be automatically mounted in every new session:
# List default volumes
mc config volume list
# Add a volume to defaults
mc config volume add /local/path:/container/path
# Remove a volume from defaults (will prompt if multiple matches found)
mc config volume remove /local/path
Default volumes will be combined with any volumes specified using the -v flag when creating a session.
External Network Connectivity
MC containers can connect to external Docker networks, allowing them to communicate with other services in those networks:
# Create a session connected to external networks
mc session create --network teamnet --network dbnet
Important: Networks must be "attachable" to be joined by MC containers. Here's how to create attachable networks:
# Create an attachable network with Docker
docker network create --driver bridge --attachable teamnet
# Example docker-compose.yml with attachable network
# docker-compose.yml
version: '3'
services:
web:
image: nginx
networks:
- teamnet
networks:
teamnet:
driver: bridge
attachable: true # This is required for MC containers to connect
Service Credentials
Service credentials like API keys configured in ~/.config/mc/config.yaml are automatically passed to containers as environment variables:
| Config Setting | Environment Variable |
|---|---|
langfuse.url |
LANGFUSE_URL |
langfuse.public_key |
LANGFUSE_INIT_PROJECT_PUBLIC_KEY |
langfuse.secret_key |
LANGFUSE_INIT_PROJECT_SECRET_KEY |
openai.api_key |
OPENAI_API_KEY |
anthropic.api_key |
ANTHROPIC_API_KEY |
openrouter.api_key |
OPENROUTER_API_KEY |
MCP Server Management
MCP (Model Control Protocol) servers provide tool-calling capabilities to AI models, enhancing their ability to interact with external services, databases, and systems. MC supports multiple types of MCP servers:
- Remote HTTP SSE servers - External MCP servers accessed over HTTP
- Docker-based MCP servers - Local MCP servers running in Docker containers
- Proxy-based MCP servers - Local MCP servers with an SSE proxy for stdio-to-SSE conversion
Managing MCP Servers
# List all configured MCP servers and their status
mc mcp list
# View detailed status of an MCP server
mc mcp status github
# Start/stop/restart individual MCP servers
mc mcp start github
mc mcp stop github
mc mcp restart github
# Start all MCP servers at once
mc mcp start --all
# Stop and remove all MCP servers at once
mc mcp stop --all
# Run the MCP Inspector to visualize and interact with MCP servers
# It automatically joins all MCP networks for seamless DNS resolution
# Uses two ports: frontend UI (default: 5173) and backend API (default: 3000)
mc mcp inspector
# Run the MCP Inspector with custom ports
mc mcp inspector --client-port 6173 --server-port 6174
# Run the MCP Inspector in detached mode
mc mcp inspector --detach
# Stop the MCP Inspector
mc mcp inspector --stop
# View MCP server logs
mc mcp logs github
# Remove an MCP server configuration
mc mcp remove github
Adding MCP Servers
MC supports different types of MCP servers:
# Add a remote HTTP SSE MCP server
mc mcp remote add github http://my-mcp-server.example.com/sse --header "Authorization=Bearer token123"
# Add a Docker-based MCP server
mc mcp docker add github mcp/github:latest --command "github-mcp" --env GITHUB_TOKEN=ghp_123456
# Add a proxy-based MCP server (for stdio-to-SSE conversion)
mc mcp proxy add github ghcr.io/mcp/github:latest --proxy-image ghcr.io/sparfenyuk/mcp-proxy:latest --command "github-mcp" --sse-port 8080
Using MCP Servers with Sessions
MCP servers can be attached to sessions when they are created:
# Create a session with a single MCP server
mc session create --mcp github
# Create a session with multiple MCP servers
mc session create --mcp github --mcp jira
# Using MCP with a project repository
mc github.com/username/repo --mcp github
MCP servers are persistent and can be shared between sessions. They continue running even when sessions are closed, allowing for efficient reuse across multiple sessions.