health_check
Verify documentation source availability and health status for programming libraries and frameworks.
Instructions
Check the health and availability of documentation sources.
Returns:
Dictionary with health status of each library's documentation site
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Implementation of the 'health_check' MCP tool. This async function performs HEAD requests to sample documentation URLs, measures response times, checks for timeouts/errors, and includes cache statistics if enabled. Registered via @mcp.tool() decorator.async def health_check(): """ Check the health and availability of documentation sources. Returns: Dictionary with health status of each library's documentation site """ results = {} # Test a sample of libraries to avoid overwhelming servers sample_libraries = list(docs_urls.items())[:5] for library, url in sample_libraries: start_time = time.time() try: async with httpx.AsyncClient() as client: response = await client.head( str(url), timeout=httpx.Timeout(10.0), headers={"User-Agent": USER_AGENT}, follow_redirects=True, ) response_time = time.time() - start_time results[library] = { "status": "healthy", "status_code": response.status_code, "response_time_ms": round(response_time * 1000, 2), "url": url, } except httpx.TimeoutException: results[library] = { "status": "timeout", "error": "Request timed out", "url": url, } except Exception as e: results[library] = {"status": "error", "error": str(e), "url": url} # Add cache stats if caching is enabled if cache: cache_stats = await cache.stats() results["_cache_stats"] = {"enabled": True, **cache_stats} else: results["_cache_stats"] = {"enabled": False} return results