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()
|
system = system_prompt if system_prompt else read_system_prompt()
|
||||||
mcp = mcp if mcp else read_mcp_settings()
|
mcp = mcp if mcp else read_mcp_settings()
|
||||||
# 修改mcp[0]["mcpServers"]列表,把 type 字段改成 transport ,如果没有的话,就默认transport:stdio
|
# 修改mcp[0]["mcpServers"]列表,把 type 字段改成 transport ,如果没有的话,就默认transport:stdio
|
||||||
if mcp and len(mcp) > 0 and "mcpServers" in mcp[0]:
|
if mcp and "mcpServers" in mcp[0]:
|
||||||
for server_name, server_config in mcp[0]["mcpServers"].items():
|
for cfg in mcp[0]["mcpServers"].values():
|
||||||
if isinstance(server_config, dict):
|
if "transport" not in cfg:
|
||||||
if "type" in server_config and "transport" not in server_config:
|
cfg["transport"] = "http" if "url" in cfg else "stdio"
|
||||||
# 如果有 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"
|
|
||||||
|
|
||||||
mcp_client = MultiServerMCPClient(mcp[0]["mcpServers"])
|
mcp_client = MultiServerMCPClient(mcp[0]["mcpServers"])
|
||||||
mcp_tools = await mcp_client.get_tools()
|
mcp_tools = await mcp_client.get_tools()
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
"semantic_search": {
|
"semantic_search": {
|
||||||
|
"transport": "stdio",
|
||||||
"command": "python",
|
"command": "python",
|
||||||
"args": [
|
"args": [
|
||||||
"./mcp/semantic_search_server.py",
|
"./mcp/semantic_search_server.py",
|
||||||
@ -9,6 +10,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"multi_keyword": {
|
"multi_keyword": {
|
||||||
|
"transport": "stdio",
|
||||||
"command": "python",
|
"command": "python",
|
||||||
"args": [
|
"args": [
|
||||||
"./mcp/multi_keyword_search_server.py",
|
"./mcp/multi_keyword_search_server.py",
|
||||||
@ -16,6 +18,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
|
"transport": "stdio",
|
||||||
"command": "python",
|
"command": "python",
|
||||||
"args": [
|
"args": [
|
||||||
"./mcp/datetime_server.py"
|
"./mcp/datetime_server.py"
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
"semantic_search": {
|
"semantic_search": {
|
||||||
|
"transport": "stdio",
|
||||||
"command": "python",
|
"command": "python",
|
||||||
"args": [
|
"args": [
|
||||||
"./mcp/semantic_search_server.py",
|
"./mcp/semantic_search_server.py",
|
||||||
@ -9,6 +10,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"multi_keyword": {
|
"multi_keyword": {
|
||||||
|
"transport": "stdio",
|
||||||
"command": "python",
|
"command": "python",
|
||||||
"args": [
|
"args": [
|
||||||
"./mcp/multi_keyword_search_server.py",
|
"./mcp/multi_keyword_search_server.py",
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
"rag_retrieve": {
|
"rag_retrieve": {
|
||||||
|
"transport": "stdio",
|
||||||
"command": "python",
|
"command": "python",
|
||||||
"args": [
|
"args": [
|
||||||
"./mcp/rag_retrieve_server.py",
|
"./mcp/rag_retrieve_server.py",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user