Jeremiah Lowin commited on
Commit
2aa779f
·
1 Parent(s): a9cea6e

Add config inference test

Browse files
Files changed (1) hide show
  1. tests/client/test_client.py +29 -0
tests/client/test_client.py CHANGED
@@ -10,6 +10,7 @@ from fastmcp.client import Client
10
  from fastmcp.client.transports import (
11
  FastMCPTransport,
12
  SSETransport,
 
13
  StreamableHttpTransport,
14
  infer_transport,
15
  )
@@ -640,3 +641,31 @@ class TestInferTransport:
640
  def test_url_returns_streamable_http_transport(self, url):
641
  """Test that URLs without /sse/ pattern return StreamableHttpTransport."""
642
  assert isinstance(infer_transport(url), StreamableHttpTransport)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  from fastmcp.client.transports import (
11
  FastMCPTransport,
12
  SSETransport,
13
+ StdioTransport,
14
  StreamableHttpTransport,
15
  infer_transport,
16
  )
 
641
  def test_url_returns_streamable_http_transport(self, url):
642
  """Test that URLs without /sse/ pattern return StreamableHttpTransport."""
643
  assert isinstance(infer_transport(url), StreamableHttpTransport)
644
+
645
+ def test_infer_remote_transport_from_config(self):
646
+ config = {
647
+ "mcpServers": {
648
+ "test_server": {
649
+ "url": "http://localhost:8000/sse",
650
+ "headers": {"Authorization": "Bearer 123"},
651
+ },
652
+ }
653
+ }
654
+ transport = infer_transport(config)
655
+ assert isinstance(transport, SSETransport)
656
+ assert transport.url == "http://localhost:8000/sse"
657
+ assert transport.headers == {"Authorization": "Bearer 123"}
658
+
659
+ def test_infer_local_transport_from_config(self):
660
+ config = {
661
+ "mcpServers": {
662
+ "test_server": {
663
+ "command": "echo",
664
+ "args": ["hello"],
665
+ },
666
+ }
667
+ }
668
+ transport = infer_transport(config)
669
+ assert isinstance(transport, StdioTransport)
670
+ assert transport.command == "echo"
671
+ assert transport.args == ["hello"]