test_step_by_step.pyā¢1.23 kB
#!/usr/bin/env python3
"""Step by step client test"""
import asyncio
import json
from fastmcp import Client
async def main():
print("š Starting MCP client...")
try:
print("š” Connecting to server...")
async with Client("http://0.0.0.0:8001/mcp/") as client:
print("ā
Connected!")
print("\nš§ Listing tools...")
tools = await client.list_tools()
print(f"ā
Found {len(tools)} tools")
print("\nš„ Calling list_accounts...")
accounts_result = await client.call_tool("list_accounts", {})
print(f"ā
Got result: {accounts_result}")
if accounts_result.content:
accounts_text = accounts_result.content[0].text
print(f"š Accounts data: {accounts_text}")
accounts = json.loads(accounts_text)
print(f"ā
Parsed {len(accounts) if isinstance(accounts, list) else 'dict'} accounts")
print("\nā
All tests passed!")
except Exception as e:
print(f"\nā Error: {e}")
import traceback
traceback.print_exc()
asyncio.run(main())