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
| Name | Required | Description | Default |
|---|---|---|---|
| older_than_hours | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- meraki-mcp-dynamic.py:796-843 (handler)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) - meraki-mcp-dynamic.py:796-796 (registration)The 'clear_cached_files' function is registered as an MCP tool via the @mcp.tool() decorator.
@mcp.tool()