mcpserver-demo / fastmcp_client.py
alexcpn's picture
minor changes
a1bb2a4
raw
history blame contribute delete
754 Bytes
"""
Author: Alex Punnen
Status: Demo
Note: I have hosted the server in Hugging Face Spaces.
https://huggingface.co/spaces/alexcpn/mcpserver-demo/tree/main
With the Docker file it is running at "https://alexcpn-mcpserver-demo.hf.space:7860/mcp/"
This is a simple client to call the MCP server and with that an LLM like OpenAI
"""
import asyncio
from fastmcp import Client
async def example():
async with Client("http://127.0.0.1:7860/mcp/") as client:
#async with Client("https://alexcpn-mcpserver-demo.hf.space/mcp/") as client:
await client.ping()
# List available tools
tools = await client.list_tools()
print("Available tools:", tools)
if __name__ == "__main__":
asyncio.run(example())