{"record":{"id":"30098a61ef0449b5","repo":"PrefectHQ/fastmcp","slug":"invalid-transport-transport","errorCode":null,"errorMessage":"Invalid transport: {transport}","messagePattern":"Invalid transport: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/utilities/tests.py","lineNumber":73,"sourceCode":"\n    try:\n        # apply the new settings\n        for attr, value in kwargs.items():\n            settings.set_setting(attr, value)\n        yield\n\n    finally:\n        # restore the old settings\n        for attr in kwargs:\n            settings.set_setting(attr, old_settings.get_setting(attr))\n\n\ndef _run_server(mcp_server: FastMCP, transport: Literal[\"sse\"], port: int) -> None:\n    # Some Starlette apps are not pickleable, so we need to create them here based on the indicated transport\n    if transport == \"sse\":\n        app = mcp_server.http_app(transport=\"sse\")\n    else:\n        raise ValueError(f\"Invalid transport: {transport}\")\n    uvicorn_server = uvicorn.Server(\n        config=uvicorn.Config(\n            app=app,\n            host=\"127.0.0.1\",\n            port=port,\n            log_level=\"error\",\n            ws=\"websockets-sansio\",\n        )\n    )\n    uvicorn_server.run()\n\n\n@contextmanager\ndef run_server_in_process(\n    server_fn: Callable[..., None],\n    *args: Any,\n    provide_host_and_port: bool = True,\n    host: str = \"127.0.0.1\",","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/utilities/tests.py#L55-L91","documentation":"The run_server_in_process test helper only supports the 'sse' transport when spawning a server subprocess; any other value hits the else branch and raises ValueError. It exists because Starlette apps are constructed (not pickled) inside the child process based on the transport string.","triggerScenarios":"Passing transport=\"http\"/\"streamable-http\"/\"stdio\" (or a typo like \"https\") to run_server_in_process / mcp_server_url instead of \"sse\".","commonSituations":"Copying test helper code between FastMCP versions where more transports are supported elsewhere; assuming the test utility accepts every transport the client does; simple typos.","solutions":["Use transport=\"sse\" (the only value this helper accepts)","Use a different server-start helper (e.g. run_server_async or http_app directly) for other transports","Fix typos — the literal string must be exactly \"sse\""],"exampleFix":"// before\nwith run_server_in_process(mcp_server, transport=\"http\") as url: ...\n\n// after\nwith run_server_in_process(mcp_server, transport=\"sse\") as url: ...","handlingStrategy":"validation","validationCode":"if transport != \"sse\":\n    raise ValueError(f\"run_server_in_process only supports 'sse', got {transport!r}\")","typeGuard":"def is_supported_transport(t: str) -> bool:\n    return t == \"sse\"","tryCatchPattern":"try:\n    with run_server_in_process(mcp, transport=transport) as url:\n        yield url\nexcept ValueError as e:\n    pytest.skip(f\"unsupported transport for helper: {e}\")","preventionTips":["Only pass \"sse\" to this helper","Use run_server_async for other transports","Define the transport as a Literal[\"sse\"] variable to get static checking"],"tags":["testing","transport","sse","configuration"],"backgroundTag":"invalid-transport-value","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}