From 4f4d06ffdb3ab57b57f32a7b1792b0e49ec26f9b Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Wed, 9 Jul 2025 09:35:26 -0400 Subject: [PATCH] Ensure the CLI accepts "streamable-http" as a valid transport (#1099) * Ensure the CLI accepts "streamable-http" as a valid transport * Add test for transport aliases --- src/fastmcp/cli/cli.py | 2 +- src/fastmcp/cli/run.py | 2 +- tests/cli/test_cli.py | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/fastmcp/cli/cli.py b/src/fastmcp/cli/cli.py index fb99960fe..a7ecf771f 100644 --- a/src/fastmcp/cli/cli.py +++ b/src/fastmcp/cli/cli.py @@ -246,7 +246,7 @@ def run( server_spec: str, *, transport: Annotated[ - Literal["stdio", "http", "sse"] | None, + run_module.TransportType | None, cyclopts.Parameter( name=["--transport", "-t"], help="Transport protocol to use", diff --git a/src/fastmcp/cli/run.py b/src/fastmcp/cli/run.py index df8e9d757..373d9cfbb 100644 --- a/src/fastmcp/cli/run.py +++ b/src/fastmcp/cli/run.py @@ -11,7 +11,7 @@ from fastmcp.utilities.logging import get_logger logger = get_logger("cli.run") # Type aliases for better type safety -TransportType = Literal["stdio", "http", "sse"] +TransportType = Literal["stdio", "http", "sse", "streamable-http"] LogLevelType = Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index b546e01d9..097c7b17e 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -236,6 +236,32 @@ class TestRunCommand: assert "log_level" not in bound.arguments assert "path" not in bound.arguments + def test_run_command_transport_aliases(self): + """Test that both 'http' and 'streamable-http' are accepted as valid transport options.""" + # Test with 'http' transport + command, bound, _ = app.parse_args( + [ + "run", + "server.py", + "--transport", + "http", + ] + ) + assert command is not None + assert bound.arguments["transport"] == "http" + + # Test with 'streamable-http' transport + command, bound, _ = app.parse_args( + [ + "run", + "server.py", + "--transport", + "streamable-http", + ] + ) + assert command is not None + assert bound.arguments["transport"] == "streamable-http" + class TestWindowsSpecific: """Test Windows-specific functionality."""