π OpenHands: AI-Driven Development
Fix FastMCP authentication API breaking change (#11416)
Tim O'Farrell1ebc3ab04e6d
diff --git a/openhands/runtime/mcp/proxy/manager.py b/openhands/runtime/mcp/proxy/manager.pyindex e3c0c675ca..a9234de30b 100644--- a/openhands/runtime/mcp/proxy/manager.py+++ b/openhands/runtime/mcp/proxy/manager.py@@ -10,6 +10,7 @@ from typing import Any, Optionalfrom anyio import get_cancelled_exc_classfrom fastapi import FastAPIfrom fastmcp import FastMCP+from fastmcp.server.auth import StaticTokenVerifierfrom fastmcp.utilities.logging import get_logger as fastmcp_get_loggerfrom openhands.core.config.mcp_config import MCPStdioServerConfig@@ -59,11 +60,21 @@ class MCPProxyManager:)return None+ # Create authentication provider if auth is enabled+ auth_provider = None+ if self.auth_enabled and self.api_key:+ # Use StaticTokenVerifier for simple API key authentication+ auth_provider = StaticTokenVerifier(+ {self.api_key: {'client_id': 'openhands', 'scopes': []}}+ )+ logger.info('FastMCP Proxy authentication enabled')+ else:+ logger.info('FastMCP Proxy authentication disabled')+# Create a new proxy with the current configurationself.proxy = FastMCP.as_proxy(self.config,- auth_enabled=self.auth_enabled,- api_key=self.api_key,+ auth=auth_provider,)logger.info('FastMCP Proxy initialized successfully')diff --git a/poetry.lock b/poetry.lockindex 7c4ecdf4f0..f563ac871a 100644--- a/poetry.lock+++ b/poetry.lock@@ -1,4 +1,4 @@-# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand.+# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand.[[package]]name = "aiofiles"@@ -12608,4 +12608,4 @@ third-party-runtimes = ["daytona", "e2b-code-interpreter", "modal", "runloop-api[metadata]lock-version = "2.1"python-versions = "^3.12,<3.14"-content-hash = "6973cf1c9ccb0d6926006697ae4863bcd0ab740a88f09fc17c205e016782cf77"+content-hash = "38201ae2a56788a893231d07f66974285f3cd70b670aa1d0e36374e3febf03b9"diff --git a/pyproject.toml b/pyproject.tomlindex 5f587d382f..00725dcd7a 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -73,7 +73,7 @@ prompt-toolkit = "^3.0.50"poetry = "^2.1.2"anyio = "4.9.0"pythonnet = "*"-fastmcp = "^2.5.2"+fastmcp = "^2.12.4" # Note: 2.12.0+ has breaking auth API changespython-frontmatter = "^1.1.0"shellingham = "^1.5.4"# TODO: Should these go into the runtime group?