michael-s-molina commented on code in PR #36151:
URL: https://github.com/apache/superset/pull/36151#discussion_r2560206399


##########
docs/developer_portal/extensions/mcp.md:
##########
@@ -0,0 +1,460 @@
+---
+title: MCP Integration
+hide_title: true
+sidebar_position: 8
+version: 1
+---
+
+<!--
+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.
+-->
+
+# MCP Integration
+
+Model Context Protocol (MCP) integration allows extensions to register custom 
AI agent capabilities that integrate seamlessly with Superset's MCP service. 
Extensions can provide both **tools** (executable functions) and **prompts** 
(interactive guidance) that AI agents can discover and use.
+
+## What is MCP?
+
+MCP enables extensions to extend Superset's AI capabilities in two ways:
+
+### MCP Tools
+Tools are Python functions that AI agents can call to perform specific tasks. 
They provide executable functionality that extends Superset's capabilities.
+
+**Examples of MCP tools:**
+- Data processing and transformation functions
+- Custom analytics calculations
+- Integration with external APIs
+- Specialized report generation
+- Business-specific operations
+
+### MCP Prompts
+Prompts provide interactive guidance and context to AI agents. They help 
agents understand how to better assist users with specific workflows or domain 
knowledge.
+
+**Examples of MCP prompts:**
+- Step-by-step workflow guidance
+- Domain-specific context and knowledge
+- Interactive troubleshooting assistance
+- Template generation helpers
+- Best practices recommendations
+
+## Getting Started
+
+## MCP Tools
+
+### Basic Tool Registration
+
+The simplest way to create an MCP tool is using the `@tool` decorator:
+
+```python
+from superset_core.mcp import tool
+
+@tool
+def hello_world() -> dict:
+    """A simple greeting tool."""
+    return {"message": "Hello from my extension!"}
+```
+
+This creates a tool that AI agents can call by name. The tool name defaults to 
the function name.
+
+### Decorator Parameters
+
+The `@tool` decorator accepts several optional parameters:
+
+**Parameter details:**
+- **`name`**: Tool identifier (AI agents use this to call your tool)
+- **`description`**: Explains what the tool does (helps AI agents decide when 
to use it)
+- **`tags`**: Categories for organization and discovery
+- **`secure`**: Whether the tool requires user authentication (defaults to 
`True`)

Review Comment:
   ```suggestion
   - **`protect`**: Whether the tool requires user authentication (defaults to 
`True`)
   ```



##########
superset/mcp_service/chart/prompts/create_chart_guided.py:
##########
@@ -21,14 +21,12 @@
 
 import logging
 
-from superset.mcp_service.app import mcp
-from superset.mcp_service.auth import mcp_auth_hook
+from superset_core.mcp import prompt
 
 logger = logging.getLogger(__name__)
 
 
[email protected]("create_chart_guided")
-@mcp_auth_hook
+@prompt("create_chart_guided")

Review Comment:
   ```
   # Files still using @mcp.resource + @mcp_auth_hook:
   - superset/mcp_service/system/resources/instance_metadata.py:30-31
   - superset/mcp_service/chart/resources/chart_configs.py:30-31
   ```



##########
superset/core/mcp/core_mcp_injection.py:
##########
@@ -0,0 +1,225 @@
+# 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.
+
+"""
+MCP dependency injection implementation.
+
+This module provides the concrete implementation of MCP abstractions
+that replaces the abstract functions in superset-core during initialization.
+"""
+
+import logging
+from typing import Any, Callable, Optional, TypeVar
+
+# Type variable for decorated functions
+F = TypeVar("F", bound=Callable[..., Any])
+
+logger = logging.getLogger(__name__)
+
+
+def create_tool_decorator(
+    func_or_name: str | Callable[..., Any] | None = None,
+    *,
+    name: Optional[str] = None,
+    description: Optional[str] = None,
+    tags: Optional[list[str]] = None,
+    protect: bool = True,
+) -> Callable[[F], F] | F:

Review Comment:
   ```
   # Current:
   def create_tool_decorator(...) -> Callable[[F], F] | F:
   
   # Consider using TypeVar for better type inference:
   _F = TypeVar("_F", bound=Callable[..., Any])
   def create_tool_decorator(...) -> Callable[[_F], _F] | _F:
   ```



-- 
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