Skip to main content
Glama
aserper

RTFD (Read The F*****g Docs)

by aserper

get_cache_entries

Retrieve detailed information about cached documentation entries to access up-to-date API references and prevent outdated code generation.

Instructions

Get detailed information about all cached entries.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'get_cache_entries' tool. It is registered via the @mcp.tool decorator and retrieves all cache entries using the CacheManager, formats them, and returns a serialized response.
    @mcp.tool(description="Get detailed information about all cached entries.")
    async def get_cache_entries() -> CallToolResult:
        """Return detailed information about all cached items including age, size, and content preview."""
        entries = _cache_manager.get_all_entries()
        result = {
            "total_entries": len(entries),
            "entries": entries,
        }
        return serialize_response_with_meta(result)
  • Helper method in CacheManager that provides detailed information on all cache entries (age, size, preview), directly called by the tool handler.
    def get_all_entries(self) -> dict[str, dict[str, Any]]:
        """
        Get detailed information about all cached entries.
    
        Returns:
            Dict mapping cache keys to entry details (age, size, content preview).
        """
        entries = {}
        current_time = time.time()
    
        try:
            with sqlite3.connect(self.db_path) as conn:
                cursor = conn.execute(
                    "SELECT key, data, timestamp FROM cache ORDER BY timestamp DESC"
                )
                rows = cursor.fetchall()
    
                for key, data_json, timestamp in rows:
                    age_seconds = current_time - timestamp
                    data = json.loads(data_json)
                    data_size = len(data_json.encode("utf-8"))
    
                    entries[key] = {
                        "age_seconds": round(age_seconds, 2),
                        "size_bytes": data_size,
                        "timestamp": timestamp,
                        "content_preview": self._get_preview(data),
                    }
        except Exception as e:
            sys.stderr.write(f"Cache get_all_entries error: {e}\n")
    
        return entries
  • Dataclass defining the structure of cache entries used by CacheManager and returned indirectly via the tool.
    @dataclass
    class CacheEntry:
        """Represents a cached item."""
    
        key: str
        data: Any
        timestamp: float
        metadata: dict[str, Any]
  • The @mcp.tool decorator registers the get_cache_entries function as an MCP tool.
    @mcp.tool(description="Get detailed information about all cached entries.")

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/aserper/RTFD'

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