Skip to main content
Glama

clear_cache

Clear the persistent device cache to resolve issues with changed or corrupted devices. Run scan_network afterward to rebuild the cache.

Instructions

Clear the persistent device cache.

Removes the cache file and clears in-memory cache. Useful when devices have changed or cache is corrupted. Run scan_network after clearing to rebuild the cache.

Returns

Dictionary containing:
- success: Whether cache was cleared successfully
- message: Descriptive message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `clear_cache` tool clears both the persistent device cache (via `_cache_manager`) and the in-memory `_device_cache` dictionary.
    @mcp.tool()
    async def clear_cache() -> dict[str, Any]:
        """Clear the persistent device cache.
    
        Removes the cache file and clears in-memory cache. Useful when devices
        have changed or cache is corrupted. Run scan_network after clearing
        to rebuild the cache.
    
        Returns
        -------
            Dictionary containing:
            - success: Whether cache was cleared successfully
            - message: Descriptive message
    
        """
        try:
            # Clear persistent cache
            cache_cleared = _cache_manager.clear()
    
            # Clear in-memory cache
            _device_cache.clear()
    
            if cache_cleared:
                return {
                    "success": True,
                    "message": "Cache cleared successfully. Run scan_network to rebuild cache.",
                    "timestamp": time.time(),
                }
            return {
                "success": False,
                "error": "Failed to clear cache file",
                "timestamp": time.time(),
            }
    
        except Exception as e:
            logger.error(f"Error clearing cache: {e}", exc_info=True)
            return build_error_response(e, "Clear cache")

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

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