You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "aminghadersohi (via GitHub)" <gi...@apache.org> on 2025/07/24 03:02:33 UTC

Re: [PR] feat(mcp): MCP Service - Phase 1 [superset]

aminghadersohi commented on code in PR #33976:
URL: https://github.com/apache/superset/pull/33976#discussion_r2227215942


##########
superset/mcp_service/mcp_app.py:
##########
@@ -0,0 +1,90 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+FastMCP app instance and initialization for Superset MCP service.
+This file provides the global FastMCP instance (mcp) and a function to initialize
+middleware. All tool modules should import mcp from here and use @mcp.tool and
+@mcp_auth_hook decorators.
+"""
+
+import logging
+
+from fastmcp import FastMCP
+
+from superset.mcp_service.middleware import LoggingMiddleware, PrivateToolMiddleware
+
+mcp = FastMCP(
+    "Superset MCP Server",
+    instructions="""

Review Comment:
   
   
   
   **Great question about auth integration!**
   
   Yes, our MCP service architecture is designed to support BearerAuthProvider integration. Looking at the FastMCP Bearer auth docs, we can integrate it in two ways:
   
   **Option 1**: Server initialization (cleanest approach)
   
   auth = BearerAuthProvider(
       jwks_uri=os.getenv("MCP_JWKS_URI"),
       issuer=os.getenv("MCP_JWT_ISSUER"),
       audience="superset-mcp-server"
   )
   
   mcp = FastMCP("Superset MCP Server", auth=auth)
   
   **Option 2**: Environment-based configuration
     Since our server is already modular with middleware support, we can add auth as an optional feature
     controlled by environment variables, making it easy to enable/disable per deployment.
   
     The BearerAuthProvider supports JWT validation via JWKS endpoints, which aligns well with enterprise
     SSO systems. We'd get access to user context via get_access_token() in our tools for fine-grained
     permissions.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org