list_trace_files
Retrieve a list of trace files stored on disk for post-hoc analysis of debugging sessions.
Instructions
List all trace files on disk (for post-hoc analysis).
Returns: dict with traces_dir, total file count, and file details.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No |
Implementation Reference
- Handler function for the 'list_trace_files' MCP tool. Scans ~/.cache/camoufox-reverse/traces/ for *.jsonl files, extracts PID and session_id from filenames, collects metadata (size, mtime), sorts by modification time descending, and returns up to `limit` files.
@mcp.tool() async def list_trace_files(limit: int = 20) -> dict: """List all trace files on disk (for post-hoc analysis). Returns: dict with traces_dir, total file count, and file details. """ if not TRACES_DIR.exists(): return {"files": [], "total": 0, "traces_dir": str(TRACES_DIR)} all_files = [] for f in TRACES_DIR.glob("*.jsonl"): try: parts = f.stem.split("_") file_pid = int(parts[0]) if parts else -1 session_id = int(parts[1]) if len(parts) > 1 else -1 except (IndexError, ValueError): continue size_kb = f.stat().st_size / 1024 all_files.append({ "path": str(f), "pid": file_pid, "session_id": session_id, "size_kb": round(size_kb, 1), "mtime": f.stat().st_mtime, }) all_files.sort(key=lambda x: x["mtime"], reverse=True) return { "traces_dir": str(TRACES_DIR), "total": len(all_files), "returned": min(len(all_files), limit), "files": all_files[:limit], } - src/camoufox_reverse_mcp/server.py:25-25 (registration)Registration: the trace module (containing list_trace_files) is imported in server.py line 25, which triggers the @mcp.tool() decorator registration.
from .tools import trace # noqa: E402, F401 — trace_property_access + list/query - Helper: defines the TRACES_DIR path constant (~/.cache/camoufox-reverse/traces) which list_trace_files reads from.
CACHE_DIR = Path.home() / ".cache" / "camoufox-reverse" CONTROL_DIR = CACHE_DIR / "control" TRACES_DIR = CACHE_DIR / "traces"