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


##########
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:
   I like option 1, can you make it configurable also? similar to: 
https://github.com/apache/superset/blob/master/superset/config.py#L1526.
   Actually, we can't make it exactly like that since `__init__` can take 
different parameters, WDYT about using a configurable factory function?
   
   ``` python
   def create_auth(app):
       jwks_uri = app.config["MCP_JWKS_URI"]
       issuer = app.config["MCP_JWT_ISSUER"]
       audience = app.config["MCP_JWT_AUDIENCE"]
   
       return BearerAuthProvider(
           jwks_uri=jwks_uri,
           issuer=issuer,
           audience=audience
       )
   ```
    
   config.py
   ``` python
   MCP_AUTH_FACTORY: Callable[[Flask], Any] = create_auth
   ```
   
   Then:
   ``` python
   mcp = FastMCP("Superset MCP Server", 
auth=app.config["MCP_AUTH_FACTORY"](app))
   ```
   
   
   



-- 
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-unsubscr...@superset.apache.org

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


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

Reply via email to