# 环境要求：Python 3.8+# 依赖包：pip install mcp
import asyncio
from mcp import stdio_client, StdioServerParameters, ClientSession

async def main():
    # 创建服务器参数
    server_params = StdioServerParameters(
        command="python", 
        args=["stock_tools_server.py"]
    )
    
    # 使用stdio_client连接到服务器
    async with stdio_client(server_params) as (read_stream, write_stream):
        # 创建客户端会话
        async with ClientSession(read_stream, write_stream) as session:
            
            # 获取可用工具列表
            tools = await session.list_tools()
            
            # 调用工具
            result = await session.call_tool(
                "get_stock_price",
                {"symbol": "AAPL"}
            )
            
            print(f"苹果股票价格: {result.content[0].text}")

# 运行MCP客户端
asyncio.run(main())
