ALSARA / tests /test_custom_client.py
axegameon's picture
Deploy: stderr forwarder, chroma_sync logging, patient prompt, citation verifier
2adda07 verified
Raw
History Blame Contribute Delete
1.24 kB
#!/usr/bin/env python3
"""Test the custom MCP client"""
import asyncio
import logging
from pathlib import Path
from custom_mcp_client import MCPClientManager
logging.basicConfig(level=logging.INFO)
async def main():
print("πŸ§ͺ Testing Custom MCP Client\n")
manager = MCPClientManager()
# Add PubMed server
print("πŸ“€ Starting PubMed server...")
await manager.add_server(
"pubmed",
str(Path("servers/pubmed_server.py"))
)
# List tools
print("\nπŸ“‹ Listing tools...")
all_tools = await manager.list_all_tools()
for server, tools in all_tools.items():
print(f"\n{server} server ({len(tools)} tools):")
for tool in tools:
print(f" - {tool['name']}: {tool.get('description', 'No description')[:80]}...")
# Test a tool call
print("\nπŸ”§ Testing tool call: search_pubmed...")
result = await manager.call_tool(
"pubmed",
"search_pubmed",
{"query": "ALS SOD1", "max_results": 2}
)
print(f"Result (first 500 chars):\n{result[:500]}...\n")
# Close all
print("πŸ›‘ Closing servers...")
await manager.close_all()
print("βœ… Test complete!")
if __name__ == "__main__":
asyncio.run(main())