Skip to content

Joe/171 oauth seems to have been broken in recent updates#173

Merged
joe-clickhouse merged 3 commits into
mainfrom
joe/171-oauth-seems-to-have-been-broken-in-recent-updates
Apr 23, 2026
Merged

Joe/171 oauth seems to have been broken in recent updates#173
joe-clickhouse merged 3 commits into
mainfrom
joe/171-oauth-seems-to-have-been-broken-in-recent-updates

Conversation

@joe-clickhouse

Copy link
Copy Markdown
Collaborator

Summary

#113 (a1f3639) added static bearer-token auth for HTTP/SSE transports but unintentionally broke FastMCP's OAuth/OIDC providers.

  1. Startup raised ValueError unless CLICKHOUSE_MCP_AUTH_TOKEN or CLICKHOUSE_MCP_AUTH_DISABLED=true was set, leaving no path to configure OAuth.
  2. Even with a workaround token, FastMCP(auth=StaticTokenVerifier(...)) overrode FastMCP's env-var-driven provider auto-discovery, so FASTMCP_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:
    1. CLICKHOUSE_MCP_AUTH_DISABLED=true -> auth=None
    2. CLICKHOUSE_MCP_AUTH_TOKEN -> StaticTokenVerifier
    3. FASTMCP_SERVER_AUTH=<full class path> -> omit auth kwarg so FastMCP auto-loads from FASTMCP_SERVER_AUTH_*.
    4. Startup fails if none is configured.
  • /health hardening: removed the inline auth gate (it only worked under static-token mode and was incompatible with redirect-based OAuth providers anyway). Response bodies trimmed to OK / generic ERROR. ... Check server logs for details. Underlying errors are logged server-side.

Closes #171

@joe-clickhouse joe-clickhouse linked an issue Apr 20, 2026 that may be closed by this pull request
@joe-clickhouse

Copy link
Copy Markdown
Collaborator Author

@codex[agent] please review this PR.

@Codex

Codex AI commented Apr 20, 2026

Copy link
Copy Markdown

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

  • releases.astral.sh
    • Triggering command: /home/REDACTED/.local/bin/uv uv run pytest -v tests submodules | head -n 10 --local de/node/bin/lsb_release credential.userngrep (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 via FASTMCP_SERVER_AUTH).
  • Made /health intentionally unauthenticated and minimized its response bodies while logging underlying failures server-side.
  • Expanded docs/changelog and added tests covering the new auth resolution and /health redaction 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.

Comment thread mcp_clickhouse/mcp_server.py Outdated
Comment thread README.md Outdated
Comment thread CHANGELOG.md

@peter-leonov-ch peter-leonov-ch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Comment thread README.md
- 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

@joe-clickhouse joe-clickhouse merged commit 2aba66a into main Apr 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OAuth seems to have been broken in recent updates

4 participants