cache_info
Check cache statistics or clear the cache to manage stored data.
Instructions
Shows cache statistics or clears the cache.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clear | No | True — clears the cache, False — shows statistics. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- tools/cache_tool.py:5-18 (handler)The async function that executes the cache_info tool logic: if clear=True clears the cache, otherwise returns cache statistics as JSON.
async def cache_info(clear: bool = False) -> str: """ Shows cache statistics or clears the cache. Args: clear: True — clears the cache, False — shows statistics. Returns: JSON with cache stats or clear result. """ if clear: removed = cache.clear() return json.dumps({"cleared": True, "removed_entries": removed}, ensure_ascii=False, indent=2) return json.dumps(cache.stats(), ensure_ascii=False, indent=2) - tools/cache_tool.py:5-18 (schema)The function signature defines the input schema (optional clear: bool = False) and output type (str).
async def cache_info(clear: bool = False) -> str: """ Shows cache statistics or clears the cache. Args: clear: True — clears the cache, False — shows statistics. Returns: JSON with cache stats or clear result. """ if clear: removed = cache.clear() return json.dumps({"cleared": True, "removed_entries": removed}, ensure_ascii=False, indent=2) return json.dumps(cache.stats(), ensure_ascii=False, indent=2) - server.py:35-35 (registration)Registration of cache_info as an MCP tool on the FastMCP server via mcp.tool()(cache_info).
mcp.tool()(cache_info) - tools/__init__.py:6-12 (registration)Re-export of cache_info from tools/__init__.py so it can be imported by server.py.
from .cache_tool import cache_info from .report import generate_report __all__ = [ "analyze_code", "compare_code", "explain_code", "generate_tests", "analyze_file", "cache_info", "generate_report", ] - cache.py:32-41 (helper)The cache.stats() and cache.clear() helper functions used by the handler to report/clear cache.
def stats() -> dict: now = time.time() alive = sum(1 for ts, _ in _store.values() if now - ts < CACHE_TTL) return {"total": len(_store), "alive": alive, "ttl_seconds": CACHE_TTL} def clear() -> int: count = len(_store) _store.clear() return count