Joe/171 oauth seems to have been broken in recent updates#173
Conversation
|
@codex[agent] please review this PR. |
Reviewed the PR—no blocking issues spotted. CI is green; local pytest runs fail only from missing ClickHouse env vars (expected in this environment). Latest commit reviewed: ade4ab3. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
Fixes HTTP/SSE authentication configuration so FastMCP OAuth/OIDC providers can be used again (without being overridden by static-token auth), and hardens /health responses to avoid leaking backend details.
Changes:
- Added
_resolve_auth()to select exactly how FastMCP auth is configured for HTTP/SSE (disabled, static token, or delegated to FastMCP viaFASTMCP_SERVER_AUTH). - Made
/healthintentionally unauthenticated and minimized its response bodies while logging underlying failures server-side. - Expanded docs/changelog and added tests covering the new auth resolution and
/healthredaction behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
mcp_clickhouse/mcp_server.py |
Centralizes auth resolution and updates /health behavior/messages. |
mcp_clickhouse/mcp_env.py |
Updates config docstring to describe the new auth mode options. |
tests/test_auth_config.py |
Adds unit tests for _resolve_auth() behavior across modes. |
tests/test_optional_chdb.py |
Adds a regression test ensuring /health hides connection error details. |
README.md |
Documents auth modes and unauthenticated /health; adds OAuth/OIDC setup guidance. |
CHANGELOG.md |
Notes OAuth/OIDC support via FASTMCP_SERVER_AUTH and /health behavior change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - Returns `200 OK` (body: `OK`) if the server is healthy and can connect to ClickHouse | ||
| - Returns `503 Service Unavailable` with a generic error message if the server cannot connect to ClickHouse | ||
|
|
||
| The endpoint is intentionally unauthenticated so orchestrator probes (e.g. Kubernetes liveness/readiness, load balancers) can reach it without credentials. The response body is deliberately minimal to avoid leaking backend version strings or error details; debug failures via the server logs. |
Summary
#113 (
a1f3639) added static bearer-token auth for HTTP/SSE transports but unintentionally broke FastMCP's OAuth/OIDC providers.ValueErrorunlessCLICKHOUSE_MCP_AUTH_TOKENorCLICKHOUSE_MCP_AUTH_DISABLED=truewas set, leaving no path to configure OAuth.FastMCP(auth=StaticTokenVerifier(...))overrode FastMCP's env-var-driven provider auto-discovery, soFASTMCP_SERVER_AUTH_AZURE_*vars were silently ignored.Changes
mcp_clickhouse/mcp_server.py: extracted auth resolution into_resolve_auth(). Three mutually exclusive modes for HTTP/SSE:CLICKHOUSE_MCP_AUTH_DISABLED=true->auth=NoneCLICKHOUSE_MCP_AUTH_TOKEN->StaticTokenVerifierFASTMCP_SERVER_AUTH=<full class path>-> omitauthkwarg so FastMCP auto-loads fromFASTMCP_SERVER_AUTH_*./healthhardening: removed the inline auth gate (it only worked under static-token mode and was incompatible with redirect-based OAuth providers anyway). Response bodies trimmed toOK/ genericERROR. ... Check server logs for details.Underlying errors are logged server-side.Closes #171