list_crash_dumps
Scan directories recursively to discover and list Linux system crash dump files for analysis.
Instructions
Scans for crash dumps in the specified directory (recursive). Returns a formatted string list of found dumps.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| search_path | No | /app/crash |
Implementation Reference
- src/crash_mcp/server.py:25-52 (handler)The @mcp.tool()-decorated handler function implementing the list_crash_dumps tool. It lists crash dumps by calling CrashDiscovery.find_dumps, sorts by recency, limits to 10, and formats the output.@mcp.tool() def list_crash_dumps(search_path: str = Config.CRASH_SEARCH_PATH) -> str: """ Scans for crash dumps in the specified directory (recursive). Returns a formatted string list of found dumps. """ logger.info(f"Listing crash dumps in {search_path}") dumps = CrashDiscovery.find_dumps([search_path]) if not dumps: return "No crash dumps found." # Sort by modification time (newest first) dumps.sort(key=lambda x: x['modified'], reverse=True) # Limit to top 10 to save tokens total_count = len(dumps) limit = 10 dumps = dumps[:limit] output = [f"Found {total_count} crash dumps (showing top {limit}):"] for d in dumps: output.append(f"- {d['path']} (Size: {d['size']} bytes)") if total_count > limit: output.append(f"... and {total_count - limit} more.") return "\n".join(output)
- src/crash_mcp/discovery.py:19-41 (helper)Core helper method used by list_crash_dumps to recursively discover crash dump files using glob patterns for common dump names.def find_dumps(search_paths: List[str]) -> List[Dict[str, str]]: """ Scans given paths for crash dump files. Returns a list of dicts with 'path', 'filename', 'size', 'modified'. """ dumps = [] for path in search_paths: if not os.path.isdir(path): continue for pattern in DUMP_PATTERNS: full_pattern = os.path.join(path, "**", pattern) # recursive search for filepath in glob.glob(full_pattern, recursive=True): if os.path.isfile(filepath): stat = os.stat(filepath) dumps.append({ "path": filepath, "filename": os.path.basename(filepath), "size": stat.st_size, "modified": stat.st_mtime }) return dumps