check_kg_client.py 628 B

1234567891011121314151617
  1. import asyncio, sys
  2. from backend.mcp.client import call_mcp_tool,list_mcp_tools
  3. async def main():
  4. base = "http://localhost:8000/mcp/kb" # 独立模式:直接指向端口,无路径前缀
  5. tools = await list_mcp_tools(base)
  6. print(f"已注册工具:{[t['name'] for t in tools]}\n")
  7. results = await call_mcp_tool(
  8. server_url=base,
  9. tool_name="search_knowledge_base",
  10. arguments={"query": "跨境电商项目具体内容讲的是什么", "tenant_id": "tenant_default"},
  11. )
  12. print(f"命中 {len(results)} 条")
  13. print(results)
  14. print(type(results))
  15. asyncio.run(main())