From 14a59fdff38ce8d1b79750b23506a57ad46303dd Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Thu, 13 Nov 2025 21:48:58 +0100 Subject: [PATCH 1/2] fix: Use NEXTCLOUD_OIDC_CLIENT_ID/SECRET env vars consistently MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #296 The application code was looking for OIDC_CLIENT_ID and OIDC_CLIENT_SECRET (without NEXTCLOUD_ prefix), but the Helm chart, documentation, and CLI all use NEXTCLOUD_OIDC_CLIENT_ID and NEXTCLOUD_OIDC_CLIENT_SECRET. This mismatch caused OAuth deployments via Helm to fail with crashloops because the credentials weren't being found. Changes: - app.py: Use NEXTCLOUD_OIDC_CLIENT_ID/SECRET in setup_oauth_config() - config.py: Use NEXTCLOUD_OIDC_CLIENT_ID/SECRET in get_settings() - Updated documentation comments and error messages This aligns with the documented naming convention where all Nextcloud-related environment variables use the NEXTCLOUD_ prefix. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- nextcloud_mcp_server/app.py | 14 ++++++++------ nextcloud_mcp_server/config.py | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/nextcloud_mcp_server/app.py b/nextcloud_mcp_server/app.py index cf1d095..93f0ea1 100644 --- a/nextcloud_mcp_server/app.py +++ b/nextcloud_mcp_server/app.py @@ -507,9 +507,9 @@ async def setup_oauth_config(): - External IdP mode: OIDC_DISCOVERY_URL points to external provider → External IdP for OAuth, Nextcloud user_oidc validates tokens and provides API access - Uses generic OIDC environment variables: + Uses OIDC environment variables: - OIDC_DISCOVERY_URL: OIDC discovery endpoint (optional, defaults to NEXTCLOUD_HOST) - - OIDC_CLIENT_ID / OIDC_CLIENT_SECRET: Static credentials (optional, uses DCR if not provided) + - NEXTCLOUD_OIDC_CLIENT_ID / NEXTCLOUD_OIDC_CLIENT_SECRET: Static credentials (optional, uses DCR if not provided) - NEXTCLOUD_OIDC_SCOPES: Requested OAuth scopes This is done synchronously before FastMCP initialization because FastMCP @@ -633,19 +633,21 @@ async def setup_oauth_config(): ) # Load client credentials (static or dynamic registration) - client_id = os.getenv("OIDC_CLIENT_ID") - client_secret = os.getenv("OIDC_CLIENT_SECRET") + client_id = os.getenv("NEXTCLOUD_OIDC_CLIENT_ID") + client_secret = os.getenv("NEXTCLOUD_OIDC_CLIENT_SECRET") if client_id and client_secret: logger.info(f"Using static OIDC client credentials: {client_id}") elif registration_endpoint: - logger.info("OIDC_CLIENT_ID not set, attempting Dynamic Client Registration") + logger.info( + "NEXTCLOUD_OIDC_CLIENT_ID not set, attempting Dynamic Client Registration" + ) client_id, client_secret = await load_oauth_client_credentials( nextcloud_host=nextcloud_host, registration_endpoint=registration_endpoint ) else: raise ValueError( - "OIDC_CLIENT_ID and OIDC_CLIENT_SECRET environment variables are required " + "NEXTCLOUD_OIDC_CLIENT_ID and NEXTCLOUD_OIDC_CLIENT_SECRET environment variables are required " "when the OIDC provider does not support Dynamic Client Registration. " f"Discovery URL: {discovery_url}" ) diff --git a/nextcloud_mcp_server/config.py b/nextcloud_mcp_server/config.py index 092dfdd..31db982 100644 --- a/nextcloud_mcp_server/config.py +++ b/nextcloud_mcp_server/config.py @@ -288,8 +288,8 @@ def get_settings() -> Settings: return Settings( # OAuth/OIDC settings oidc_discovery_url=os.getenv("OIDC_DISCOVERY_URL"), - oidc_client_id=os.getenv("OIDC_CLIENT_ID"), - oidc_client_secret=os.getenv("OIDC_CLIENT_SECRET"), + oidc_client_id=os.getenv("NEXTCLOUD_OIDC_CLIENT_ID"), + oidc_client_secret=os.getenv("NEXTCLOUD_OIDC_CLIENT_SECRET"), oidc_issuer=os.getenv("OIDC_ISSUER"), # Nextcloud settings nextcloud_host=os.getenv("NEXTCLOUD_HOST"), From 39259ef28241d7d539f7f135c4ae80492eafdc58 Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Thu, 13 Nov 2025 22:06:07 +0100 Subject: [PATCH 2/2] ci: Run smoke tests only in ci --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2c30f98..7ef61c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -85,4 +85,4 @@ jobs: NEXTCLOUD_USERNAME: "admin" NEXTCLOUD_PASSWORD: "admin" run: | - uv run pytest -v --log-cli-level=WARN --ignore=tests/manual + uv run pytest -v --log-cli-level=WARN -m smoke