# Sandbox image for scanning UNTRUSTED MCP servers.
#
# Running a random community MCP server means executing third-party code. This image lets you do
# it inside an ephemeral, host-isolated container (run it on a Linux VM via Colima/Docker Desktop
# so even a malicious package can't touch your real machine): no host filesystem is mounted, the
# container is thrown away after each scan (--rm), and the server runs as a non-root user.
#
# It bundles node (npx), uv (uvx) and RedCell, so you can scan npm- or PyPI-published servers.
FROM python:3.12-slim

RUN apt-get update \
 && apt-get install -y --no-install-recommends nodejs npm ca-certificates \
 && rm -rf /var/lib/apt/lists/*

# uv/uvx for scanning PyPI-published servers.
RUN pip install --no-cache-dir uv

WORKDIR /app
COPY pyproject.toml README.md ./
COPY redcell ./redcell
COPY examples ./examples
RUN pip install --no-cache-dir .

# Drop privileges: the untrusted server (and our probes) run as a normal user.
RUN useradd -m scanner
USER scanner
ENV HOME=/home/scanner \
    NPM_CONFIG_CACHE=/home/scanner/.npm \
    XDG_CACHE_HOME=/home/scanner/.cache \
    UV_CACHE_DIR=/home/scanner/.cache/uv

# Args after the image name are passed straight to `redcell` (e.g. `scan -- npx -y some-server`).
ENTRYPOINT ["redcell"]
