Skip to main content
Glama
TDHster

docker-logs-mcp

by TDHster
README.md
# docker-logs-mcp

MCP server for viewing Docker container logs on a remote VPS via SSH.
Tools optimized for tokens efficent

## Requirements

- Python ≥ 3.12
- [uv](https://docs.astral.sh/uv/) (package installer)
- SSH key access to the VPS

## Quick Start

```bash
cd docker-logs-mcp
uv sync
```

## Connecting to Cline

Add to Cline's MCP servers:

```json
{
  "docker-logs": {
    "command": "uv",
    "args": ["run", "--directory", "/path/to/docker-logs-mcp", "python", "-m", "src.docker_mcp"]
  }
}
```

Where to add:
- **VS Code**: `~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json` or in Cline MCP config JSON
- **Cline Desktop**: Settings → MCP Servers

## Project Configuration

Each Docker project must have a `.deploy` file in its root:

```bash
SSH_HOST=user@server.com
PROJECT_DIR=/opt/project
SSH_PORT=22          # optional, defaults to 22
```

This file is also used by the deploy script (`source ./.deploy`).

## Environment Variables

| Variable | Default | Description |
|----------|---------|-------------|
| `SSH_KEY` | `~/.ssh/id_ed25519` | Path to SSH private key |

## Tools

| Tool | Parameters | Description | Server Command |
|------|-----------|-------------|---------------|
| `docker_logs` | `project` (req.), `service` (all), `tail` (500), `errors_only` (true), `max_length` (300) | Latest Docker service logs. By default shows only WARNING/ERROR/CRITICAL, lines truncated to 300 chars — saves tokens | `cd $PROJECT_DIR && docker compose logs --tail=N --no-color SERVICE` |
| `docker_ps` | `project` (req.) | Status of all project Docker containers | `cd $PROJECT_DIR && docker compose ps --format json` |
| `docker_stats` | `project` (req.) | CPU and RAM usage of containers | `cd $PROJECT_DIR && docker stats --no-stream --no-trunc --format json` |
| `server_info` | `project` (req.) | General VPS info: uptime, disk (`df -h /`), memory (`free -h`), container status | `uptime && df -h / && free -h && cd $PROJECT_DIR && docker compose ps` |
| `docker_grep` | `project` (req.), `pattern` (req.), `service` (all), `tail` (500), `context` (0), `ignore_case` (false) | Search logs with `grep -E`. More token-efficient than `docker_logs` for targeted search — returns only matching lines | `cd $PROJECT_DIR && docker compose logs --tail=N --no-color SERVICE \| grep -E [flags] 'PATTERN'` |

TDQS

A4.2/5.0

Scored across 5 tools

Disambiguation4/5

Most tools are distinct: docker_ps, docker_stats, and server_info each serve clear different purposes. docker_logs and docker_grep both deal with logs, but their descriptions clearly separate recent-error viewing from pattern searching, so ambiguity is mild.

Naming Consistency4/5

Four tools use the consistent 'docker_' prefix and short noun pattern (docker_logs, docker_ps, docker_grep, docker_stats). server_info breaks the pattern by not using the 'docker_' prefix, creating a minor inconsistency.

Tool Count5/5

With five tools, the set is well-scoped for a Docker log and monitoring server. Each tool covers a distinct need without redundancy or unnecessary bloat.

Completeness4/5

The set covers the core domain: viewing logs, searching logs, listing containers, checking resource usage, and overall server health. Minor gaps might include container lifecycle actions, but those are outside the apparent logging/monitoring purpose.

Maintenance

ActivityStale
ResponsivenessNo issues