From bb77e27039c6d2a645a94e7c8da27ccede3e8786 Mon Sep 17 00:00:00 2001 From: Daniel Chalef <131175+danielchalef@users.noreply.github.com> Date: Thu, 30 Oct 2025 22:10:10 -0700 Subject: [PATCH] feat: Add /health endpoint for Docker healthchecks - Add @mcp.custom_route for /health endpoint using FastMCP - Returns {status: 'healthy', service: 'graphiti-mcp'} - Update Dockerfile.standalone healthcheck to use /health instead of / - Eliminates 404 errors in logs from healthcheck pings - Follows FastMCP best practices for operational monitoring --- mcp_server/docker/Dockerfile.standalone | 2 +- mcp_server/src/graphiti_mcp_server.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mcp_server/docker/Dockerfile.standalone b/mcp_server/docker/Dockerfile.standalone index aecb4909..6db22d95 100644 --- a/mcp_server/docker/Dockerfile.standalone +++ b/mcp_server/docker/Dockerfile.standalone @@ -71,7 +71,7 @@ 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/ || exit 1 + CMD curl -f http://localhost:8000/health || exit 1 # Run the MCP server CMD ["uv", "run", "main.py"] diff --git a/mcp_server/src/graphiti_mcp_server.py b/mcp_server/src/graphiti_mcp_server.py index 4c442e0e..b75d2c54 100644 --- a/mcp_server/src/graphiti_mcp_server.py +++ b/mcp_server/src/graphiti_mcp_server.py @@ -738,6 +738,12 @@ async def get_status() -> StatusResponse: ) +@mcp.custom_route('/health', methods=['GET']) +async def health_check(request) -> dict: + """Health check endpoint for Docker and load balancers.""" + return {'status': 'healthy', 'service': 'graphiti-mcp'} + + async def initialize_server() -> ServerConfig: """Parse CLI arguments and initialize the Graphiti server configuration.""" global config, graphiti_service, queue_service, graphiti_client, semaphore