mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 15:19:10 +02:00
fix(cli): forward stateless flag in uv run path (#4177)
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
This commit is contained in:
parent
81a16ed27f
commit
dbf5ee24be
2 changed files with 38 additions and 0 deletions
|
|
@ -727,6 +727,8 @@ async def run(
|
|||
inner_cmd.extend(["--log-level", final_log_level])
|
||||
if final_no_banner:
|
||||
inner_cmd.append("--no-banner")
|
||||
if stateless:
|
||||
inner_cmd.append("--stateless")
|
||||
# Add skip-env flag to prevent infinite recursion
|
||||
inner_cmd.append("--skip-env")
|
||||
|
||||
|
|
|
|||
|
|
@ -960,6 +960,42 @@ class TestRunWithReloadWithServerArgs:
|
|||
assert any("Detected changes" in record.message for record in caplog.records)
|
||||
assert call_count == 2, f"Restart logic was not triggered for {reload_cmd}"
|
||||
|
||||
async def test_run_with_needs_uv_forwards_stateless_flag(self):
|
||||
"""`--stateless` should survive the uv-wrapped subprocess path."""
|
||||
mock_config = MagicMock()
|
||||
mock_config.deployment.transport = None
|
||||
mock_config.deployment.host = None
|
||||
mock_config.deployment.port = None
|
||||
mock_config.deployment.path = None
|
||||
mock_config.deployment.log_level = None
|
||||
mock_config.deployment.args = ()
|
||||
mock_config.environment.build_command = lambda cmd: ["uv", "run", *cmd]
|
||||
|
||||
mock_result = MagicMock()
|
||||
mock_result.returncode = 0
|
||||
|
||||
with (
|
||||
patch(
|
||||
"fastmcp.cli.cli.load_and_merge_config",
|
||||
return_value=(mock_config, "server.py"),
|
||||
),
|
||||
patch(
|
||||
"fastmcp.cli.cli.subprocess.run", return_value=mock_result
|
||||
) as mock_run,
|
||||
pytest.raises(SystemExit) as exc_info,
|
||||
):
|
||||
await run("server.py", stateless=True)
|
||||
|
||||
assert exc_info.value.code == 0
|
||||
cmd = mock_run.call_args.args[0]
|
||||
assert "--stateless" in cmd
|
||||
assert cmd[cmd.index("--stateless") - 3 : cmd.index("--stateless") + 1] == [
|
||||
"fastmcp",
|
||||
"run",
|
||||
"server.py",
|
||||
"--stateless",
|
||||
]
|
||||
|
||||
|
||||
class TestInspectorModuleMode:
|
||||
"""Test the inspector command's module-mode handling."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue