Skip to main content

MCP server for Docker, Kubernetes, and Azure Application Insights

Project description

๐Ÿณ MCP Container Tools

PyPI version Python 3.11+ License: MIT MCP

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.


Made with โค๏ธ for the MCP community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_container_tools-0.1.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_container_tools-0.1.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file mcp_container_tools-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_container_tools-0.1.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for mcp_container_tools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fd2cfce61bbf35e9971c9c0efd7f1a36b3d2dcc4911854937abef37c3e228c0d
MD5 aed164c60414139b3e8ea07d9b8fc729
BLAKE2b-256 ed9c4fe89d363e7150968eba8779964a0131721584de68dec84804f1de1daf9e

See more details on using hashes here.

File details

Details for the file mcp_container_tools-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_container_tools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c272620fb3559b653571fabedac8c4c5ff204c400d72b75995d16d6a407b6b80
MD5 e4c2a297fe5b4b56f4da8dea047cfa1e
BLAKE2b-256 fed0f93bcc480929ebbf17b52fe68075e6d64ed94e8463a4b948be446f93de3f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page