12 lines
392 B
Python
12 lines
392 B
Python
import asyncio
|
|
from fastmcp import Client
|
|
|
|
client = Client("http://localhost:9000/mcp")
|
|
|
|
async def call_tool(city: str):
|
|
async with client:
|
|
result = await client.call_tool("get_weather", {"city": city})
|
|
print(result)
|
|
## 启动服务端后,再启动客户端进行连接和调用
|
|
## 这种方式是通过fastmcp的客户端直接调用的
|
|
asyncio.run(call_tool("北京")) |