aminghadersohi commented on code in PR #45391:
URL: https://github.com/apache/superset/pull/45391#discussion_r4333590809
##########
superset/mcp_service/jwt_verifier.py:
##########
@@ -312,20 +315,34 @@ def __init__(
app: Any,
auth_enabled: bool = False,
page_config: dict[str, Any] | None = None,
+ mcp_path: str | None = None,
) -> None:
super().__init__(app)
self._html = _build_browser_hello_html(
auth_enabled=auth_enabled, page_config=page_config
)
+ # The streamable-HTTP endpoint FastMCP mounts (``/mcp`` by default).
+ self._mcp_path = _normalize_path(
+ mcp_path or fastmcp.settings.streamable_http_path
+ )
async def dispatch(
self, request: Request, call_next: Callable[..., Any]
) -> Response:
- if request.method in ("GET", "HEAD") and
_prefers_browser_html(request):
+ if (
+ request.method in ("GET", "HEAD")
+ and _normalize_path(request.url.path) == self._mcp_path
+ and _prefers_browser_html(request)
+ ):
return HTMLResponse(content=self._html, status_code=200)
return await call_next(request)
Review Comment:
Nit: When this app is mounted at `/prefix` (or served with `root_path`),
`request.url.path` is `/prefix/mcp`, but the configured endpoint is `/mcp`.
Browser visits then reach the MCP handler instead of the hello page.
```suggestion
from starlette._utils import get_route_path
if (
request.method in ("GET", "HEAD")
and _normalize_path(get_route_path(request.scope)) ==
self._mcp_path
and _prefers_browser_html(request)
):
return HTMLResponse(content=self._html, status_code=200)
return await call_next(request)
```
--
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]