Jeremiah Lowin commited on
Commit
2e1c8b2
·
unverified ·
1 Parent(s): 25428f8

Ensure the CLI accepts "streamable-http" as a valid transport (#1099)

Browse files

* Ensure the CLI accepts "streamable-http" as a valid transport

* Add test for transport aliases

src/fastmcp/cli/cli.py CHANGED
@@ -246,7 +246,7 @@ def run(
246
  server_spec: str,
247
  *,
248
  transport: Annotated[
249
- Literal["stdio", "http", "sse"] | None,
250
  cyclopts.Parameter(
251
  name=["--transport", "-t"],
252
  help="Transport protocol to use",
 
246
  server_spec: str,
247
  *,
248
  transport: Annotated[
249
+ run_module.TransportType | None,
250
  cyclopts.Parameter(
251
  name=["--transport", "-t"],
252
  help="Transport protocol to use",
src/fastmcp/cli/run.py CHANGED
@@ -11,7 +11,7 @@ from fastmcp.utilities.logging import get_logger
11
  logger = get_logger("cli.run")
12
 
13
  # Type aliases for better type safety
14
- TransportType = Literal["stdio", "http", "sse"]
15
  LogLevelType = Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
16
 
17
 
 
11
  logger = get_logger("cli.run")
12
 
13
  # Type aliases for better type safety
14
+ TransportType = Literal["stdio", "http", "sse", "streamable-http"]
15
  LogLevelType = Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
16
 
17
 
tests/cli/test_cli.py CHANGED
@@ -236,6 +236,32 @@ class TestRunCommand:
236
  assert "log_level" not in bound.arguments
237
  assert "path" not in bound.arguments
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
 
240
  class TestWindowsSpecific:
241
  """Test Windows-specific functionality."""
 
236
  assert "log_level" not in bound.arguments
237
  assert "path" not in bound.arguments
238
 
239
+ def test_run_command_transport_aliases(self):
240
+ """Test that both 'http' and 'streamable-http' are accepted as valid transport options."""
241
+ # Test with 'http' transport
242
+ command, bound, _ = app.parse_args(
243
+ [
244
+ "run",
245
+ "server.py",
246
+ "--transport",
247
+ "http",
248
+ ]
249
+ )
250
+ assert command is not None
251
+ assert bound.arguments["transport"] == "http"
252
+
253
+ # Test with 'streamable-http' transport
254
+ command, bound, _ = app.parse_args(
255
+ [
256
+ "run",
257
+ "server.py",
258
+ "--transport",
259
+ "streamable-http",
260
+ ]
261
+ )
262
+ assert command is not None
263
+ assert bound.arguments["transport"] == "streamable-http"
264
+
265
 
266
  class TestWindowsSpecific:
267
  """Test Windows-specific functionality."""