rspace-online/docker/kicad-mcp/Dockerfile

39 lines
1.2 KiB
Docker

FROM node:20-slim
# Install KiCad (includes pcbnew Python module), Python, and build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
kicad \
python3 \
python3-pip \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Use SWIG backend (headless — no KiCad GUI needed)
ENV KICAD_BACKEND=swig
# Ensure pcbnew module is findable (installed by kicad package)
ENV PYTHONPATH=/usr/lib/python3/dist-packages
# Point KiCad MCP to system Python (absolute path for existsSync validation)
ENV KICAD_PYTHON=/usr/bin/python3
WORKDIR /app
# Copy MCP server source
COPY KiCAD-MCP-Server/ .
# Remove any venv so the server uses system Python (which has pcbnew)
RUN rm -rf .venv venv
# Install Node deps + supergateway (stdio→SSE bridge)
RUN npm install && npm install -g supergateway
# Install Python requirements into system Python (Pillow, cairosvg, requests, etc.)
RUN pip3 install --break-system-packages -r python/requirements.txt requests
# Ensure generated files dir exists
RUN mkdir -p /data/files/generated
EXPOSE 8809
# Use StreamableHttp (supports multiple concurrent connections, unlike SSE)
CMD ["supergateway", "--stdio", "node dist/index.js", "--port", "8809", "--outputTransport", "streamableHttp"]