graphiti/mcp_server/docker/Dockerfile.standalone
Daniel Chalef d97c248551
Fix MCP server telemetry and update graphiti-core to v0.23.0 (#1057)
* Fix MCP server telemetry and update graphiti-core to v0.23.0

- Regenerate uv.lock in Docker builds to ensure posthog dependency is included
- Update graphiti-core version to 0.23.0 across all configurations
- Fix Python 3.11 compatibility for Pydantic TypedDict import
- Add FalkorDB Browser UI access information to startup logs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add typing-extensions as explicit dependency

Required for Python 3.11 compatibility with Pydantic 2.11.7,
which mandates typing_extensions.TypedDict on Python < 3.12.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Use built-in TypedDict from typing module

Python 3.10+ includes TypedDict in the standard library.
Removed typing-extensions dependency as it's unnecessary.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Revert to typing_extensions.TypedDict for Pydantic compatibility

Pydantic requires typing_extensions.TypedDict on Python < 3.12.
Docker container uses Python 3.11, so this is necessary.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add Ruff linter rule to prevent typing.TypedDict usage

Adds banned-api configuration to both main and MCP server pyproject.toml
files to enforce typing_extensions.TypedDict usage, required for
Pydantic compatibility on Python < 3.12.

Also includes Ruff auto-formatting changes to quote styles.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Bump MCP server version to 1.0.1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-08 18:31:24 -08:00

81 lines
2.6 KiB
Text

# syntax=docker/dockerfile:1
# Standalone Graphiti MCP Server Image
# This image runs only the MCP server and connects to an external database (Neo4j or FalkorDB)
FROM python:3.11-slim-bookworm
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install uv for Python package management
ADD https://astral.sh/uv/install.sh /uv-installer.sh
RUN sh /uv-installer.sh && rm /uv-installer.sh
# Add uv to PATH
ENV PATH="/root/.local/bin:${PATH}"
# Configure uv for optimal Docker usage
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=never \
MCP_SERVER_HOST="0.0.0.0" \
PYTHONUNBUFFERED=1
# Set up MCP server directory
WORKDIR /app/mcp
# Accept graphiti-core version as build argument
ARG GRAPHITI_CORE_VERSION=0.23.0
# Copy project files for dependency installation
COPY pyproject.toml uv.lock ./
# Remove the local path override for graphiti-core in Docker builds
# Install with BOTH neo4j and falkordb extras for maximum flexibility
# and regenerate lock file to match the PyPI version
RUN sed -i '/\[tool\.uv\.sources\]/,/graphiti-core/d' pyproject.toml && \
sed -i "s/graphiti-core\[falkordb\]>=0\.23\.0/graphiti-core[neo4j,falkordb]==${GRAPHITI_CORE_VERSION}/" pyproject.toml && \
echo "Regenerating lock file for PyPI graphiti-core..." && \
rm -f uv.lock && \
uv lock
# Install Python dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev
# Store graphiti-core version
RUN echo "${GRAPHITI_CORE_VERSION}" > /app/mcp/.graphiti-core-version
# Copy MCP server application code
COPY main.py ./
COPY src/ ./src/
COPY config/ ./config/
# Create log directory
RUN mkdir -p /var/log/graphiti
# Add Docker labels with version information
ARG MCP_SERVER_VERSION=1.0.0
ARG BUILD_DATE
ARG VCS_REF
LABEL org.opencontainers.image.title="Graphiti MCP Server (Standalone)" \
org.opencontainers.image.description="Standalone Graphiti MCP server for external Neo4j or FalkorDB" \
org.opencontainers.image.version="${MCP_SERVER_VERSION}" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.vendor="Zep AI" \
org.opencontainers.image.source="https://github.com/zep-ai/graphiti" \
graphiti.core.version="${GRAPHITI_CORE_VERSION}"
# Expose MCP server port
EXPOSE 8000
# Health check - verify MCP server is responding
HEALTHCHECK --interval=10s --timeout=5s --start-period=15s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Run the MCP server
CMD ["uv", "run", "main.py"]