from __future__ import annotations """验证自建旅行MCP与高德MCP服务器的工具注册与加载是否正常。""" import asyncio from rich.console import Console from rich.table import Table from app.mcp_client import load_mcp_tools console = Console() async def main() -> None: bundle = await load_mcp_tools() console.print( { "全部MCP工具数": len( bundle.all_tools ), "旅行查询工具数": len( bundle.travel_tools ), "高德工具数": len( bundle.amap_tools ), } ) table = Table(title="已加载MCP工具") table.add_column("工具类型") table.add_column("工具名称") table.add_column("说明") travel_names = { tool.name for tool in bundle.travel_tools } for tool in bundle.all_tools: tool_type = ( "旅行查询" if tool.name in travel_names else "高德地图" ) table.add_row( tool_type, tool.name, (tool.description or "")[:100], ) console.print(table) if __name__ == "__main__": asyncio.run(main())