Skip to content

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

Add config inference test

Jeremiah Lowin02cb6f8291c5
diff --git a/tests/client/test_client.py b/tests/client/test_client.py
index efaa7f516..e63f80179 100644
--- a/tests/client/test_client.py
+++ b/tests/client/test_client.py
@@ -10,6 +10,7 @@ from fastmcp.client import Client
from fastmcp.client.transports import (
FastMCPTransport,
SSETransport,
+ StdioTransport,
StreamableHttpTransport,
infer_transport,
)
@@ -640,3 +641,31 @@ class TestInferTransport:
def test_url_returns_streamable_http_transport(self, url):
"""Test that URLs without /sse/ pattern return StreamableHttpTransport."""
assert isinstance(infer_transport(url), StreamableHttpTransport)
+
+ def test_infer_remote_transport_from_config(self):
+ config = {
+ "mcpServers": {
+ "test_server": {
+ "url": "http://localhost:8000/sse",
+ "headers": {"Authorization": "Bearer 123"},
+ },
+ }
+ }
+ transport = infer_transport(config)
+ assert isinstance(transport, SSETransport)
+ assert transport.url == "http://localhost:8000/sse"
+ assert transport.headers == {"Authorization": "Bearer 123"}
+
+ def test_infer_local_transport_from_config(self):
+ config = {
+ "mcpServers": {
+ "test_server": {
+ "command": "echo",
+ "args": ["hello"],
+ },
+ }
+ }
+ transport = infer_transport(config)
+ assert isinstance(transport, StdioTransport)
+ assert transport.command == "echo"
+ assert transport.args == ["hello"]