x402_health
Check the real-time health status of any registered x402 service to confirm it is operational.
Instructions
Check real-time health status of any registered x402 service. Free, no payment required.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| service_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- server.py:233-260 (handler)The function that executes the x402_health tool logic. Makes an HTTP GET request to DISCOVERY_API/health/{service_id}, parses the JSON response, and returns a formatted health report including uptime%, latency, last check time, and quality tier.
def x402_health(service_id: str) -> str: """Get live health status for a specific x402 service. Args: service_id: The service ID from the catalog (e.g. 'ouroboros/discovery'). Returns: Current health: uptime%, latency, last check time, HTTP status. """ try: with httpx.Client(timeout=10.0) as client: resp = client.get(f"{DISCOVERY_API}/health/{service_id}") if resp.status_code == 404: return f"Service '{service_id}' not found. Browse catalog: {DISCOVERY_API}/catalog" resp.raise_for_status() data = resp.json() except Exception as e: return f"Health check error: {e}" return ( f"Health Report: {data.get('name', service_id)}\n" f"Status: {data.get('health_status', '?')}\n" f"Uptime (7d): {data.get('uptime_pct', '?')}%\n" f"Avg Latency: {data.get('avg_latency_ms', '?')}ms\n" f"Last Checked: {data.get('last_checked', '?')}\n" f"Quality Tier: {data.get('quality_tier', '?')}\n" f"Endpoint: {data.get('endpoint_url', data.get('url', '?'))}" ) - server.py:224-232 (registration)The @mcp.tool decorator that registers x402_health as an MCP tool with FastMCP, including description and annotations (readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=True).
@mcp.tool( description="Check real-time health status of any registered x402 service. Free, no payment required.", annotations=ToolAnnotations( readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=True, ), ) - server.py:234-241 (schema)The input schema for x402_health: a single parameter 'service_id' (str) representing the service ID from the catalog (e.g. 'ouroboros/discovery'). The return type is str containing a formatted health report.
"""Get live health status for a specific x402 service. Args: service_id: The service ID from the catalog (e.g. 'ouroboros/discovery'). Returns: Current health: uptime%, latency, last check time, HTTP status. """