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>
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
E2B
Using MCP to run code via e2b.