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
This commit is contained in:
Daniel Chalef 2025-10-30 22:10:10 -07:00
parent aab042d84a
commit bb77e27039
2 changed files with 7 additions and 1 deletions

View file

@ -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"]

View file

@ -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