This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 81466987cbb fix(mcp): use create_proxy in simple_proxy for fastmcp 4 
compatibility (#44787)
81466987cbb is described below

commit 81466987cbb233ab04e92b9243791320651d78b9
Author: Amin Ghadersohi <[email protected]>
AuthorDate: Sat Oct 3 15:21:39 2026 +1000

    fix(mcp): use create_proxy in simple_proxy for fastmcp 4 compatibility 
(#44787)
---
 superset/mcp_service/simple_proxy.py      |  6 ++---
 tests/unit_tests/test_mcp_simple_proxy.py | 45 +++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/superset/mcp_service/simple_proxy.py 
b/superset/mcp_service/simple_proxy.py
index 26446c20724..b3453eec4e4 100644
--- a/superset/mcp_service/simple_proxy.py
+++ b/superset/mcp_service/simple_proxy.py
@@ -39,7 +39,7 @@ proxy: FastMCP | None = None
 def signal_handler(signum: int, frame: Any) -> None:
     """Handle shutdown signals gracefully"""
     logger.info("Received signal %s, shutting down gracefully...", signum)
-    # FastMCP.as_proxy() handles its own cleanup
+    # The proxy handles its own cleanup
     sys.exit(0)
 
 
@@ -48,7 +48,7 @@ def main() -> None:
     global proxy
 
     try:
-        from fastmcp import FastMCP
+        from fastmcp.server import create_proxy
 
         # Set up signal handlers for graceful shutdown
         signal.signal(signal.SIGINT, signal_handler)
@@ -57,7 +57,7 @@ def main() -> None:
         logger.info("Starting MCP proxy server...")
 
         # Create a proxy to the remote FastMCP server
-        proxy = FastMCP.as_proxy("http://localhost:5008/mcp/";, name="MCP 
Proxy")
+        proxy = create_proxy("http://localhost:5008/mcp/";, name="MCP Proxy")
 
         logger.info("Proxy created successfully, starting...")
 
diff --git a/tests/unit_tests/test_mcp_simple_proxy.py 
b/tests/unit_tests/test_mcp_simple_proxy.py
new file mode 100644
index 00000000000..282817b8f30
--- /dev/null
+++ b/tests/unit_tests/test_mcp_simple_proxy.py
@@ -0,0 +1,45 @@
+# 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.
+
+from importlib import util
+from pathlib import Path
+from unittest.mock import patch
+
+from fastmcp import FastMCP
+from fastmcp.server import create_proxy
+
+
+def test_simple_proxy_builds_and_runs() -> None:
+    """Build the real proxy without starting a transport or changing signal 
handlers."""
+    path = Path(__file__).resolve().parents[2] / 
"superset/mcp_service/simple_proxy.py"
+    spec = util.spec_from_file_location("simple_proxy", path)
+    assert spec is not None
+    assert spec.loader is not None
+    module = util.module_from_spec(spec)
+    spec.loader.exec_module(module)
+
+    with (
+        patch("fastmcp.server.create_proxy", wraps=create_proxy) as 
mock_create,
+        patch.object(FastMCP, "run") as mock_run,
+        patch.object(module.signal, "signal"),
+    ):
+        module.main()
+
+    mock_create.assert_called_once_with("http://localhost:5008/mcp/";, 
name="MCP Proxy")
+    assert isinstance(module.proxy, FastMCP)
+    assert module.proxy.name == "MCP Proxy"
+    mock_run.assert_called_once_with()

Reply via email to