get_cached_files
Retrieve a list of all files stored in the cache to enable efficient file management and access within the Penpot AI-driven design workflow.
Instructions
List all files currently stored in the cache.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- penpot_mcp/server/mcp_server.py:395-398 (handler)Handler and registration for the 'get_cached_files' tool. This function is registered as an MCP tool when config.RESOURCES_AS_TOOLS is True and returns all cached files via the MemoryCache instance.@self.mcp.tool() def get_cached_files() -> dict: """List all files currently stored in the cache.""" return self.file_cache.get_all_cached_files()
- penpot_mcp/utils/cache.py:61-84 (helper)The MemoryCache.get_all_cached_files() method implements the core logic for retrieving all non-expired cached Penpot files, cleaning up expired entries in the process. This is called by the tool handler.def get_all_cached_files(self) -> Dict[str, Dict[str, Any]]: """ Get all valid cached files. Returns: Dictionary mapping file IDs to their cached data """ result = {} current_time = time.time() # Create a list of expired keys to remove expired_keys = [] for file_id, cache_data in self._cache.items(): if current_time - cache_data['timestamp'] <= self.ttl_seconds: result[file_id] = cache_data['data'] else: expired_keys.append(file_id) # Remove expired entries for key in expired_keys: del self._cache[key] return result
- Instantiation of the MemoryCache used by the get_cached_files tool, with a 10-minute TTL.self.file_cache = MemoryCache(ttl_seconds=600) # 10 minutes
- penpot_mcp/server/mcp_server.py:88-93 (registration)Conditional registration of tools including get_cached_files based on config.RESOURCES_AS_TOOLS.if config.RESOURCES_AS_TOOLS: self._register_resources(resources_only=True) self._register_tools(include_resource_tools=True) else: self._register_resources(resources_only=False) self._register_tools(include_resource_tools=False)
- MCP resource providing the same cached files listing functionality, always available (non-tool version).@self.mcp.resource("penpot://cached-files") def get_cached_files() -> dict: """List all files currently stored in the cache.""" return self.file_cache.get_all_cached_files()