MCP Container Tools
An MCP server for managing and monitoring Docker, Docker Compose, and Kubernetes environments alongside Azure Application Insights. It enables advanced log filtering, container lifecycle management, and querying of cloud application traces and metrics.
README
🐳 MCP Container Tools
A Model Context Protocol (MCP) server for Docker, Kubernetes, and Azure Application Insights with advanced log filtering and monitoring capabilities.
✨ Features
- 🐳 Docker — Container logs, inspect, exec, list containers
- 🐙 Docker Compose — Service logs, start/stop/restart services
- ☸️ Kubernetes — Pod logs, deployment logs, events, exec into pods
- ☁️ Azure Application Insights — Exceptions, traces, requests, metrics
- 🔍 Log Filtering — Filter by log level, regex patterns, exclude patterns
- 🌐 Remote Support — Connect to remote Docker hosts via SSH or TCP
📋 Requirements
| Requirement | Version | Required For |
|---|---|---|
| 🐍 Python | 3.11+ | All |
| 🐳 Docker | Latest | Docker tools |
| ☸️ kubectl | Latest | Kubernetes tools |
| ☁️ Azure CLI | Latest | Azure tools (optional) |
🚀 Installation
📦 Quick Install (recommended)
# Basic installation
pip install mcp-container-tools
# With Azure Application Insights support
pip install mcp-container-tools[azure]
🐙 Install from GitHub
# Latest version from GitHub
pip install git+https://github.com/simseksem/mcp-container-tools.git
# With Azure support
pip install "mcp-container-tools[azure] @ git+https://github.com/simseksem/mcp-container-tools.git"
🔧 Install from source (for development)
git clone https://github.com/simseksem/mcp-container-tools.git
cd mcp-container-tools
pip install -e ".[all]"
✅ Verify installation
mcp-server --help
⚙️ Configuration
🖥️ Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"container-tools": {
"command": "/path/to/mcp-container-tools/.venv/bin/python",
"args": ["-m", "mcp_server.server"],
"env": {
"AZURE_LOG_ANALYTICS_WORKSPACE_ID": "your-workspace-id",
"AZURE_APP_INSIGHTS_RESOURCE_ID": "/subscriptions/.../resourceGroups/.../providers/microsoft.insights/components/..."
}
}
}
}
💻 Claude Code
Add to ~/.claude/settings.json or create .mcp.json in your project:
{
"mcpServers": {
"container-tools": {
"command": "/path/to/mcp-container-tools/.venv/bin/python",
"args": ["-m", "mcp_server.server"]
}
}
}
☁️ Azure Authentication
Azure tools use DefaultAzureCredential which supports:
- Azure CLI (
az login) - Environment variables
- Managed Identity
- Visual Studio Code
# Easiest: Login with Azure CLI
az login
📖 Usage Examples
🐳 Docker
# Read container logs
docker_logs(container="my-app", tail=100)
# Read logs from last 30 minutes
docker_logs(container="my-app", since="30m")
# Filter by log level (only errors and above)
docker_logs(container="my-app", min_level="error")
# Search for patterns
docker_logs(container="my-app", pattern="timeout|connection refused")
# Exclude health checks
docker_logs(container="my-app", exclude_pattern="GET /health")
# Remote Docker host via SSH
docker_logs(container="my-app", host="ssh://user@server.com")
# List containers
docker_ps(all=True)
🐙 Docker Compose
# Read service logs
compose_logs(service="api", tail=200)
# Read all services logs
compose_logs(project_dir="/path/to/project")
# Service management
compose_up(service="api", project_dir="/path/to/project")
compose_down(project_dir="/path/to/project")
compose_restart(service="api")
☸️ Kubernetes
# Read pod logs
k8s_logs(pod="api-7d4b8c6f9-x2k4m", namespace="production")
# Read logs from all pods in a deployment
k8s_deployment_logs(deployment="api", namespace="production")
# Filter logs
k8s_logs(pod="api-*", min_level="warn", pattern="database")
# Use different context
k8s_logs(pod="my-pod", context="production-cluster", namespace="backend")
# List pods
k8s_pods(namespace="all", selector="app=api")
# Get events
k8s_events(namespace="production")
# Execute command in pod
k8s_exec(pod="api-xyz", command="printenv", namespace="production")
☁️ Azure Application Insights
# Query exceptions from last hour
azure_exceptions(timespan="PT1H", limit=50)
# Get only critical exceptions
azure_exceptions(severity="critical", search="NullReference")
# Query application traces
azure_traces(timespan="PT1H", severity="error")
# Query HTTP requests
azure_requests(timespan="PT1H", failed_only=True)
# Get slow requests (>1 second)
azure_requests(min_duration_ms=1000, limit=20)
# Query external dependencies (SQL, HTTP, etc.)
azure_dependencies(timespan="PT1H", failed_only=True, type_filter="SQL")
# Get metrics
azure_metrics(metric_name="requests/count", timespan="P1D", interval="PT1H")
# Query availability test results
azure_availability(timespan="P1D", failed_only=True)
# Run custom Kusto query
azure_query(query="""
requests
| where success == false
| summarize count() by bin(timestamp, 1h), resultCode
| order by timestamp desc
""", timespan="P1D")
🔍 Log Filtering Options
All log tools support these filtering options:
| Option | Description | Example |
|---|---|---|
min_level |
Minimum log level | "error", "warn", "info" |
pattern |
Regex to include | "error|exception" |
exclude_pattern |
Regex to exclude | "health.*check" |
context_lines |
Lines around matches | 5 |
Supported log levels: trace → debug → info → warn → error → fatal
⏱️ Timespan Format (Azure)
Azure tools use ISO 8601 duration format:
| Format | Duration |
|---|---|
PT1H |
1 hour |
PT30M |
30 minutes |
P1D |
1 day |
P7D |
7 days |
🛠️ Available Tools
🐳 Docker Tools
| Tool | Description |
|---|---|
docker_logs |
📄 Read container logs with filtering |
docker_ps |
📋 List containers |
docker_inspect |
🔎 Get container details |
docker_exec |
⚡ Execute command in container |
🐙 Docker Compose Tools
| Tool | Description |
|---|---|
compose_logs |
📄 Read service logs |
compose_ps |
📋 List services |
compose_up |
▶️ Start services |
compose_down |
⏹️ Stop services |
compose_restart |
🔄 Restart services |
☸️ Kubernetes Tools
| Tool | Description |
|---|---|
k8s_logs |
📄 Read pod logs |
k8s_deployment_logs |
📚 Read deployment logs |
k8s_pods |
📋 List pods |
k8s_describe |
🔎 Describe pod |
k8s_exec |
⚡ Execute in pod |
k8s_events |
📢 Get events |
k8s_contexts |
🌐 List contexts |
☁️ Azure Application Insights Tools
| Tool | Description |
|---|---|
azure_query |
🔍 Run custom Kusto queries |
azure_exceptions |
❌ Query application exceptions |
azure_traces |
📝 Query application traces |
azure_requests |
🌐 Query HTTP requests |
azure_dependencies |
🔗 Query external dependencies |
azure_metrics |
📊 Query metrics |
azure_availability |
✅ Query availability tests |
👨💻 Development
Install dev dependencies
pip install -e ".[all]"
Run tests
pytest
Linting and type checking
ruff check .
mypy src/
📁 Project Structure
mcp-container-tools/
├── 📂 src/mcp_server/
│ ├── 📄 __init__.py
│ ├── 📄 server.py # Main server entry point
│ ├── 📂 tools/
│ │ ├── 🐳 docker.py # Docker tools
│ │ ├── 🐙 docker_compose.py # Compose tools
│ │ ├── ☸️ kubernetes.py # K8s tools
│ │ ├── ☁️ azure_insights.py # Azure App Insights
│ │ └── 📁 file_operations.py # File tools
│ ├── 📂 resources/
│ │ ├── ⚙️ config.py # Config resources
│ │ └── 📊 data.py # Data resources
│ ├── 📂 prompts/
│ │ └── 📝 templates.py # Prompt templates
│ └── 📂 utils/
│ └── 🔍 log_filter.py # Log filtering
├── 📂 tests/
├── 📄 pyproject.toml
└── 📄 README.md
🔐 Environment Variables
| Variable | Description |
|---|---|
AZURE_LOG_ANALYTICS_WORKSPACE_ID |
Azure Log Analytics workspace ID |
AZURE_APP_INSIGHTS_RESOURCE_ID |
Azure Application Insights resource ID |
📄 License
MIT License - see LICENSE for details.
<p align="center"> Made with ❤️ for the MCP community </p>
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。