Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds OIDC authentication support for HTTP mode deployments, fixes a previously skipped test, and updates all installation documentation to use PyPI instead of GitHub URLs.
- Adds optional OIDC authentication for HTTP transport mode with proper environment variable validation
- Fixes
test_no_data_loadedtest to properly validateNoDataLoadedErrorexception handling - Updates all documentation and client configurations to use PyPI installation (
uvx databeak)
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/databeak/server.py | Adds OIDC authentication settings and integration with validation logic |
| tests/unit/servers/test_discovery_server_coverage.py | Fixes skipped test by replacing mocks with real session management |
| docs/installation.md | Updates installation commands and adds OIDC authentication documentation |
| README.md | Updates quick start examples and adds OIDC configuration section |
Comments suppressed due to low confidence (1)
src/databeak/server.py:1
- The import
DatabeakSettingsis removed but was previously used in the@smithery.server(config_schema=DatabeakSettings)decorator. Verify that removing the config schema doesn't break server configuration functionality.
"""Main FastMCP server for DataBeak."""
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| session.has_data.return_value = False | ||
| manager.return_value.get_session.return_value = session | ||
| # Create a real session without data | ||
| from databeak.exceptions import NoDataLoadedError |
There was a problem hiding this comment.
[nitpick] The import is placed inside the test function rather than at the module level. Consider moving this import to the top of the file with other imports for consistency and better readability.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #134 +/- ##
==========================================
- Coverage 84.75% 84.68% -0.07%
==========================================
Files 27 27
Lines 3076 3089 +13
Branches 458 460 +2
==========================================
+ Hits 2607 2616 +9
- Misses 355 357 +2
- Partials 114 116 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Code Review: Add OIDC authentication, fix tests, and update PyPI installation docsOverviewThis PR adds OIDC authentication for HTTP mode, fixes a previously-skipped test, and updates documentation to reflect PyPI availability. The intent is sound, but the architectural shift in 🚨 Critical Issues1. Smithery entry point is broken ( The function [tool.smithery]
server = "databeak.server:create_server" # ← will fail with AttributeErrorThis silently breaks the Smithery integration at startup. Either update the entry to
|
Code Review: PR #134 — OIDC Authentication, Test Fix, Docs UpdateOverviewThis PR adds optional OIDC authentication for HTTP mode, fixes a previously-skipped unit test, and updates installation docs to reference PyPI. The overall direction is good, but there are several correctness and security issues worth addressing. Critical: Broken Smithery Entry PointIn server = "databeak.server:create_server"But Architecture: Module-Level Initialisation in
|
| Area | Status |
|---|---|
Smithery entry point (create_server → create_smithery_server) |
❌ Must fix |
client_secret using plain str |
SecretStr |
case_sensitive=False dropped silently |
|
Module-level OIDC init + logger.error at import time |
main() |
log_level no validation |
Literal type |
Logging side effects in __init__.py |
|
type: ignore on mcp.run() |
|
| Test fix | ✅ |
| Documentation | ✅ |
The broken entry point is a blocker. The security and architectural concerns are significant enough to warrant a revision pass before merge.
Code Review: PR #134 — OIDC Authentication, Test Fix, and PyPI DocsOverviewThis PR adds optional OIDC authentication for HTTP mode deployments, fixes one skipped test, and updates all installation docs to point at PyPI. The functionality is additive and the docs changes are straightforward, but there are a few structural concerns in the server refactor worth addressing. Server Refactor — Key Structural Changes🔴
|
| Item | Status |
|---|---|
Entry point create_server → create_smithery_server mismatch |
🔴 Breaking — fix before merge |
OidcSettings in server.py vs settings.py |
🟡 Convention violation |
| Silent partial OIDC config | 🟡 Security UX risk |
| Module-level OIDC init | 🟡 Testing complexity |
| Session leak in test | 🟡 Test hygiene |
type: ignore in mcp.run() |
🟡 Unresolved type mismatch |
log_level field without validation |
🟡 Minor |
| Docs updates | ✅ Clean |
| OIDC design intent | ✅ Sound |
The entry point breakage is the only blocker. The other items are improvement opportunities.
Review generated by Claude Code
Code Review: PR #134 — OIDC Authentication, Test Fix, PyPI DocsThe intent here is solid — OIDC auth, a proper test fix, and a long-overdue PyPI simplification. But the 🔴 Critical Issues1. IndentationError in
|
The rebase introduced mixed 4/5-space indentation in the two server factory functions. Fix all docstrings, comments, and code blocks to use consistent 4-space indentation. Also add type ignores for pre-existing mypy errors on prompt() calls.
Code Review — PR #134: OIDC Authentication, Test Fix, and PyPI DocsOverviewThis PR adds OIDC authentication for HTTP mode, fixes a skipped test in the discovery server, and updates all installation docs to reference PyPI. The intent is sound, but there are structural issues in Critical: Health Check Endpoint Silently Drops in HTTP Mode
The refactor creates a module-level # Module-level mcp — used by main()
mcp = FastMCP("DataBeak", auth=auth, ...)
# ...
def create_server() -> FastMCP:
mcp = FastMCP(...) # ← local variable, shadows module-level
@mcp.custom_route("/health", ...) # ← registered on local mcp, not the one main() runs
...
def main():
mcp.run(...) # ← module-level mcp has NO /health routeAny HTTP deployment relying on Significant: Duplicate Server Instance / Dead Code
Similarly, Moderate: Module-Level OIDC Initialization Has Side Effects# server.py top-level
oidc_settings = OidcSettings() # reads env vars at import time
auth: OIDCProxy | None = None
if oidc_settings.config_url and ...:
auth = OIDCProxy(...) # makes network/DNS calls at import time?
elif any([...]):
logger.error(...) # logs at import timeExecuting this at module load means any test that imports Minor: Test Session Leak
The new _session = manager.get_or_create_session(no_data_session_id)
# ... test runs, session is never removedOther tests in this file use fixture-based teardown with Minor:
|
The pre-commit mypy hook had fastmcp>=0.1.0 (old 0.x series) while pyproject.toml specifies fastmcp>=3.2.0. This caused mypy to report arg-type errors on prompt() calls in pre-commit but not in CI. Align the version to fastmcp>=3.2.0 in both places. Also remove unnecessary cast() and unused typing imports.
Code Review: PR #134 — OIDC Authentication, Test Fix, PyPI DocsOverviewThis PR adds optional OIDC authentication for HTTP mode, fixes a previously skipped test in the discovery server, and updates documentation to reference PyPI installation. The direction is sound but there are several structural issues that need attention before merging. 🔴 Critical Issues1. Health check endpoint is broken
# In create_server() — never called by main()
@mcp.custom_route("/health", methods=["GET"])
async def health_check(_request: Request) -> PlainTextResponse:
return PlainTextResponse("OK")Any container orchestration that probes 2.
|
The _fastmcp attribute exists at runtime but mypy doesn't know about it. Add type ignore to prevent attr-defined errors.
Code Review: PR #134 — Add OIDC authentication, fix tests, and update PyPI installation docsGood overall direction — OIDC support is a useful addition and the PyPI migration simplifies install docs significantly. There are a few architectural issues that need attention before merge. Critical Issues1. Dual-instance
|
…nt _fastmcp The create_server() function returns a FastMCP instance directly. The _fastmcp attribute only existed on the Smithery wrapper decorator, which is not used here. Pass the FastMCP instance directly to Client.
Code Review: PR #134 — OIDC Authentication, Test Fix, PyPI DocsOverviewThis PR bundles three distinct concerns: OIDC auth support for HTTP mode, a fix for a previously-skipped test, and a documentation refresh for PyPI installation. The doc and test changes are generally clean; the server.py refactoring has a few structural issues worth addressing. Critical Issues1. Duplicate
|
Client(mcp) in FastMCP 3.x defaults to stdio transport which hangs. Use FastMCPTransport(mcp) for in-memory connection instead.
Code ReviewOverviewThis PR covers three distinct areas: OIDC authentication for HTTP mode, a previously skipped test fix, and PyPI-based installation docs. The test fix and documentation changes are solid. The OIDC integration has structural issues that need attention before merge. Critical Issues1. Duplicate server instances (
|
…n tests FastMCPTransport spawns a stdio subprocess which hangs in test context. Use auto_initialize=False with manual connect/disconnect for true in-memory testing.
Code Review: PR #134 — OIDC Authentication, Test Fix, PyPI DocsOverall this is a useful addition, but there are several architectural and correctness issues worth addressing before merge. Critical Issues1. Duplicate server instantiation in
|
Pass FastMCP instance directly to Client (was trying to unwrap non-existent _fastmcp attribute). Use FastMCPTransport for true in-memory connection instead of stdio subprocess which hangs.
Code Review — PR #134: OIDC Auth, Test Fix, PyPI DocsGood direction overall — OIDC support is a meaningful addition and the test fix removes a TODO. However, there are several architectural issues in CriticalTwo divergent The PR introduces a module-level
This is a regression. Either collapse everything into
client_secret: str | None = NoneUse from pydantic import SecretStr
client_secret: SecretStr | None = NoneThen pass Architecture / Conventions
CLAUDE.md is explicit: "Configuration centralized in Module-level side effects fire before logging is configured # server.py — runs at import time
oidc_settings = OidcSettings()
...
logger.error("Incomplete OIDC configuration. ...") # before setup_structured_logging()
logging.getLogger("databeak").setLevel(get_settings().log_level)
logging.getLogger("mcp").setLevel(get_settings().log_level)Cache the result in one call. More broadly, configuring loggers as a module-level import side effect will affect any test that imports the package — consider moving this into Testing
The new test creates a session with async def test_no_data_loaded(self) -> None:
no_data_session_id = str(uuid.uuid4())
manager = get_session_manager()
manager.get_or_create_session(no_data_session_id)
try:
ctx = create_mock_context(no_data_session_id)
with pytest.raises(NoDataLoadedError):
await detect_outliers(ctx)
ctx = create_mock_context(no_data_session_id)
with pytest.raises(NoDataLoadedError):
await profile_data(ctx)
finally:
await manager.remove_session(no_data_session_id)The Minor
elif any(
v is not None for v in (
oidc_settings.config_url,
oidc_settings.client_id,
oidc_settings.client_secret,
oidc_settings.base_url,
)
):
DocumentationThe docs changes are clean and welcome — the PyPI simplification is a clear improvement. The OIDC section in Summary
|
Summary
This PR adds OIDC authentication support for HTTP mode deployments, fixes a skipped test in the discovery server, and updates all installation documentation to reflect PyPI as the primary installation source.
Changes
1. OIDC Authentication (HTTP Mode)
OidcSettingsclass withDATABEAK_OIDC_*environment variablesOIDCProxyfrom FastMCP for secure HTTP deploymentsEnvironment Variables:
DATABEAK_OIDC_CONFIG_URL- OIDC discovery configuration URLDATABEAK_OIDC_CLIENT_ID- OAuth2 client IDDATABEAK_OIDC_CLIENT_SECRET- OAuth2 client secretDATABEAK_OIDC_BASE_URL- Application base URL for OAuth22. Fixed Skipped Test
test_no_data_loadedintest_discovery_server_coverage.py:624NoDataLoadedErrorexception handling3. Documentation Updates
uvx --from git+...touvx databeakTest Plan
uv run pytest tests/unit/servers/test_discovery_server_coverage.pyBreaking Changes
None - this is additive functionality.
Notes
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com