Skip to main content
Glama

clear_old_cache

Remove expired weather cache entries older than a specified maximum age in minutes, freeing storage and ensuring data freshness.

Instructions

Clear expired weather cache entries.

Args: max_age_minutes: Maximum age in minutes before considering expired

Returns: Status message with number of entries removed

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_age_minutesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The actual implementation of clear_expired_cache (the helper called by clear_old_cache). Iterates over weather_cache dict, finds entries older than max_age_minutes, deletes them, and returns the count.
    def clear_expired_cache(self, max_age_minutes: int = 60) -> int:
        """Clear expired cache entries.
    
        Args:
            max_age_minutes: Maximum age before considering expired
    
        Returns:
            Number of entries removed
        """
        now = datetime.now(tz=timezone.utc)
        expired_keys = [
            key
            for key, value in self.weather_cache.items()
            if now - value["timestamp"] > timedelta(minutes=max_age_minutes)
        ]
    
        for key in expired_keys:
            del self.weather_cache[key]
    
        return len(expired_keys)
  • The MCP tool handler 'clear_old_cache' decorated with @mcp.tool(). Accepts max_age_minutes parameter, delegates to conversation_tools.clear_expired_cache(), and returns a status message.
    @mcp.tool()
    def clear_old_cache(max_age_minutes: int = 60) -> str:
        """Clear expired weather cache entries.
    
        Args:
            max_age_minutes: Maximum age in minutes before considering expired
    
        Returns:
            Status message with number of entries removed
        """
        removed = conversation_tools.clear_expired_cache(max_age_minutes)
        return f"Cleared {removed} expired cache entries older than {max_age_minutes} minutes"
  • Registration of the 'clear_old_cache' tool via the @mcp.tool() decorator on the function definition inside create_server().
    @mcp.tool()
    def clear_old_cache(max_age_minutes: int = 60) -> str:
        """Clear expired weather cache entries.
    
        Args:
            max_age_minutes: Maximum age in minutes before considering expired
    
        Returns:
            Status message with number of entries removed
        """
        removed = conversation_tools.clear_expired_cache(max_age_minutes)
        return f"Cleared {removed} expired cache entries older than {max_age_minutes} minutes"
  • Helper method get_cached_weather() used by other tools to check cache age; related to the caching system that clear_old_cache manages.
    def get_cached_weather(self, cache_key: str, max_age_minutes: int = 60) -> str | None:
        """Get cached weather data if still fresh.
    
        Args:
            cache_key: Cache identifier to lookup
            max_age_minutes: Maximum age in minutes before cache expires
    
        Returns:
            Cached data if fresh, None if expired or not found
        """
        if cache_key not in self.weather_cache:
            return None
    
        cached = self.weather_cache[cache_key]
        age = datetime.now(tz=timezone.utc) - cached["timestamp"]
    
        if age <= timedelta(minutes=max_age_minutes):
            cached_data: str = cached["data"]
            return cached_data
    
        # Cache expired, remove it
        del self.weather_cache[cache_key]
        return None
Behavior2/5

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

No annotations are provided, but the description only states the action and parameter. It does not disclose behavioral traits such as destructiveness, safety for repeated use, or side effects.

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?

The description is extremely concise with one line for purpose plus args/returns. It is front-loaded and contains no superfluous text.

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

Completeness4/5

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

The tool is simple with one optional parameter and an output schema. The description explains the parameter and return value, but could mention default behavior or safety.

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?

The description adds meaning to the parameter 'max_age_minutes' beyond the schema by explaining its purpose ('Maximum age in minutes before considering expired'). Schema coverage is 0%, so this is valuable.

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 the action 'Clear expired weather cache entries' using a specific verb and resource. It distinguishes from sibling tools (get_alerts, get_current_time, get_forecast) which are retrieval-focused.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, nor does it mention when not to use it.

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/naggbagg/mcp-server'

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