"""
第 1 步测试：连接本地 MCP Server，并列出它提供的工具。

运行：
python step1_list_tools.py
"""

from __future__ import annotations

import asyncio
import sys
from pathlib import Path

from langchain_mcp_adapters.client import MultiServerMCPClient


async def main() -> None:
    server_file = Path(__file__).with_name("my_mcp_demo.py").resolve()

    # MCP Client 会自动启动 my_mcp_demo.py，然后询问它有哪些工具。
    client = MultiServerMCPClient(
        {
            "travel-tools": {
                "transport": "stdio",
                "command": sys.executable,
                "args": [str(server_file)],
            }
        }
    )

    tools = await client.get_tools()

    print("MCP Client 发现了这些工具：")
    for tool in tools:
        print(f"- {tool.name}: {tool.description}")


if __name__ == "__main__":
    asyncio.run(main())
