Skip to main content
Glama

get_cache_info

Check cache status to determine if a device rescan is needed by retrieving file age, expiration status, and stored device count.

Instructions

Get information about the persistent device cache.

Returns information about the cache file including age, expiration status, and device count. Useful for determining if a rescan is needed.

Returns

Dictionary containing:
- exists: Whether cache file exists
- path: Path to cache file
- age_seconds: Age of cache in seconds
- expired: Whether cache has expired
- device_count: Number of devices in cache
- ttl_seconds: Time-to-live for cache entries

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The get_cache_info MCP tool handler, which calls the cache manager's get_cache_info method.
    async def get_cache_info() -> dict[str, Any]:
        """Get information about the persistent device cache.
    
        Returns information about the cache file including age, expiration status,
        and device count. Useful for determining if a rescan is needed.
    
        Returns
        -------
            Dictionary containing:
            - exists: Whether cache file exists
            - path: Path to cache file
            - age_seconds: Age of cache in seconds
            - expired: Whether cache has expired
            - device_count: Number of devices in cache
            - ttl_seconds: Time-to-live for cache entries
    
        """
        try:
            cache_info = _cache_manager.get_cache_info()
            cache_info["memory_cache_size"] = len(_device_cache)
            return cache_info
        except Exception as e:
            logger.error(f"Error getting cache info: {e}", exc_info=True)
            return build_error_response(e, "Get cache info")
  • The DeviceCache method that performs the actual logic for getting cache information from the file system.
    def get_cache_info(self) -> dict[str, Any]:
        """Get information about the current cache.
    
        Returns
        -------
            Dictionary with cache metadata
    
        """
        if not self.cache_file.exists():
            return {
                "exists": False,
                "path": str(self.cache_file),
                "ttl_seconds": self.ttl_seconds,
            }
    
        try:
            with self.cache_file.open() as f:
                data = json.load(f)
    
            cache_age = time.time() - data.get("timestamp", 0)
            return {
                "exists": True,
                "path": str(self.cache_file),
                "version": data.get("version"),
                "device_count": data.get("device_count", 0),
                "age_seconds": round(cache_age, 2),
                "ttl_seconds": self.ttl_seconds,
                "expired": cache_age > self.ttl_seconds,
                "created": data.get("timestamp"),
            }
    
        except (json.JSONDecodeError, OSError, KeyError) as e:
            return {
                "exists": True,
                "path": str(self.cache_file),
                "error": str(e),
                "ttl_seconds": self.ttl_seconds,
            }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the return format and key behavioral aspects like cache age and expiration, but lacks details on potential errors, performance characteristics, or prerequisites. It adds value beyond the schema but is not comprehensive.

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 front-loaded with the core purpose, followed by usage context and a structured return value breakdown. Every sentence adds value without waste, and the formatting with a 'Returns' section enhances clarity while maintaining brevity.

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?

Given the tool's low complexity (0 parameters), high schema coverage, and presence of an output schema, the description is complete. It explains what the tool does, when to use it, and details the return values, which aligns well with the structured data provided.

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?

Since there are 0 parameters and schema description coverage is 100%, the baseline is 4. The description does not need to compensate for any parameter documentation gaps, and it appropriately focuses on the output without redundant input details.

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 tool's purpose with a specific verb ('Get information') and resource ('persistent device cache'), distinguishing it from siblings like clear_cache, scan_network, and list_devices. It explicitly identifies what information is retrieved, making the purpose unambiguous and well-differentiated.

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

Usage Guidelines4/5

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

The description provides clear context for when to use the tool ('Useful for determining if a rescan is needed'), which implies usage relative to scan_network. However, it does not explicitly state when not to use it or name specific alternatives, keeping it from a perfect score.

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

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