# Copyright (c) 2026 Dedalus Labs, Inc. and its contributors
# SPDX-License-Identifier: MIT
"""Sample MCP client for testing x-mcp server locally."""
import asyncio
from dedalus_mcp.client import MCPClient
SERVER_URL = "http://localhost:8080/mcp"
async def main() -> None:
client = await MCPClient.connect(SERVER_URL)
# List tools
result = await client.list_tools()
print(f"\nAvailable tools ({len(result.tools)}):\n")
for t in result.tools:
print(f" {t.name}")
if t.description:
print(f" {t.description[:80]}...")
print()
# Test x_get_user_by_username
print("--- x_get_user_by_username ---")
user = await client.call_tool("x_get_user_by_username", {"username": "elikitten"})
print(user)
print()
# Test x_search_recent
print("--- x_search_recent ---")
tweets = await client.call_tool("x_search_recent", {"query": "from:elikitten", "max_results": 5})
print(tweets)
await client.close()
if __name__ == "__main__":
asyncio.run(main())