Fix import

This commit is contained in:
Jeremiah Lowin 2025-05-31 20:30:36 -04:00
commit 97c9b9cbe4

View file

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