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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/RTFD/server.py:158-166 (handler)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)
- src/RTFD/cache.py:179-210 (helper)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
- src/RTFD/cache.py:17-25 (helper)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]
- src/RTFD/server.py:158-158 (registration)The @mcp.tool decorator registers the get_cache_entries function as an MCP tool.@mcp.tool(description="Get detailed information about all cached entries.")