codeant-ai-for-open-source[bot] commented on code in PR #40469:
URL: https://github.com/apache/superset/pull/40469#discussion_r3311424881


##########
superset/mcp_service/server.py:
##########
@@ -717,6 +718,24 @@ def build_middleware_list() -> list[Middleware]:
     ]
 
 
+def _build_starlette_middleware(flask_app: Any | None = None) -> list[Any]:
+    from starlette.middleware import Middleware as StarletteMiddleware
+
+    if flask_app is None:
+        from superset.mcp_service.flask_singleton import get_flask_app
+
+        flask_app = get_flask_app()
+    auth_enabled = flask_app.config.get("MCP_AUTH_ENABLED", False)
+    page_config = flask_app.config.get("MCP_HELLO_PAGE", None)
+    return [
+        StarletteMiddleware(
+            BrowserHelloMiddleware,
+            auth_enabled=auth_enabled,
+            page_config=page_config,
+        )

Review Comment:
   **🟠 Architect Review — HIGH**
   
   Browser hello page infers whether auth is required solely from 
`MCP_AUTH_ENABLED`, but auth can be enabled via `MCP_AUTH_FACTORY` even when 
that flag is `False`. In such valid custom-auth deployments, the hello page 
omits the `Authorization` header in the config snippet even though the MCP 
endpoint requires a Bearer token, causing users to copy a non-working client 
config.
   
   **Suggestion:** Derive the hello-page auth behavior from the actual auth 
provider in use (e.g., based on whether `_create_auth_provider` returned a 
non-None provider or by passing an explicit `auth_enabled` flag from 
auth-provider creation) instead of relying only on `MCP_AUTH_ENABLED`.
   
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=8635d631b8994435a5d2d8b0dd9c5611&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 | [Fix in VSCode 
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=8635d631b8994435a5d2d8b0dd9c5611&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is an **Architect / Logical Review** comment left during a code review. 
These reviews are first-class, important findings — not optional suggestions. 
Do NOT dismiss this as a 'big architectural change' just because the title says 
architect review; most of these can be resolved with a small, localized fix 
once the intent is understood.
   
   **Path:** superset/mcp_service/server.py
   **Line:** 728:735
   **Comment:**
        *HIGH: Browser hello page infers whether auth is required solely from 
`MCP_AUTH_ENABLED`, but auth can be enabled via `MCP_AUTH_FACTORY` even when 
that flag is `False`. In such valid custom-auth deployments, the hello page 
omits the `Authorization` header in the config snippet even though the MCP 
endpoint requires a Bearer token, causing users to copy a non-working client 
config.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   If a suggested approach is provided above, use it as the authoritative 
instruction. If no explicit code suggestion is given, you MUST still draft and 
apply your own minimal, localized fix — do not punt back with 'no suggestion 
provided, review manually'. Keep the change as small as possible: add a guard 
clause, gate on a loading state, reorder an await, wrap in a conditional, etc. 
Do not refactor surrounding code or expand scope beyond the finding.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to