refresh_cache
Refresh the local documentation cache to update Python project dependency references. Returns statistics about the operation, ensuring AI assistants access accurate, version-specific documentation.
Instructions
Refresh the local documentation cache.
Returns: Statistics about cache refresh operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/autodoc_mcp/main.py:513-571 (handler)Handler function for the 'refresh_cache' tool. Decorated with @mcp.tool which registers it. Refreshes the local documentation cache by invalidating all entries and returns statistics on cleared entries and freed space.@mcp.tool async def refresh_cache() -> dict[str, Any]: """ Refresh the local documentation cache. Returns: Statistics about cache refresh operation """ 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: logger.info("Starting cache refresh") # Get current cache stats initial_stats = await cache_manager.get_cache_stats() # Clear the entire cache await cache_manager.invalidate() # Get final stats final_stats = await cache_manager.get_cache_stats() logger.info( "Cache refresh completed", cleared_entries=initial_stats.get("total_entries", 0), ) return { "success": True, "cleared_entries": initial_stats.get("total_entries", 0), "freed_bytes": initial_stats.get("total_size_bytes", 0), "final_entries": final_stats.get("total_entries", 0), } except AutoDocsError as e: formatted_error = ErrorFormatter.format_exception(e) logger.error("Cache refresh failed", 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, }, }