Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Fix import

Jeremiah Lowin97c9b9cbe449
diff --git a/src/fastmcp/client/transports.py b/src/fastmcp/client/transports.py
index cafe9588c..5ab1d9a9e 100644
--- a/src/fastmcp/client/transports.py
+++ b/src/fastmcp/client/transports.py
@@ -37,7 +37,6 @@ from pydantic import AnyUrl
from typing_extensions import Unpack
from fastmcp.client.auth import OAuth
-from fastmcp.server import FastMCP as FastMCPServer
from fastmcp.server.dependencies import get_http_headers
from fastmcp.server.server import FastMCP
from fastmcp.utilities.logging import get_logger
@@ -55,7 +54,6 @@ __all__ = [
"ClientTransport",
"SSETransport",
"StreamableHttpTransport",
- "FastMCPServer",
"StdioTransport",
"PythonStdioTransport",
"FastMCPStdioTransport",
@@ -656,7 +654,7 @@ class FastMCPTransport(ClientTransport):
tests or scenarios where client and server run in the same runtime.
"""
- def __init__(self, mcp: FastMCPServer | FastMCP1Server):
+ def __init__(self, mcp: FastMCP | FastMCP1Server):
"""Initialize a FastMCPTransport from a FastMCP server instance."""
# Accept both FastMCP 2.x and FastMCP 1.0 servers. Both expose a
@@ -770,7 +768,7 @@ def infer_transport(transport: ClientTransportT) -> ClientTransportT: ...
@overload
-def infer_transport(transport: FastMCPServer) -> FastMCPTransport: ...
+def infer_transport(transport: FastMCP) -> FastMCPTransport: ...
@overload
@@ -805,7 +803,7 @@ def infer_transport(transport: Path) -> PythonStdioTransport | NodeStdioTranspor
def infer_transport(
transport: ClientTransport
- | FastMCPServer
+ | FastMCP
| FastMCP1Server
| AnyUrl
| Path
@@ -822,7 +820,7 @@ def infer_transport(
The function supports these input types:
- ClientTransport: Used directly without modification
- - FastMCPServer or FastMCP1Server: Creates an in-memory FastMCPTransport
+ - FastMCP or FastMCP1Server: Creates an in-memory FastMCPTransport
- Path or str (file path): Creates PythonStdioTransport (.py) or NodeStdioTransport (.js)
- AnyUrl or str (URL): Creates StreamableHttpTransport (default) or SSETransport (for /sse endpoints)
- MCPConfig or dict: Creates MCPConfigTransport, potentially connecting to multiple servers
@@ -860,7 +858,7 @@ def infer_transport(
return transport
# the transport is a FastMCP server (2.x or 1.0)
- elif isinstance(transport, FastMCPServer | FastMCP1Server):
+ elif isinstance(transport, FastMCP | FastMCP1Server):
inferred_transport = FastMCPTransport(mcp=transport)
# the transport is a path to a script