# MCP gateway image: mcp-proxy + every homelab MCP server preinstalled at a
# pinned version. Clients (Claude Code, Codex, Gemini, Hermes, ...) connect to
# https://mcp.ginnoir.com/servers/<name>/mcp instead of each spawning 9 local
# npx/uvx processes per session.
#
# Built by .gitea/workflows/build-mcp-gateway.yml -> registry.ginnoir.com.
# Portainer only pulls, never builds (see stacks/romhacks note).
#
# Bump a server: change its pin below, push. Nothing resolves at runtime: no
# `npx -y` / `uvx --refresh`, so a broken upstream release can't take a tool
# down until we choose to pull it in.

FROM hashicorp/vault-mcp-server:0.2.0 AS vault

FROM ghcr.io/sparfenyuk/mcp-proxy:v0.15.2-debian-node

# --- Node servers -----------------------------------------------------------
RUN npm install -g --omit=dev \
      @dodwmd/mcparr@0.1.1 \
      bookstack-mcp@5.7.3 \
      ntfy-me-mcp@1.5.0 \
      @davidfuchs/mcp-uptime-kuma@0.7.0 \
 && npm cache clean --force

# --- Python servers (uv tools, binaries land in /usr/local/bin) -------------
ENV UV_TOOL_DIR=/opt/uv-tools \
    UV_TOOL_BIN_DIR=/usr/local/bin \
    UV_PYTHON_PREFERENCE=only-system
RUN uv tool install "mcp-portainer~=2.42.0" \
 && uv tool install --extra-index-url https://nikitatsym.github.io/gitea-mcp/simple "gitea-mcp==1.0.76" \
 && uv tool install --extra-index-url https://nikitatsym.github.io/authentik-mcp/simple "authentik-mcp==1.0.27" \
 && uv tool install --with "mcp<2" \
      "git+https://github.com/darknight/freshrss-mcp-server@d6b3c4c342fc493b95d20a14be8284004e3312aa" \
 && rm -rf /root/.cache/uv

# --- Go server --------------------------------------------------------------
COPY --from=vault /bin/vault-mcp-server /usr/local/bin/vault-mcp-server

COPY servers.json /app/servers.json

# Fail the build (not the deploy) if any entrypoint is missing.
RUN for b in mcparr bookstack-mcp ntfy-me-mcp mcp-uptime-kuma mcp-portainer \
             gitea-mcp authentik-mcp freshrss-mcp vault-mcp-server; do \
      command -v "$b" >/dev/null || { echo "missing $b" >&2; exit 1; }; \
    done

EXPOSE 8096
# ENTRYPOINT (catatonit -- mcp-proxy) is inherited; args come from compose.
