π The fast, Pythonic way to build MCP servers and clients.
Updates to tests
William Easton185bb477132f
diff --git a/src/fastmcp/client/transports.py b/src/fastmcp/client/transports.pyindex 71aa8c855..3c067b14f 100644--- a/src/fastmcp/client/transports.py+++ b/src/fastmcp/client/transports.py@@ -3,7 +3,6 @@ import asyncioimport contextlibimport datetimeimport os-import secretsimport shutilimport sysimport warningsdiff --git a/src/fastmcp/mcp_config.py b/src/fastmcp/mcp_config.pyindex fde181dc7..47e248c76 100644--- a/src/fastmcp/mcp_config.py+++ b/src/fastmcp/mcp_config.py@@ -27,7 +27,7 @@ from __future__ import annotationsimport datetimeimport refrom pathlib import Path-from typing import TYPE_CHECKING, Annotated, Any, Literal+from typing import TYPE_CHECKING, Annotated, Any, Literal, castfrom urllib.parse import urlparseimport httpx@@ -97,8 +97,12 @@ class _TransformingMCPServerMixin(FastMCPBaseModel):"""Turn the Transforming MCPServer into a FastMCP Server and also return the underlying transport."""from fastmcp import FastMCPfrom fastmcp.client import Client+ from fastmcp.client.transports import (+ ClientTransport, # pyright: ignore[reportUnusedImport]+ )- transport: ClientTransport = self.to_transport()+ transport: ClientTransport = super().to_transport() # pyright: ignore[reportUnknownMemberType, reportAttributeAccessIssue, reportUnknownVariableType]+ transport = cast(ClientTransport, transport)client: Client[ClientTransport] = Client(transport=transport, name=client_name)diff --git a/src/fastmcp/server/proxy.py b/src/fastmcp/server/proxy.pyindex 4fcce6b69..9de5da845 100644--- a/src/fastmcp/server/proxy.py+++ b/src/fastmcp/server/proxy.py@@ -1,7 +1,6 @@from __future__ import annotationsimport inspect-import secretsimport warningsfrom collections.abc import Awaitable, Callablefrom pathlib import Path@@ -550,7 +549,6 @@ class ProxyClient(Client[ClientTransportT]):| str,**kwargs,):-if "name" not in kwargs:kwargs["name"] = self.generate_name()if "roots" not in kwargs:diff --git a/src/fastmcp/utilities/mcp_config.py b/src/fastmcp/utilities/mcp_config.pyindex a1f3888f3..32b5e88e8 100644--- a/src/fastmcp/utilities/mcp_config.py+++ b/src/fastmcp/utilities/mcp_config.py@@ -1,6 +1,5 @@from typing import Any-from fastmcp.client import Clientfrom fastmcp.client.transports import (ClientTransport,SSETransport,@@ -11,8 +10,8 @@ from fastmcp.mcp_config import (MCPConfig,MCPServerTypes,)-from fastmcp.server.server import FastMCPfrom fastmcp.server.proxy import ProxyClient+from fastmcp.server.server import FastMCPdef mcp_config_to_servers_and_transports(diff --git a/tests/server/proxy/test_proxy_server.py b/tests/server/proxy/test_proxy_server.pyindex 12873b6a5..561353084 100644--- a/tests/server/proxy/test_proxy_server.py+++ b/tests/server/proxy/test_proxy_server.py@@ -87,7 +87,7 @@ async def test_create_proxy(fastmcp_server):assert isinstance(server, FastMCPProxy)assert isinstance(server, FastMCP)- assert server.name.startswith("FastMCP-")+ assert server.name.startswith("FastMCPProxy-")async def test_as_proxy_with_server(fastmcp_server):diff --git a/tests/server/test_mount.py b/tests/server/test_mount.pyindex 2defe3578..8fde83446 100644--- a/tests/server/test_mount.py+++ b/tests/server/test_mount.py@@ -290,18 +290,21 @@ class TestMultipleServerMount:# Use an unreachable portunreachable_client = Client(- transport=SSETransport("http://127.0.0.1:9999/sse/")+ transport=SSETransport("http://127.0.0.1:9999/sse/"),+ name="unreachable_client",)# Create a proxy server that will fail to connect- unreachable_proxy = FastMCP.as_proxy(unreachable_client)+ unreachable_proxy = FastMCP.as_proxy(+ unreachable_client, name="unreachable_proxy"+ )# Mount the unreachable proxymain_app.mount(unreachable_proxy, "unreachable")# All object types should work from working server despite unreachable proxywith caplog_for_fastmcp(caplog):- async with Client(main_app) as client:+ async with Client(main_app, name="main_app_client") as client:# Test toolstools = await client.list_tools()tool_names = [tool.name for tool in tools]@@ -326,17 +329,17 @@ class TestMultipleServerMount:record.message for record in caplog.records if record.levelname == "WARNING"]assert any(- "Failed to get tools from server: 'FastMCP', mounted at: 'unreachable'"+ "Failed to get tools from server: 'unreachable_proxy', mounted at: 'unreachable'"in msgfor msg in warning_messages)assert any(- "Failed to get resources from server: 'FastMCP', mounted at: 'unreachable'"+ "Failed to get resources from server: 'unreachable_proxy', mounted at: 'unreachable'"in msgfor msg in warning_messages)assert any(- "Failed to get prompts from server: 'FastMCP', mounted at: 'unreachable'"+ "Failed to get prompts from server: 'unreachable_proxy', mounted at: 'unreachable'"in msgfor msg in warning_messages)