π The fast, Pythonic way to build MCP servers and clients.
Fix import and remaining available port
Jeremiah Lowin3d454380b15f
diff --git a/src/fastmcp/utilities/tests.py b/src/fastmcp/utilities/tests.pyindex cb697129f..4fa73006e 100644--- a/src/fastmcp/utilities/tests.py+++ b/src/fastmcp/utilities/tests.py@@ -11,6 +11,7 @@ from typing import TYPE_CHECKING, Any, Literalimport uvicornfrom fastmcp.settings import settings+from fastmcp.utilities.http import find_available_portif TYPE_CHECKING:from fastmcp.server.server import FastMCP@@ -84,9 +85,7 @@ def run_server_in_process(The server URL."""host = "127.0.0.1"- with socket.socket() as s:- s.bind((host, 0))- port = s.getsockname()[1]+ port = find_available_port()proc = multiprocessing.Process(target=server_fn, args=(host, port, *args), daemon=Truediff --git a/tests/auth/test_oauth_client.py b/tests/auth/test_oauth_client.pyindex e743e25c3..2a1fd4c23 100644--- a/tests/auth/test_oauth_client.py+++ b/tests/auth/test_oauth_client.py@@ -11,7 +11,7 @@ import fastmcp.client.auth # Import module, not the function directlyfrom fastmcp.client import Clientfrom fastmcp.client.transports import StreamableHttpTransportfrom fastmcp.server.auth.auth import ClientRegistrationOptions-from fastmcp.server.auth.providers.in_memory import InMemory+from fastmcp.server.auth.in_memory_provider import InMemoryOAuthProvider as InMemoryfrom fastmcp.server.server import FastMCPfrom fastmcp.utilities.tests import run_server_in_process