Skip to main content
Glama
ymylive
by ymylive

cache_stats

View HTTP-cache statistics to identify why price data appears stale or to debug rate-limit (429) errors. Returns hit rate, entries, and per-pattern breakdowns.

Instructions

Return current HTTP-cache statistics.

Reach for this when:

  • The user asks why a price/value looks stale or is identical to a previous query (responses may be served from cache up to the per-endpoint TTL).

  • You're debugging rate-limit (HTTP 429) errors and want to confirm the cache is doing its job.

  • The user explicitly asks about cache utilization or hit rate.

Returns: Dict with keys: entries: number of live cached entries max_entries: LRU eviction threshold hits, misses, sets, errors: cumulative counters since process start hit_rate: hits / (hits + misses), 0.0 if no requests yet by_pattern: per-endpoint-pattern breakdown of the same counters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `cache_stats` tool handler — an async function decorated with @mcp.tool() that returns HTTP cache statistics by delegating to the get_stats() helper.
    @mcp.tool()
    async def cache_stats() -> dict[str, Any]:
        """Return current HTTP-cache statistics.
    
        Reach for this when:
        - The user asks why a price/value looks stale or is identical to a previous
          query (responses may be served from cache up to the per-endpoint TTL).
        - You're debugging rate-limit (HTTP 429) errors and want to confirm the
          cache is doing its job.
        - The user explicitly asks about cache utilization or hit rate.
    
        Returns:
            Dict with keys:
                entries: number of live cached entries
                max_entries: LRU eviction threshold
                hits, misses, sets, errors: cumulative counters since process start
                hit_rate: hits / (hits + misses), 0.0 if no requests yet
                by_pattern: per-endpoint-pattern breakdown of the same counters
        """
        return get_stats()
  • The get_stats() helper function that cache_stats delegates to — it reads global counters and pattern-specific counters to assemble the stats dictionary.
    def get_stats() -> dict[str, Any]:
        hits = _global_counters["hits"]
        misses = _global_counters["misses"]
        total = hits + misses
        hit_rate = (hits / total) if total else 0.0
        return {
            "entries": len(_store),
            "max_entries": MAX_ENTRIES,
            "hits": hits,
            "misses": misses,
            "sets": _global_counters["sets"],
            "errors": _global_counters["errors"],
            "hit_rate": round(hit_rate, 4),
            "by_pattern": {
                label: dict(counts) for label, counts in _pattern_counters.items()
            },
        }
  • The tool is registered via the @mcp.tool() decorator on the cache_stats async function. The 'mcp' instance is imported from coin_mcp.core.
    @mcp.tool()
    async def cache_stats() -> dict[str, Any]:
  • The cache module (containing cache_stats) is imported at the bottom of core.py so its @mcp.tool() decorators run at module load time.
    # Import last so the cache module's @mcp.tool() registrations run at module
    # load. cache imports `mcp` and `DEFAULT_TIMEOUT` from this module, so this
    # must come AFTER those names exist.
    from . import cache  # noqa: E402,F401
  • The schema for cache_stats output is defined in the docstring: returns dict with entries, max_entries, hits, misses, sets, errors, hit_rate, and by_pattern.
        Dict with keys:
            entries: number of live cached entries
            max_entries: LRU eviction threshold
            hits, misses, sets, errors: cumulative counters since process start
            hit_rate: hits / (hits + misses), 0.0 if no requests yet
            by_pattern: per-endpoint-pattern breakdown of the same counters
    """
    return get_stats()
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Despite no annotations, the description fully discloses behavior: it notes cache may serve stale data up to TTL, counters are cumulative since process start, and provides detailed return structure. No contradictions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured with a brief line, bulleted usage cases, and a clear dict description. Every sentence adds value, no fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter tool with output schema, the description fully covers purpose, usage, behavior, and return format. It is self-contained and complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters in input schema (baseline 4). Description does not need to explain parameters but adds value by detailing the output structure, which is not covered by schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it returns HTTP-cache statistics with specific verb 'Return' and resource 'current HTTP-cache statistics'. It distinguishes from siblings like clear_cache.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit 'Reach for this when' bullet points list three scenarios, guiding when to use this tool over alternatives, e.g., when debugging rate-limit errors or checking cache utilization.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ymylive/coin-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server