Jeremiah Lowin commited on
Commit
c1940a6
·
1 Parent(s): 0fa02ae

Add "http" as an alias for streamable-http

Browse files
src/fastmcp/client/transports.py CHANGED
@@ -736,11 +736,11 @@ class MCPConfigTransport(ClientTransport):
736
  "mcpServers": {
737
  "weather": {
738
  "url": "https://weather-api.example.com/mcp",
739
- "transport": "streamable-http"
740
  },
741
  "calendar": {
742
  "url": "https://calendar-api.example.com/mcp",
743
- "transport": "streamable-http"
744
  }
745
  }
746
  }
 
736
  "mcpServers": {
737
  "weather": {
738
  "url": "https://weather-api.example.com/mcp",
739
+ "transport": "http"
740
  },
741
  "calendar": {
742
  "url": "https://calendar-api.example.com/mcp",
743
+ "transport": "http"
744
  }
745
  }
746
  }
tests/auth/providers/test_bearer.py CHANGED
@@ -65,7 +65,7 @@ def mcp_server_url(rsa_key_pair: RSAKeyPair) -> Generator[str]:
65
  with run_server_in_process(
66
  run_mcp_server,
67
  public_key=rsa_key_pair.public_key,
68
- run_kwargs=dict(transport="streamable-http"),
69
  ) as url:
70
  yield f"{url}/mcp/"
71
 
@@ -696,7 +696,7 @@ class TestFastMCPBearerAuth:
696
  run_mcp_server,
697
  public_key=rsa_key_pair.public_key,
698
  auth_kwargs=dict(required_scopes=["read", "write"]),
699
- run_kwargs=dict(transport="streamable-http"),
700
  ) as url:
701
  mcp_server_url = f"{url}/mcp/"
702
  with pytest.raises(httpx.HTTPStatusError) as exc_info:
@@ -719,7 +719,7 @@ class TestFastMCPBearerAuth:
719
  run_mcp_server,
720
  public_key=rsa_key_pair.public_key,
721
  auth_kwargs=dict(required_scopes=["read", "write"]),
722
- run_kwargs=dict(transport="streamable-http"),
723
  ) as url:
724
  mcp_server_url = f"{url}/mcp/"
725
  async with Client(mcp_server_url, auth=BearerAuth(token)) as client:
 
65
  with run_server_in_process(
66
  run_mcp_server,
67
  public_key=rsa_key_pair.public_key,
68
+ run_kwargs=dict(transport="http"),
69
  ) as url:
70
  yield f"{url}/mcp/"
71
 
 
696
  run_mcp_server,
697
  public_key=rsa_key_pair.public_key,
698
  auth_kwargs=dict(required_scopes=["read", "write"]),
699
+ run_kwargs=dict(transport="http"),
700
  ) as url:
701
  mcp_server_url = f"{url}/mcp/"
702
  with pytest.raises(httpx.HTTPStatusError) as exc_info:
 
719
  run_mcp_server,
720
  public_key=rsa_key_pair.public_key,
721
  auth_kwargs=dict(required_scopes=["read", "write"]),
722
+ run_kwargs=dict(transport="http"),
723
  ) as url:
724
  mcp_server_url = f"{url}/mcp/"
725
  async with Client(mcp_server_url, auth=BearerAuth(token)) as client:
tests/auth/test_oauth_client.py CHANGED
@@ -43,7 +43,7 @@ def run_server(host: str, port: int, **kwargs) -> None:
43
 
44
  @pytest.fixture(scope="module")
45
  def streamable_http_server() -> Generator[str, None, None]:
46
- with run_server_in_process(run_server, transport="streamable-http") as url:
47
  yield f"{url}/mcp/"
48
 
49
 
 
43
 
44
  @pytest.fixture(scope="module")
45
  def streamable_http_server() -> Generator[str, None, None]:
46
+ with run_server_in_process(run_server, transport="http") as url:
47
  yield f"{url}/mcp/"
48
 
49
 
tests/client/test_openapi.py CHANGED
@@ -56,7 +56,7 @@ def run_proxy_server(host: str, port: int, shttp_url: str, **kwargs) -> None:
56
  class TestClientHeaders:
57
  @pytest.fixture(scope="class")
58
  def shttp_server(self) -> Generator[str, None, None]:
59
- with run_server_in_process(run_server, transport="streamable-http") as url:
60
  yield f"{url}/mcp/"
61
 
62
  @pytest.fixture(scope="class")
