Generated by /repo-architecture skill v2.0.0

Infrastructure MCP Architecture

MCP-compatible server exposing 20 infrastructure management and knowledge tools for the Sanchez Family network. Provides Docker, Traefik, DNS, network, service, documentation, and diagnostic capabilities to any AI agent or MCP client on the network.

The server acts as the single programmatic interface between AI agents (Claude Code, n8n workflows) and the production infrastructure running on rod-server (10.0.1.6). It bridges the gap between natural language tool calls and low-level Docker/Traefik/DNS APIs.

Component Classification

ComponentClassificationRole
src/index.jsPrimaryExpress HTTP server, tool dispatcher, MCP JSON-RPC endpoints
src/tools/docker.jsPrimaryDocker container management (list, logs, stats, compose status)
src/tools/traefik.jsPrimaryTraefik reverse proxy introspection (routers, services, overview)
src/tools/dns.jsPrimaryPi-hole DNS record and statistics queries
src/tools/network.jsSecondaryNetwork inventory, port checks, connectivity tests
src/tools/services.jsSecondaryService catalog and HTTP health checks
src/tools/docs.jsSecondaryArchitecture docs, service info, troubleshooting guides
src/tools/diagnose.jsSecondaryMulti-step service and DNS diagnostics
src/data/infrastructure.jsonAuxiliaryStatic knowledge base (hosts, services, topology, troubleshooting)
Docker SocketExternalDocker Engine API via /var/run/docker.sock
Traefik APIExternalTraefik dashboard API at http://traefik:8080/api
Pi-holeExternalDNS config files (read-only mounts) + HTTP API
MCP ProxyExternalUpstream proxy at mcp.home:3100 (API key auth)
Tools
20
Tool Categories
7
Runtime
Node.js 20
Port
3200
Source Files
9
Network
hosting_web

2. Runtime Architecture

Diagram A: Runtime Request Flow

HTTP + API key HTTP direct workflow call POST /call docker.sock HTTP :8080 file read static JSON Claude Code MCP client / CLI AI infrastructure agent n8n Workflows Automation / HTTP Scheduled health checks MCP Proxy Node.js / :3100 API key auth gateway Infrastructure MCP Server Node.js 20 / Express / :3200 20 tools across 7 categories Docker Engine Unix socket / dockerode 50+ containers Traefik API HTTP / :8080/api Routers, services, middleware Pi-hole Config files + HTTP API DNS records, query stats infrastructure.json Static knowledge base (built into image) CLAUDE.md Mounted docs (read-only) Legend Primary path Backend call Async / static

Request Flow

  1. Claude Code (or any MCP client) sends an HTTP POST to /call with a tool name and parameters -- either directly to infra-mcp.home:3200 or via the MCP Proxy at mcp.home:3100 (which adds API key authentication).
  2. The Express server (index.js) dispatches the request to the appropriate tool module based on the tool name prefix (docker, traefik, dns, network, service, docs, diagnose).
  3. Each tool module queries its backend: Docker tools use the dockerode library over the Unix socket, Traefik tools query the HTTP dashboard API, DNS tools read mounted config files or the Pi-hole HTTP API, and knowledge tools read from the static infrastructure.json.
  4. Results are returned as MCP-compatible content blocks ({"content": [{"type": "text", "text": "..."}]}), ready for consumption by any MCP client.

3. Public Interfaces

HTTP Endpoints

MethodPathAuthDescription
GET/healthNoneServer status, tool count, uptime
GET/toolsNoneList all 20 tools with MCP schemas
GET/docsNoneAuto-generated API documentation
POST/callNone (direct) / API key (proxy)Execute a tool: {"tool":"name","params":{}}
POST/tools/listNoneMCP JSON-RPC 2.0 tool listing
POST/tools/callNoneMCP JSON-RPC 2.0 tool execution

Access URLs

MethodURLAuth
Direct (LAN)https://infra-mcp.homeNone
Direct (public)https://infra-mcp.sanchezfamily.caNone
Via MCP Proxyhttps://mcp.home/mcp/infra/...X-API-Key header

MCP Tools (20)

Docker Tools (4)

Tool NameDescriptionParameters
docker_list_containersList all Docker containers with status, ports, networks, and image infoall (boolean, optional)
docker_container_logsGet recent logs from a Docker containername (string, required), lines (number, optional)
docker_container_statsGet CPU, memory, and network stats for a containername (string, required)
docker_compose_statusGet status of all Docker Compose projects and containersNone

