add default transport
This commit is contained in:
parent
720db80ae9
commit
d6334aa655
@ -24,20 +24,10 @@ async def init_agent(model_name="qwen3-next", api_key=None,
|
||||
system = system_prompt if system_prompt else read_system_prompt()
|
||||
mcp = mcp if mcp else read_mcp_settings()
|
||||
# 修改mcp[0]["mcpServers"]列表,把 type 字段改成 transport ,如果没有的话,就默认transport:stdio
|
||||
if mcp and len(mcp) > 0 and "mcpServers" in mcp[0]:
|
||||
for server_name, server_config in mcp[0]["mcpServers"].items():
|
||||
if isinstance(server_config, dict):
|
||||
if "type" in server_config and "transport" not in server_config:
|
||||
# 如果有 type 字段但没有 transport 字段,将 type 改为 transport
|
||||
type_value = server_config.pop("type")
|
||||
# 特殊处理:'streamable-http' 改为 'http'
|
||||
if type_value == "streamable-http":
|
||||
server_config["transport"] = "http"
|
||||
else:
|
||||
server_config["transport"] = type_value
|
||||
elif "transport" not in server_config:
|
||||
# 如果既没有 type 也没有 transport,添加默认的 transport: stdio
|
||||
server_config["transport"] = "stdio"
|
||||
if mcp and "mcpServers" in mcp[0]:
|
||||
for cfg in mcp[0]["mcpServers"].values():
|
||||
if "transport" not in cfg:
|
||||
cfg["transport"] = "http" if "url" in cfg else "stdio"
|
||||
|
||||
mcp_client = MultiServerMCPClient(mcp[0]["mcpServers"])
|
||||
mcp_tools = await mcp_client.get_tools()
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
{
|
||||
"mcpServers": {
|
||||
"semantic_search": {
|
||||
"transport": "stdio",
|
||||
"command": "python",
|
||||
"args": [
|
||||
"./mcp/semantic_search_server.py",
|
||||
@ -9,6 +10,7 @@
|
||||
]
|
||||
},
|
||||
"multi_keyword": {
|
||||
"transport": "stdio",
|
||||
"command": "python",
|
||||
"args": [
|
||||
"./mcp/multi_keyword_search_server.py",
|
||||
@ -16,6 +18,7 @@
|
||||
]
|
||||
},
|
||||
"datetime": {
|
||||
"transport": "stdio",
|
||||
"command": "python",
|
||||
"args": [
|
||||
"./mcp/datetime_server.py"
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
{
|
||||
"mcpServers": {
|
||||
"semantic_search": {
|
||||
"transport": "stdio",
|
||||
"command": "python",
|
||||
"args": [
|
||||
"./mcp/semantic_search_server.py",
|
||||
@ -9,6 +10,7 @@
|
||||
]
|
||||
},
|
||||
"multi_keyword": {
|
||||
"transport": "stdio",
|
||||
"command": "python",
|
||||
"args": [
|
||||
"./mcp/multi_keyword_search_server.py",
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
{
|
||||
"mcpServers": {
|
||||
"rag_retrieve": {
|
||||
"transport": "stdio",
|
||||
"command": "python",
|
||||
"args": [
|
||||
"./mcp/rag_retrieve_server.py",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user