Skip to main content
Glama

clear_cached_files

Delete cached Meraki API response files older than a specified number of hours to free up disk space.

Instructions

Clear cached response files older than specified hours

Args: older_than_hours: Delete files older than this many hours (default: 24)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
older_than_hoursNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'clear_cached_files' tool. It iterates .json files in RESPONSE_CACHE_DIR, deletes those older than the specified number of hours, and returns a JSON summary of deleted/kept files.
    @mcp.tool()
    async def clear_cached_files(older_than_hours: int = 24) -> str:
        """
        Clear cached response files older than specified hours
    
        Args:
            older_than_hours: Delete files older than this many hours (default: 24)
        """
        try:
            if not os.path.exists(RESPONSE_CACHE_DIR):
                return json.dumps({
                    "message": "No cache directory found",
                    "cache_dir": RESPONSE_CACHE_DIR
                }, indent=2)
    
            now = datetime.now()
            deleted = []
            kept = []
    
            for filename in os.listdir(RESPONSE_CACHE_DIR):
                if filename.endswith('.json'):
                    filepath = os.path.join(RESPONSE_CACHE_DIR, filename)
                    file_time = datetime.fromtimestamp(os.path.getmtime(filepath))
                    age_hours = (now - file_time).total_seconds() / 3600
    
                    if age_hours > older_than_hours:
                        os.remove(filepath)
                        deleted.append({
                            "filename": filename,
                            "age_hours": round(age_hours, 2)
                        })
                    else:
                        kept.append({
                            "filename": filename,
                            "age_hours": round(age_hours, 2)
                        })
    
            return json.dumps({
                "cache_dir": RESPONSE_CACHE_DIR,
                "deleted_count": len(deleted),
                "kept_count": len(kept),
                "deleted_files": deleted,
                "kept_files": kept
            }, indent=2)
        except Exception as e:
            return json.dumps({
                "error": str(e)
            }, indent=2)
  • The 'clear_cached_files' function is registered as an MCP tool via the @mcp.tool() decorator.
    @mcp.tool()
Behavior2/5

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

No annotations are provided, so the description must fully convey behavioral traits. It states the tool deletes files, indicating destructive behavior, but does not disclose additional traits such as irreversibility, permission requirements, or effects on other cached responses. This is insufficient for a destructive operation.

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

Conciseness4/5

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

The description is very short and includes a structured args section. It contains no unnecessary words, but could perhaps integrate the parameter description more naturally. Overall, it earns its place with minimal verbosity.

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

Completeness2/5

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

Given the tool's low complexity and the presence of an output schema, the description should still cover context like the scope of 'cached response files' and potential side effects. It lacks this context, and the existence of sibling caching tools further demands comparison, which is absent.

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

Parameters3/5

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

The input schema has 0% description coverage, so the description must compensate. It explains that 'older_than_hours' specifies the age threshold for deletion, adding meaning beyond the schema's type and default. However, the explanation is minimal and does not elaborate on format or constraints.

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

Purpose4/5

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

The description clearly states the tool clears cached response files older than a specified number of hours, using the verb 'clear' and resource 'cached response files'. However, it does not differentiate from the sibling tool 'cache_clear', which may perform a similar or related function.

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 the parameter default but offers no guidance on when to use this tool versus alternatives like 'cache_clear', nor does it include any exclusions or prerequisites. The agent is left to infer usage context without explicit direction.

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/CiscoDevNet/meraki-magic-mcp-community'

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