CoolFace
Apppublic

roy2012/stock_mcp

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
test_tushare_client_http.py35 linesDownload Raw Back to root
1"""2测试 MCP 服务器可用接口3"""4import asyncio5from fastmcp import Client6import logging7 8logging.basicConfig(level=logging.INFO)9 10async def list_available_tools():11    """列出所有可用的工具函数"""12    try:13        # 创建客户端 - 使用SSE方式连接14        client = Client("http://127.0.0.1:9000/mcp")15        16        # 连接服务器17        async with client:18            print("已连接到服务器")19            print("\n可用的工具函数列表:")20            print("-" * 50)21            22            # 获取所有工具函数23            tools = await client.list_tools()24            25            # 打印每个工具函数的信息26            for tool in tools:27                print(f"函数名: {tool.name}")28                print(f"描述: {tool.description}")29                print("-" * 50)30            31    except Exception as e:32        print(f"测试过程中出现错误: {str(e)}")33 34if __name__ == "__main__":35    asyncio.run(list_available_tools())