Skip to main content
Glama
mcp-docker-compose

mcp-docker-compose

by Ricrdoss
README.md
# mcp-docker-compose

An open-source Model Context Protocol (MCP) server that gives AI coding agents safe, structured access to local Docker Compose services, logs, configuration inspection, and service restarts.

## Security Guarantees

- **No shell execution**: All `docker compose` commands are invoked directly via `node:child_process` `execFile` with explicit argument arrays—never `exec` or shell string concatenation. Flag-like arguments (`-...`) are rejected.
- **Automatic secret redaction**: Sensitive environment variables (`PASSWORD`, `SECRET`, `TOKEN`, `API_KEY`, `PRIVATE_KEY`, `ACCESS_KEY`, `AUTH`, `DSN`, `DATABASE_URL`), bearer tokens, and embedded URI credentials (e.g., `postgres://user:pass@host`) are automatically replaced with `[REDACTED]` in both `compose_inspect_config` and `compose_get_logs`.
- **Non-destructive toolset**: Exposes only read/inspection tools and single-service graceful restarts—no `down`, `rm`, `prune`, or `exec` operations.
- **Output & timeout safety**: Commands enforce configurable timeouts and `maxBuffer` limits, and log output is capped at 20,000 characters.

## Quick Start

Run directly with `npx` (requires Node.js >= 20 and Docker Compose v2):

```bash
npx -y mcp-docker-compose
```

## Client Configuration

### Claude Code

Add to your project `.mcp.json` or `~/.claude.json`:

```json
{
  "mcpServers": {
    "docker-compose": {
      "command": "npx",
      "args": ["-y", "mcp-docker-compose"]
    }
  }
}
```

### Claude Desktop

Add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "docker-compose": {
      "command": "npx",
      "args": ["-y", "mcp-docker-compose"]
    }
  }
}
```

### Cursor

Add to `.cursor/mcp.json` in your project or global Cursor settings:

```json
{
  "mcpServers": {
    "docker-compose": {
      "command": "npx",
      "args": ["-y", "mcp-docker-compose"]
    }
  }
}
```

## Tools Reference

| Tool | Description | Parameters |
| --- | --- | --- |
| `compose_list_services` | Lists services with state, health status, and published ports. | `composeFile?: string`, `cwd?: string` |
| `compose_get_logs` | Fetches recent logs with secret redaction, optional error filtering, and 20k-char truncation. | `service?: string`, `tail?: number` (1–500, default `100`), `errorsOnly?: boolean` (default `false`), `composeFile?: string`, `cwd?: string` |
| `compose_inspect_config` | Inspects resolved service config (`image`, redacted `environment`, `ports`, `depends_on`). | `service?: string`, `composeFile?: string`, `cwd?: string` |
| `compose_restart_service` | Gracefully restarts a single service with a shutdown timeout. | `service: string` (required), `timeoutSeconds?: number` (1–120, default `10`), `composeFile?: string`, `cwd?: string` |

## Development

```bash
npm install
npm run lint
npm run build
npm test
```

## License

[MIT](./LICENSE)