test_fda_simple.py•2.69 kB
#!/usr/bin/env python3
"""Simple test of the FDA MCP server"""
import asyncio
import json
from fastmcp.client import Client
FDA_MCP_URL = "https://fda-mcp-davinci-mcp.apps.cluster-sdzgj.sdzgj.sandbox319.opentlc.com/mcp/"
async def test_fda_mcp():
print("=" * 60)
print("FDA MCP Server Test (Simplified)")
print("=" * 60)
print(f"Server: {FDA_MCP_URL}\n")
async with Client(FDA_MCP_URL) as client:
# List tools
print("📋 Available Tools:")
tools = await client.list_tools()
for tool in tools:
print(f" • {tool.name}")
print(f"\nTotal: {len(tools)} tools\n")
# Test 1: Search by K-number
print("Test 1: Search Jabra Enhance Plus by K-number")
print("-" * 40)
result = await client.call_tool(
"search_fda_by_identifier",
{"k_number": "K213424"}
)
# Parse the result - it's in TextContent format
if result and hasattr(result, 'content'):
for content in result.content:
if hasattr(content, 'text'):
data = json.loads(content.text)
print(f"✅ Device Found!")
print(f" Name: {data['device_name']}")
print(f" Manufacturer: {data['manufacturer']}")
print(f" Status: {data['status']}")
print(f" FDA Number: {data['fda_number']}")
print(f" Decision Date: {data['decision_date']}")
print(f" Is OTC: {data['is_otc']}")
print(f" Confidence: {data['confidence_score']}")
# Test 2: Get classification
print("\nTest 2: Get OTC hearing aid classification (QUH)")
print("-" * 40)
result = await client.call_tool(
"get_device_classification",
{"product_code": "QUH"}
)
if result and hasattr(result, 'content'):
for content in result.content:
if hasattr(content, 'text'):
data = json.loads(content.text)
if 'error' not in data:
print(f"✅ Classification Found!")
print(f" Device Name: {data['device_name']}")
print(f" Device Class: {data['device_class']}")
print(f" Is OTC: {data['is_otc']}")
print(f" Medical Specialty: {data['medical_specialty']}")
else:
print(f"❌ Error: {data['error']}")
print("\n" + "=" * 60)
print("✅ Tests completed!")
if __name__ == "__main__":
asyncio.run(test_fda_mcp())