Traefik Tools (3)

Tool NameDescriptionParameters
traefik_list_routersList all HTTP routers with rules, entrypoints, and TLS configNone
traefik_list_servicesList all services with backend URLs and health statusNone
traefik_overviewDashboard overview with router, service, middleware countsNone

DNS Tools (3)

Tool NameDescriptionParameters
dns_list_recordsList all Pi-hole custom DNS records (IP-to-domain)None
dns_list_local_domainsList all local .home domain mappings from dnsmasqNone
dns_query_statsPi-hole DNS query statistics and blocking statusNone

Network Tools (3)

Tool NameDescriptionParameters
network_inventoryFull network inventory: hosts, IPs, topology, firewall rulesNone
network_check_portCheck if a port is open on a host (TCP connect, 3s timeout)host (string, required), port (number, required)
network_test_connectivityTest connectivity via ping or HTTP requesthost (string, required), method (string, optional)

Service Tools (2)

Tool NameDescriptionParameters
service_catalogComplete service catalog with names, types, URLs, portsfilter (string, optional)
service_health_checkHTTP health check on any URL with status code and timingurl (string, required)

Documentation Tools (3)

Tool NameDescriptionParameters
docs_architectureFull architecture docs: topology, request flow, TLS, firewallNone
docs_service_infoDetailed info about a specific service (config, URLs, management commands)service (string, required)
docs_troubleshootingTroubleshooting guides for common infrastructure issuestopic (string, optional)

Diagnostic Tools (2)

Tool NameDescriptionParameters
diagnose_serviceComprehensive diagnostics: container status, port, HTTP, Traefik routingservice (string, required)
diagnose_dns_resolutionTest full DNS resolution chain: Pi-hole, registration, external DNS, HTTPSdomain (string, required)

4. Repository Structure

_infra_mcp/
  CLAUDE.md               # Comprehensive API docs and usage guide
  Dockerfile              # Node.js 20 Alpine, production build
  package.json            # 3 dependencies (express, axios, dockerode)
  docs/
    ARCHITECTURE.html     # Previous architecture doc
  src/
    index.js              # Express server, tool dispatcher, MCP endpoints
    data/
      infrastructure.json # Static knowledge base (hosts, services, topology)
    tools/
      docker.js           # 4 tools: list, logs, stats, compose status
      traefik.js          # 3 tools: routers, services, overview
      dns.js              # 3 tools: records, local domains, query stats
      network.js          # 3 tools: inventory, port check, connectivity
      services.js         # 2 tools: catalog, health check
      docs.js             # 3 tools: architecture, service info, troubleshooting
      diagnose.js         # 2 tools: service diagnostics, DNS resolution
        

Module Architecture

Each tool module exports a uniform interface:

  • tools -- Array of MCP tool definitions with name, description, and inputSchema
  • call(name, params) -- Async function that dispatches to the correct handler by tool name

The main index.js aggregates all modules into a flat registry, mapping each tool name to its module's call function. This keeps tool modules fully independent with no cross-dependencies.

5. Deployment

Docker Container

PropertyValue
Image basenode:20-alpine
Container nameinfra-mcp
Port3200 (internal)
Networkhosting_web
Compose file/home/rod/_rod/_hosting/docker-compose.agent-system.yml
Source directory/home/rod/_rod/_infra_mcp
MCP Proxy backendRegistered as infra in MCP_SERVERS env var

Volume Mounts

Host PathContainer PathModePurpose
/var/run/docker.sock/var/run/docker.sockRead-onlyDocker Engine API access
Pi-hole custom.list/pihole-config/custom.listRead-onlyDNS record listing
Pi-hole 02-local-domains.conf/pihole-config/02-local-domains.confRead-onlyLocal domain listing
CLAUDE.md/docs/CLAUDE.mdRead-onlyArchitecture documentation source

Environment Variables

VariableDefaultDescription
PORT3200HTTP server listen port
TRAEFIK_API_URLhttp://traefik:8080/apiTraefik dashboard API base URL
PIHOLE_CUSTOM_LIST/pihole-config/custom.listPath to Pi-hole custom DNS records
PIHOLE_DNSMASQ_CONF/pihole-config/02-local-domains.confPath to dnsmasq local domain config
DOCS_DIR/docsDirectory containing CLAUDE.md

