list_log_files
Retrieve available log files with metadata from the JSON Logs MCP Server to access and manage logging data.
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)Dispatch handler for the 'list_log_files' tool: calls log_analyzer.get_log_files() and returns JSON serialized list of log files.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-431 (registration)Registers the 'list_log_files' tool in list_tools() with description and 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)Main helper method invoked by the handler: refreshes log file cache and returns 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-55 (helper)Supporting method that scans the log directory for *.log* files, collects metadata (path, name, size, modified time), 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}