INNER CODE UNIT · Python

get_cached_metrics

pab1it0/prometheus-mcp-server · src/prometheus_mcp_server/server.py:253

def get_cached_metrics() -> List[str]:
    """Get metrics list with caching to improve completion performance.

    This helper function is available for future completion support when
    FastMCP implements the completion capability. For now, it can be used
    internally to optimize repeated metric list requests.
    """
    current_time = time.time()

    # snapshot for clarity
    cached_data = _metrics_cache["data"]
    cached_timestamp = _metrics_cache["timestamp"]

    if cached_data is not None and (current_time - cached_timestamp) < _CACHE_TTL:
        logger.debug("Using cached metrics list", cache_age=current_time - cached_timestamp)
        return cached_data

    # Fetch fresh metrics

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…