fix: don't pass HTTP kwargs to run_async when transport is unspecified (#3838)

When transport is None (the default), run_async resolves it to
settings.transport which defaults to "stdio". The previous guard
`transport != "stdio"` passed HTTP kwargs through for None transport,
causing TypeError in run_stdio_async.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bill Easton 2026-04-12 11:51:34 -05:00 committed by GitHub
commit 74797c8cac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,6 +15,7 @@ from typing import Any, Literal
from mcp.server.fastmcp import FastMCP as FastMCP1x
from watchfiles import Change, awatch
import fastmcp
from fastmcp.server.server import FastMCP, create_proxy
from fastmcp.utilities.logging import get_logger
from fastmcp.utilities.mcp_server_config import (
@ -240,8 +241,13 @@ async def run_command(
kwargs = {}
if transport is not None:
kwargs["transport"] = transport
# Only pass HTTP-specific options for non-stdio transports
if transport != "stdio":
# Resolve effective transport for the HTTP kwargs guard — transport
# may be None here if the user didn't pass --transport, in which case
# run_async will resolve it from settings.transport.
effective_transport = (
transport if transport is not None else fastmcp.settings.transport
)
if effective_transport != "stdio":
if host is not None:
kwargs["host"] = host
if port is not None: