feat: add MCP server with stdio transport for LLM integration#4495
feat: add MCP server with stdio transport for LLM integration#4495
Conversation
Implements a Model Context Protocol (MCP) server as a new `dozzle mcp` subcommand using the mark3labs/mcp-go library. Exposes four tools: - list_containers: List all containers across hosts with optional state filter - get_container_logs: Fetch recent logs from a container (configurable time range) - container_action: Start/stop/restart containers - list_hosts: List all connected Docker hosts Uses stdio transport for seamless integration with Claude and other MCP clients. https://claude.ai/code/session_01YRr9yDHxRJBKxBbjARpRJM
ReviewBug: RawLogs called with zero 'to' time — internal/mcp/server.go:201 The call uses time.Time{} as the 'to' argument: time.Time{} formats as "0001-01-01T00:00:00Z" and is passed to Docker's Until option (see docker/client.go:292). Docker treats this as a timestamp in year 0001 — logs will always be empty. Should be time.Now(), matching the pattern in web/download.go:194. Minor issues:
|
Uses StreamableHTTPServer for remote access. Listens on :8081 by default, configurable via --mcp-addr flag or DOZZLE_MCP_ADDR env var. https://claude.ai/code/session_01YRr9yDHxRJBKxBbjARpRJM
ReviewBug: reader, err := containerSvc.RawLogs(ctx, since, time.Time{}, stdType)
PR description mismatch: Title and description say "stdio transport" but the implementation uses Minor issues:
|
Exposes the last ~5 minutes of container stats history (up to 300 data points) including CPU percentage, memory percentage, and memory usage. https://claude.ai/code/session_01YRr9yDHxRJBKxBbjARpRJM
|
Review: MCP Server Implementation Bug - garbled log output: Mismatch - stdio vs HTTP: Security - no auth on MCP endpoint: go.mod placement: Naming - No tests added for the new package. |
Switch from RawLogs to LogsBetweenDates so the MCP get_container_logs tool returns Dozzle's processed log events with detected log levels, JSON parsing, and multi-line grouping. Output is JSONL with structured entries containing timestamp, level, stream, type, and parsed message. https://claude.ai/code/session_01YRr9yDHxRJBKxBbjARpRJM
ReviewSecurity - Critical
Bug - Double JSON marshaling ( Off-by-one in size limit ( Misleading method name ( Description vs implementation mismatch Stats may be empty ( Minor
|
ReviewPR description mismatch (title says "stdio" but implementation is HTTP) No authentication on MCP HTTP server — Stats may always be empty — Double JSON-encoding in Minor
|
ReviewTransport mismatch — title/description say "stdio transport" but Misleading method name — Double JSON serialization — Label secret exposure —
No tests — |
Implements a Model Context Protocol (MCP) server as a new
dozzle mcpsubcommand using the mark3labs/mcp-go library. Exposes four tools:
Uses stdio transport for seamless integration with Claude and other MCP clients.
https://claude.ai/code/session_01YRr9yDHxRJBKxBbjARpRJM