list_log_files
Retrieve and list available log files along with their metadata from the JSON Logs MCP Server for efficient log management and analysis.
Instructions
List available log files with metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- json_logs_mcp_server.py:468-475 (handler)Handler for the 'list_log_files' tool: calls log_analyzer.get_log_files() and returns the JSON-formatted list of log files as TextContent.elif name == "list_log_files": results = log_analyzer.get_log_files() return [ types.TextContent( type="text", text=json.dumps(results, indent=2, default=str) ) ]
- json_logs_mcp_server.py:423-430 (registration)Registers the 'list_log_files' tool in list_tools() with empty input schema.types.Tool( name="list_log_files", description="List available log files with metadata", inputSchema={ "type": "object", "properties": {} } )
- json_logs_mcp_server.py:426-429 (schema)Input schema for 'list_log_files' tool: empty object (no parameters).inputSchema={ "type": "object", "properties": {} }
- json_logs_mcp_server.py:56-59 (helper)Core helper method that refreshes the log files cache and returns the list of available log files with metadata.def get_log_files(self) -> List[Dict[str, Any]]: """Get list of available log files""" self._refresh_log_files() return list(self.log_files_cache.values())
- json_logs_mcp_server.py:35-54 (helper)Private helper that scans the log directory for *.log* files, collects metadata (path, name, size, modified), sorts by recency, and caches them.def _refresh_log_files(self): """Refresh the cache of available log files""" if not self.log_directory.exists(): self.log_files_cache = {} return log_files = [] for file_path in self.log_directory.glob("*.log*"): if file_path.is_file(): stat = file_path.stat() log_files.append({ "path": str(file_path), "name": file_path.name, "size": stat.st_size, "modified": datetime.fromtimestamp(stat.st_mtime).isoformat() }) # Sort by modification time (newest first) log_files.sort(key=lambda x: x["modified"], reverse=True) self.log_files_cache = {f["name"]: f for f in log_files}