Management Commands

# Build
cd /home/rod/_rod/_hosting
docker compose -f docker-compose.agent-system.yml --env-file /home/rod/_rod/.env build infra-mcp

# Start / Restart
docker compose -f docker-compose.agent-system.yml --env-file /home/rod/_rod/.env up -d infra-mcp

# Logs
docker logs -f infra-mcp

# Health check
curl -sk https://infra-mcp.home/health

# Local development
cd /home/rod/_rod/_infra_mcp
npm install && PORT=3200 node src/index.js
        

Traefik Routing

Three routers are defined in dynamic.yml:

  • infra-mcp-http -- HTTP redirect for both domains
  • infra-mcp -- HTTPS public (infra-mcp.sanchezfamily.ca, Let's Encrypt)
  • infra-mcp-local -- HTTPS local (infra-mcp.home, local CA wildcard)

Middleware: lan-only (admin access restricted to LAN IPs) + security-headers

6. Dependencies

NPM Packages (Production)

PackageVersionPurposeUsed By
express^4.18.0HTTP server and routing frameworkindex.js
axios^1.6.0HTTP client for Traefik API, Pi-hole API, health checkstraefik.js, dns.js, services.js, diagnose.js, network.js
dockerode^4.0.0Docker Engine API client via Unix socketdocker.js, diagnose.js

Node.js Built-in Modules

ModuleUsed ByPurpose
fsdns.js, docs.jsRead Pi-hole config files and CLAUDE.md
pathdns.js, docs.jsFile path resolution
netnetwork.js, diagnose.jsTCP socket connections for port checks
child_processnetwork.js, diagnose.jsExec ping and dig commands
httpsservices.js, diagnose.js, network.jsTLS agent with rejectUnauthorized: false for self-signed certs

External Services

ServiceConnectionRequiredFailure Impact
Docker Engine/var/run/docker.sockYesAll docker_* tools and container diagnostics fail
Traefik Dashboard APIhttp://traefik:8080/apiYesAll traefik_* tools and routing diagnostics fail
Pi-hole Config FilesMounted at /pihole-config/Partialdns_list_records and dns_list_local_domains return errors; other tools unaffected
Pi-hole HTTP APIhttp://pihole:80/admin/api.phpPartialdns_query_stats fails; may require auth token
Network (ping/dig)System commandsOptionalnetwork_test_connectivity and diagnose_dns_resolution may degrade

7. Data Sources

SourceTypeMount / ConnectionTools Using It
Docker SocketUnix socket/var/run/docker.sock (read-only)docker_*, diagnose_service
Traefik APIHTTPhttp://traefik:8080/api (Docker network)traefik_*, diagnose_*
Pi-hole custom.listFile/pihole-config/custom.list (read-only)dns_list_records
Pi-hole dnsmasq confFile/pihole-config/02-local-domains.conf (read-only)dns_list_local_domains
Pi-hole HTTP APIHTTPhttp://pihole:80/admin/api.php (Docker network)dns_query_stats
infrastructure.jsonStatic JSONBuilt into image at src/data/network_*, service_*, docs_*, diagnose_*
CLAUDE.mdFile/docs/CLAUDE.md (read-only mount)docs_architecture
Updating the knowledge base: The static infrastructure.json is baked into the Docker image at build time. After adding new hosts, services, or changing network configuration, edit src/data/infrastructure.json, rebuild the image, and restart the container.

8. Constraints and Risks

ItemSeverityDescription
Docker socket access Medium Read-only mount of /var/run/docker.sock allows container inspection but not management. The socket is still a privileged resource -- container compromise could read container metadata.
No authentication on direct access Medium Direct access to infra-mcp.home has no API key requirement. Mitigated by Traefik lan-only middleware restricting access to 10.0.1.0/24 and Docker subnets.
Static knowledge base Low infrastructure.json is baked into the image. Adding new services requires a rebuild. Network/service changes are not reflected until the image is rebuilt.
Pi-hole API auth Low dns_query_stats may fail if Pi-hole requires an authentication token. The tool gracefully returns an error message.
Shell command injection Low network_test_connectivity and diagnose_dns_resolution pass user input to exec() for ping/dig. Input validation is minimal -- currently relies on LAN-only access restriction.
No tests Low No unit or integration tests. The server is validated through manual health checks and end-to-end tool calls.