mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-06-10 17:35:57 +00:00
The official MCP configuration schema uses `transport` to specify the transport mechanism (stdio/sse/http), but `McpServerConfig` only honored `type` and defaulted to `stdio`. Remote MCP servers configured with just `transport: sse` were therefore misidentified as stdio and failed with "with stdio transport requires 'command' field". Add a model validator that promotes `transport` to `type` when only `transport` is provided, while keeping `type` authoritative when both are set. This matches the MCP-spec field name without breaking existing configurations. Fixes #3238
This commit is contained in:
@@ -83,6 +83,41 @@ def test_build_server_params_rejects_unsupported_transport():
|
||||
build_server_params("bad-transport", config)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("transport", ["sse", "http"])
|
||||
def test_mcp_server_config_accepts_transport_alias(transport: str):
|
||||
"""The MCP-spec ``transport`` field should be accepted as an alias for ``type``.
|
||||
|
||||
Regression test for https://github.com/bytedance/deer-flow/issues/3238 — a
|
||||
remote MCP server configured with only ``transport: sse`` was previously
|
||||
misidentified as ``stdio`` (the default for ``type``).
|
||||
"""
|
||||
config = McpServerConfig.model_validate(
|
||||
{
|
||||
"transport": transport,
|
||||
"url": "https://example.com/mcp",
|
||||
}
|
||||
)
|
||||
|
||||
assert config.type == transport
|
||||
|
||||
params = build_server_params("aliased-server", config)
|
||||
assert params["transport"] == transport
|
||||
assert params["url"] == "https://example.com/mcp"
|
||||
|
||||
|
||||
def test_mcp_server_config_type_takes_precedence_over_transport():
|
||||
"""When both ``type`` and ``transport`` are provided, ``type`` wins."""
|
||||
config = McpServerConfig.model_validate(
|
||||
{
|
||||
"type": "http",
|
||||
"transport": "sse",
|
||||
"url": "https://example.com/mcp",
|
||||
}
|
||||
)
|
||||
|
||||
assert config.type == "http"
|
||||
|
||||
|
||||
def test_build_servers_config_returns_empty_when_no_enabled_servers():
|
||||
extensions = ExtensionsConfig(
|
||||
mcp_servers={
|
||||
|
||||
Reference in New Issue
Block a user