Skip to main content
Glama
ymylive
by ymylive

clear_cache

Clear all cached cryptocurrency data to force a fresh fetch from sources. Use when market data appears stale or a user explicitly requests a refresh. Returns the number of cache entries removed.

Instructions

Drop every entry from the HTTP cache.

Reach for this when:

  • The user explicitly asks to refresh / invalidate cached data.

  • You suspect cached data is materially stale and a TTL has not yet expired (e.g. user reports a price that disagrees with their exchange).

Prefer letting TTLs expire naturally; this tool resets ALL endpoints, not just one. Counters (hits/misses/...) are preserved.

Returns: {"cleared": }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The clear_cache MCP tool handler function. Decorated with @mcp.tool(), it calls the clear() helper and returns {'cleared': <count of dropped entries>}.
    @mcp.tool()
    async def clear_cache() -> dict[str, int]:
        """Drop every entry from the HTTP cache.
    
        Reach for this when:
        - The user explicitly asks to refresh / invalidate cached data.
        - You suspect cached data is materially stale and a TTL has not yet
          expired (e.g. user reports a price that disagrees with their exchange).
    
        Prefer letting TTLs expire naturally; this tool resets ALL endpoints, not
        just one. Counters (hits/misses/...) are preserved.
    
        Returns:
            {"cleared": <number of entries dropped>}
        """
        return {"cleared": clear()}
  • The clear() helper function called by the clear_cache tool. Clears the internal _store OrderedDict and returns the number of entries that were removed.
    def clear() -> int:
        n = len(_store)
        _store.clear()
        return n
  • The @mcp.tool() decorator on clear_cache registers this function as an MCP tool with the FastMCP server instance.
    @mcp.tool()
    async def clear_cache() -> dict[str, int]:
  • The clear_cache tool takes no input parameters and returns a dict with a single int key 'cleared', as documented in the docstring.
    @mcp.tool()
    async def clear_cache() -> dict[str, int]:
        """Drop every entry from the HTTP cache.
    
        Reach for this when:
        - The user explicitly asks to refresh / invalidate cached data.
        - You suspect cached data is materially stale and a TTL has not yet
          expired (e.g. user reports a price that disagrees with their exchange).
    
        Prefer letting TTLs expire naturally; this tool resets ALL endpoints, not
        just one. Counters (hits/misses/...) are preserved.
    
        Returns:
            {"cleared": <number of entries dropped>}
        """
        return {"cleared": clear()}
  • Test fixture that calls cache.clear() before and after every test to isolate cache state.
    @pytest.fixture(autouse=True)
    def clear_cache_each_test():
        """Drop all cache entries before every test so state can't leak between tests."""
        _cache.clear()
        yield
Behavior4/5

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

Discloses full effect (drops all entries, preserves counters, returns count). Without annotations, description carries burden; it adequately covers main behaviors. Minor omission: no mention of permissions or performance implications, but given simplicity, still strong.

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?

Efficiently structured: purpose, usage guidelines, caution, return format. Every sentence earns its place; no fluff. Front-loaded with core action.

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?

Fully covers tool behavior, when to use, and return format. Given 0 parameters and presence of output schema, no missing information. Context regarding sibling tools (cache_stats) is implied.

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 schema, so description adds value by explaining output format and tool purpose. Baseline for 0 params is 4; description also provides output schema in prose.

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?

Explicitly states 'Drop every entry from the HTTP cache' with specific verb and resource. Emphasizes it resets ALL endpoints, distinguishing it from siblings like cache_stats and other data-fetching tools.

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?

Provides explicit 'Reach for this when' criteria with two clear scenarios (explicit user request, suspected stale data). Advises preferring natural TTL expiry, giving clear boundaries on when not to use.

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