test_local_fda.py•1.27 kB
#!/usr/bin/env python3
"""Test FDA MCP via port-forward"""
import asyncio
import json
from fastmcp.client import Client
async def test_local():
local_url = "http://localhost:8090/mcp/"
print(f"Testing FDA MCP via port-forward: {local_url}")
print("-" * 50)
try:
async with Client(local_url) as client:
# List tools
tools = await client.list_tools()
print(f"✅ Connected! Found {len(tools)} tools:")
for tool in tools[:5]: # Show first 5
print(f" • {tool.name}")
# Quick test
print("\nTesting K-number lookup:")
result = await client.call_tool(
"search_fda_by_identifier",
{"k_number": "K213424"}
)
if result and hasattr(result, 'content'):
for content in result.content:
if hasattr(content, 'text'):
data = json.loads(content.text)
print(f"✅ Found: {data['device_name']} by {data['manufacturer']}")
print(f" Status: FDA {data['status'].upper()}")
except Exception as e:
print(f"❌ Error: {e}")
if __name__ == "__main__":
asyncio.run(test_local())