Skip to main content
Glama

get_cache_stats

Retrieve detailed statistics and information about the documentation cache to monitor and optimize storage and performance in the AutoDocs MCP Server environment.

Instructions

Get statistics about the documentation cache.

Returns: Cache statistics and information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler function for 'get_cache_stats'. Decorated with @mcp.tool for automatic registration. Delegates to cache_manager for stats and package list, with error handling.
    @mcp.tool
    async def get_cache_stats() -> dict[str, Any]:
        """
        Get statistics about the documentation cache.
    
        Returns:
            Cache statistics and information
        """
        if cache_manager is None:
            return {
                "success": False,
                "error": {
                    "message": "Cache manager not initialized",
                    "suggestion": "Try again or restart the MCP server",
                    "severity": "critical",
                    "code": "service_not_initialized",
                    "recoverable": False,
                },
            }
    
        try:
            stats = await cache_manager.get_cache_stats()
            cached_packages = await cache_manager.list_cached_packages()
    
            return {
                "success": True,
                "cache_stats": stats,
                "cached_packages": cached_packages,
                "total_packages": len(cached_packages),
            }
    
        except Exception as e:
            formatted_error = ErrorFormatter.format_exception(
                e, {"operation": "get_cache_stats"}
            )
            logger.error("Failed to get cache stats", error=str(e))
            return {
                "success": False,
                "error": {
                    "message": formatted_error.message,
                    "suggestion": formatted_error.suggestion,
                    "severity": formatted_error.severity.value,
                    "code": formatted_error.error_code,
                    "recoverable": formatted_error.recoverable,
                },
            }
  • Core helper method in FileCacheManager that computes cache statistics: total entries, size in bytes, and cache directory path.
    async def get_cache_stats(self) -> dict[str, Any]:
        """Get cache statistics."""
        try:
            cache_files = list(self.cache_dir.glob("*.json"))
            total_size = sum(f.stat().st_size for f in cache_files)
    
            return {
                "total_entries": len(cache_files),
                "total_size_bytes": total_size,
                "cache_dir": str(self.cache_dir),
            }
        except OSError as e:
            logger.error("Failed to get cache stats", error=str(e))
            return {"error": str(e)}
  • Helper method in FileCacheManager that lists all cached package names by scanning JSON files in the cache directory.
    async def list_cached_packages(self) -> list[str]:
        """List all cached package keys."""
        try:
            return [f.stem for f in self.cache_dir.glob("*.json")]
        except OSError as e:
            logger.error("Failed to list cached packages", error=str(e))
            return []
  • FastMCP decorator that registers the get_cache_stats function as a tool.
    @mcp.tool
Behavior2/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 states the tool returns 'Cache statistics and information', which implies a read-only operation, but doesn't clarify aspects like whether it requires authentication, has rate limits, or what specific statistics are included. This leaves gaps in understanding the tool's behavior beyond its basic function.

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 concise and well-structured, with two sentences that efficiently convey the tool's purpose and return value. It avoids unnecessary details, making it easy to parse. However, it could be slightly more front-loaded by integrating the return information into the first sentence for better clarity.

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

Completeness3/5

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

Given the tool's simplicity (0 parameters, no annotations, but has an output schema), the description is adequate but incomplete. It explains what the tool does and what it returns, but lacks context on usage guidelines and behavioral traits. The presence of an output schema reduces the need to detail return values, but more guidance on when to use this tool would enhance completeness.

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 tool has 0 parameters, and schema description coverage is 100%, so there are no parameters to document. The description doesn't need to add parameter details, and it appropriately doesn't mention any. This meets the baseline for tools with no parameters, as there's nothing to compensate for.

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's purpose with a specific verb ('Get') and resource ('statistics about the documentation cache'), making it easy to understand what it does. However, it doesn't explicitly differentiate from sibling tools like 'refresh_cache' or 'scan_dependencies', which also relate to the cache but perform different operations.

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. It doesn't mention scenarios for usage, prerequisites, or comparisons to sibling tools such as 'refresh_cache' (which might update the cache) or 'get_package_docs' (which might retrieve cached documentation). This lack of context leaves the agent without clear 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

Related 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/bradleyfay/autodoc-mcp'

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