local-docker-mcp
Enables Docker container management and test execution via MCP tools, supporting image building, container operations, and automated test runs.
README
local-docker-mcp
A Python MCP (Model Context Protocol) server that provides Docker container management and test execution capabilities via FastMCP. Runs as an HTTP server on port 8000 at path /local-docker/mcp/.
Features
- Docker Image Management: Build, pull, list, and remove Docker images
- Container Operations: Run, stop, remove containers; fetch logs; execute commands
- Test Execution: Run tests inside containers with automatic file/folder upload
- Cross-Platform: Works on Windows, macOS, and Linux with platform-appropriate upload strategies
- MCP Protocol: Exposes all functionality as MCP tools for LLM consumption
Tech Stack
- Python ≥3.14
- FastMCP ≥3.4.2 - MCP server framework
- docker ≥7.1.0 - Docker SDK for Python
- uv - Dependency management
Project Structure
local-docker-mcp/
├── main.py # Main MCP server entry point (single file)
├── pyproject.toml # Project config & dependencies
├── uv.lock # Locked dependencies
├── .python-version # Python version pin
├── .gitignore
└── README.md
Quick Start
Prerequisites
- Python ≥3.14
- Docker installed and running
uvpackage manager
Installation
# Clone and navigate to project
cd local-docker-mcp
# Install dependencies
uv sync
# Run the MCP server
uv run main.py
The server starts at http://0.0.0.0:8000/local-docker/mcp/
Development
# Install in editable mode
uv pip install -e .
# Add a new dependency
uv add package-name
uv sync
Available MCP Tools
All tools are decorated with @mcp.tool() and exposed via the MCP protocol.
Image Management
| Tool | Description |
|---|---|
build_image |
Build Docker image from Dockerfile |
pull_image |
Pull Docker image from registry |
remove_image |
Remove Docker image |
list_resources |
List containers and images |
Container Operations
| Tool | Description |
|---|---|
run_container |
Start container from image (requires byagent_ prefix) |
get_container_logs |
Fetch container logs |
stop_and_remove_container |
Stop/remove container, optionally remove image |
exec_in_container |
Execute arbitrary command in container (requires byagent_ prefix) |
Test Execution
| Tool | Description |
|---|---|
run_tests |
Run tests inside container with optional file/folder upload |
run_tests Parameters
container_name(required, must have prefixbyagent_)container_tests_folder(required, absolute path in container)test_file(optional, specific test file)test_node_ids(optional, specific test node IDs)upload_from_folder/upload_from_files(mutually exclusive, for uploading test files)test_runner(default:pytest)test_runner_args(optional, additional test runner arguments)env_vars(optional, environment variables)timeout_seconds(optional, test timeout)
Upload Strategy
upload_from_folder: Copies entire folder contents tocontainer_tests_folderupload_from_files: Copies specific files tocontainer_tests_folder- Mutually exclusive — cannot use both
Architecture
Main Entry Point (main.py)
- FastMCP Server: Named "local-docker-mcp", runs on HTTP transport at
0.0.0.0:8000with path/local-docker/mcp/ - Platform Detection: Detects OS at import time for cross-platform Docker commands
Key Components
_run(cmd, cwd, timeout)— Shell command runner with structured output and timeout handling_fmt(res, label)— Formats command results into readable strings with success/failure icons_upload_files_to_container(files, container_name, dest)— Cross-platform file upload viadocker cp_upload_folder_to_container(folder, container_name, dest)— Cross-platform folder upload:- Windows: Uses
docker cpexclusively - macOS/Linux: Prefers
tarpipe for permissions/symlinks, falls back todocker cp
- Windows: Uses
Container Naming Convention
All container operations require the byagent_ prefix for container names (validated in tools).
Cross-Platform Support
| Platform | Folder Upload Method |
|---|---|
| Windows | docker cp |
| macOS/Linux | tar pipe (preferred), docker cp (fallback) |
License
[Add your license here]
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests (when available)
- Submit a pull request
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。