import asyncio
from dedalus_mcp.client import MCPClient
from mcp.shared.exceptions import McpError
async def main():
client = await MCPClient.connect("http://127.0.0.1:8000/mcp")
try:
tools = await client.list_tools()
print("Available tools:")
for tool in tools.tools:
print(f" - {tool.name}")
add_result = await client.call_tool("add", {"a": 5, "b": 3})
print(f"5 + 3 = {add_result.content[0].text}")
mul_result = await client.call_tool("multiply", {"a": 4, "b": 7})
print(f"4 * 7 = {mul_result.content[0].text}")
except McpError as e:
print(f"Tool call failed: {e}")
finally:
await client.close()
asyncio.run(main())