Add /health endpoint for Docker healthcheck
All checks were successful
Build And Test / publish (push) Successful in 48s

The healthcheck was hitting /mcp which requires auth, causing unhealthy status.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-30 16:42:38 -08:00
parent 3bc66e4efc
commit a2104917fd
2 changed files with 11 additions and 1 deletions

View File

@@ -35,7 +35,7 @@ EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/mcp')" || exit 1
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
# Use entrypoint to fix permissions, then run as mcp user
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -165,8 +165,15 @@ if __name__ == "__main__":
import signal
import uvicorn
from starlette.responses import JSONResponse
from starlette.routing import Route
from middleware import APIKeyAuthMiddleware
async def health_check(request):
"""Health check endpoint for Docker/Traefik."""
return JSONResponse({"status": "healthy"})
async def main():
await initialize()
@@ -176,6 +183,9 @@ if __name__ == "__main__":
# Get the underlying ASGI app from FastMCP
app = mcp.http_app(path="/mcp")
# Add health check route
app.routes.append(Route("/health", health_check))
# Add authentication middleware if API key is configured
if settings.mcp_api_key:
app.add_middleware(