π The fast, Pythonic way to build MCP servers and clients.
Add Any annotations to args and kwargs
claude[bot]d16c69a46d38
diff --git a/src/fastmcp/client/client.py b/src/fastmcp/client/client.pyindex 68716a801..c1957c277 100644--- a/src/fastmcp/client/client.py+++ b/src/fastmcp/client/client.py@@ -155,38 +155,38 @@ class Client(Generic[ClientTransportT]):"""@overload- def __init__(self: Client[T], transport: T, *args, **kwargs) -> None: ...+ def __init__(self: Client[T], transport: T, *args: Any, **kwargs: Any) -> None: ...@overloaddef __init__(self: Client[SSETransport | StreamableHttpTransport],transport: AnyUrl,- *args,- **kwargs,+ *args: Any,+ **kwargs: Any,) -> None: ...@overloaddef __init__(self: Client[FastMCPTransport],transport: FastMCP | FastMCP1Server,- *args,- **kwargs,+ *args: Any,+ **kwargs: Any,) -> None: ...@overloaddef __init__(self: Client[PythonStdioTransport | NodeStdioTransport],transport: Path,- *args,- **kwargs,+ *args: Any,+ **kwargs: Any,) -> None: ...@overloaddef __init__(self: Client[MCPConfigTransport],transport: MCPConfig | dict[str, Any],- *args,- **kwargs,+ *args: Any,+ **kwargs: Any,) -> None: ...@overload@@ -198,8 +198,8 @@ class Client(Generic[ClientTransportT]):| StreamableHttpTransport],transport: str,- *args,- **kwargs,+ *args: Any,+ **kwargs: Any,) -> None: ...def __init__(diff --git a/src/fastmcp/server/auth/oauth_proxy.py b/src/fastmcp/server/auth/oauth_proxy.pyindex 97f5e7526..8400aa68a 100644--- a/src/fastmcp/server/auth/oauth_proxy.py+++ b/src/fastmcp/server/auth/oauth_proxy.py@@ -89,7 +89,10 @@ class ProxyDCRClient(OAuthClientInformationFull):"""def __init__(- self, *args, allowed_redirect_uri_patterns: list[str] | None = None, **kwargs+ self,+ *args: Any,+ allowed_redirect_uri_patterns: list[str] | None = None,+ **kwargs: Any,):"""Initialize with allowed redirect URI patterns.diff --git a/src/fastmcp/server/low_level.py b/src/fastmcp/server/low_level.pyindex 7dd3e9d4b..eb9e87c2a 100644--- a/src/fastmcp/server/low_level.py+++ b/src/fastmcp/server/low_level.py@@ -12,7 +12,7 @@ from mcp.server.models import InitializationOptionsclass LowLevelServer(_Server[LifespanResultT, RequestT]):- def __init__(self, *args, **kwargs):+ def __init__(self, *args: Any, **kwargs: Any):super().__init__(*args, **kwargs)# FastMCP servers support notifications for all componentsself.notification_options = NotificationOptions(diff --git a/src/fastmcp/server/proxy.py b/src/fastmcp/server/proxy.pyindex 57ec5facf..6847befcd 100644--- a/src/fastmcp/server/proxy.py+++ b/src/fastmcp/server/proxy.py@@ -69,7 +69,7 @@ class ProxyManagerMixin:class ProxyToolManager(ToolManager, ProxyManagerMixin):"""A ToolManager that sources its tools from a remote client in addition to local and mounted tools."""- def __init__(self, client_factory: ClientFactoryT, **kwargs):+ def __init__(self, client_factory: ClientFactoryT, **kwargs: Any):super().__init__(**kwargs)self.client_factory = client_factory@@ -123,7 +123,7 @@ class ProxyToolManager(ToolManager, ProxyManagerMixin):class ProxyResourceManager(ResourceManager, ProxyManagerMixin):"""A ResourceManager that sources its resources from a remote client in addition to local and mounted resources."""- def __init__(self, client_factory: ClientFactoryT, **kwargs):+ def __init__(self, client_factory: ClientFactoryT, **kwargs: Any):super().__init__(**kwargs)self.client_factory = client_factory@@ -204,7 +204,7 @@ class ProxyResourceManager(ResourceManager, ProxyManagerMixin):class ProxyPromptManager(PromptManager, ProxyManagerMixin):"""A PromptManager that sources its prompts from a remote client in addition to local and mounted prompts."""- def __init__(self, client_factory: ClientFactoryT, **kwargs):+ def __init__(self, client_factory: ClientFactoryT, **kwargs: Any):super().__init__(**kwargs)self.client_factory = client_factory@@ -258,7 +258,7 @@ class ProxyTool(Tool, MirroredComponent):A Tool that represents and executes a tool on a remote server."""- def __init__(self, client: Client, **kwargs):+ def __init__(self, client: Client, **kwargs: Any):super().__init__(**kwargs)self._client = client@@ -354,7 +354,7 @@ class ProxyTemplate(ResourceTemplate, MirroredComponent):A ResourceTemplate that represents and creates resources from a remote server template."""- def __init__(self, client: Client, **kwargs):+ def __init__(self, client: Client, **kwargs: Any):super().__init__(**kwargs)self._client = client@@ -640,7 +640,7 @@ class StatefulProxyClient(ProxyClient[ClientTransportT]):Note that it is essential to ensure that the proxy server itself is also stateful."""- def __init__(self, *args, **kwargs):+ def __init__(self, *args: Any, **kwargs: Any):super().__init__(*args, **kwargs)self._caches: dict[ServerSession, Client[ClientTransportT]] = {}diff --git a/src/fastmcp/tools/tool_transform.py b/src/fastmcp/tools/tool_transform.pyindex c1bd5b69e..0cc5ed960 100644--- a/src/fastmcp/tools/tool_transform.py+++ b/src/fastmcp/tools/tool_transform.py@@ -34,7 +34,7 @@ _current_tool: ContextVar[TransformedTool | None] = ContextVar( # type: ignore[)-async def forward(**kwargs) -> ToolResult:+async def forward(**kwargs: Any) -> ToolResult:"""Forward to parent tool with argument transformation applied.This function can only be called from within a transformed tool's custom@@ -64,7 +64,7 @@ async def forward(**kwargs) -> ToolResult:return await tool.forwarding_fn(**kwargs)-async def forward_raw(**kwargs) -> ToolResult:+async def forward_raw(**kwargs: Any) -> ToolResult:"""Forward directly to parent tool without transformation.This function bypasses all argument transformation and validation, calling the parent@@ -681,7 +681,7 @@ class TransformedTool(Tool):schema = compress_schema(schema, prune_defs=True)# Create forwarding function that closes over everything it needs- async def _forward(**kwargs):+ async def _forward(**kwargs: Any):# Validate argumentsvalid_args = set(new_props.keys())provided_args = set(kwargs.keys())diff --git a/src/fastmcp/utilities/tests.py b/src/fastmcp/utilities/tests.pyindex 9d0efeaca..ce175e221 100644--- a/src/fastmcp/utilities/tests.py+++ b/src/fastmcp/utilities/tests.py@@ -75,11 +75,11 @@ def _run_server(mcp_server: FastMCP, transport: Literal["sse"], port: int) -> No@contextmanagerdef run_server_in_process(server_fn: Callable[..., None],- *args,+ *args: Any,provide_host_and_port: bool = True,host: str = "127.0.0.1",port: int | None = None,- **kwargs,+ **kwargs: Any,) -> Generator[str, None, None]:"""Context manager that runs a FastMCP server in a separate process and