@@ -69,7 +69,7 @@ class TestClientHeaders:
69
  with run_server_in_process(
70
  run_proxy_server,
71
  shttp_url=shttp_server,
72
- transport="streamable-http",
73
  ) as url:
74
  yield f"{url}/mcp/"
75
 
 
56
  class TestClientHeaders:
57
  @pytest.fixture(scope="class")
58
  def shttp_server(self) -> Generator[str, None, None]:
59
+ with run_server_in_process(run_server, transport="http") as url:
60
  yield f"{url}/mcp/"
61
 
62
  @pytest.fixture(scope="class")
 
69
  with run_server_in_process(
70
  run_proxy_server,
71
  shttp_url=shttp_server,
72
+ transport="http",
73
  ) as url:
74
  yield f"{url}/mcp/"
75
 
tests/client/test_streamable_http.py CHANGED
@@ -103,13 +103,23 @@ async def streamable_http_server(
103
  stateless_http: bool = False,
104
  ) -> AsyncGenerator[str, None]:
105
  with run_server_in_process(
106
- run_server, stateless_http=stateless_http, transport="streamable-http"
107
  ) as url:
108
  async with Client(transport=StreamableHttpTransport(f"{url}/mcp/")) as client:
109
  assert await client.ping()
110
  yield f"{url}/mcp/"
111
 
112
 
 
 
 
 
 
 
 
 
 
 
113
  async def test_ping(streamable_http_server: str):
114
  """Test pinging the server."""
115
  async with Client(
@@ -119,6 +129,19 @@ async def test_ping(streamable_http_server: str):
119
  assert result is True
120
 
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  async def test_http_headers(streamable_http_server: str):
123
  """Test getting HTTP headers from the server."""
124
  async with Client(
 
103
  stateless_http: bool = False,
104
  ) -> AsyncGenerator[str, None]:
105
  with run_server_in_process(
106
+ run_server, stateless_http=stateless_http, transport="http"
107
  ) as url:
108
  async with Client(transport=StreamableHttpTransport(f"{url}/mcp/")) as client:
109
  assert await client.ping()
110
  yield f"{url}/mcp/"
111
 
112
 
113
+ async def streamable_http_server_with_streamable_http_alias() -> AsyncGenerator[
114
+ str, None
115
+ ]:
116
+ """Test that the "streamable-http" transport alias works."""
117
+ with run_server_in_process(run_server, transport="streamable-http") as url:
118
+ async with Client(transport=StreamableHttpTransport(f"{url}/mcp/")) as client:
119
+ assert await client.ping()
120
+ yield f"{url}/mcp/"
121
+
122
+
123
  async def test_ping(streamable_http_server: str):
124
  """Test pinging the server."""
125
  async with Client(
 
129
  assert result is True
130
 
131
 
132
+ async def test_ping_with_streamable_http_alias(
133
+ streamable_http_server_with_streamable_http_alias: str,
134
+ ):
135
+ """Test pinging the server."""
136
+ async with Client(
137
+ transport=StreamableHttpTransport(
138
+ streamable_http_server_with_streamable_http_alias
139
+ )
140
+ ) as client:
141
+ result = await client.ping()
142
+ assert result is True
143
+
144
+
145
  async def test_http_headers(streamable_http_server: str):
146
  """Test getting HTTP headers from the server."""
147
  async with Client(
tests/server/http/test_http_dependencies.py CHANGED
@@ -44,7 +44,7 @@ def run_server(host: str, port: int, **kwargs) -> None:
44
 
45
  @pytest.fixture(autouse=True, scope="module")
46
  def shttp_server() -> Generator[str, None, None]:
47
- with run_server_in_process(run_server, transport="streamable-http") as url:
48
  yield f"{url}/mcp/"
49
 
50
 
 
44
 
45
  @pytest.fixture(autouse=True, scope="module")
46
  def shttp_server() -> Generator[str, None, None]:
47
+ with run_server_in_process(run_server, transport="http") as url:
48
  yield f"{url}/mcp/"
49
 
50
 
tests/server/http/test_http_middleware.py CHANGED
@@ -96,7 +96,7 @@ async def test_streamable_http_app_with_custom_middleware():
96
  server._additional_http_routes = routes
97
 
98
  # Create the app with custom middleware
99
- app = server.http_app(transport="streamable-http", middleware=custom_middleware)
100
 
101
  # Create a test client
102
  transport = ASGITransport(app=app)
 
96
  server._additional_http_routes = routes
97
 
98
  # Create the app with custom middleware
99
+ app = server.http_app(transport="http", middleware=custom_middleware)
100
 
101
  # Create a test client
102
  transport = ASGITransport(app=app)