get_boot_logs
Retrieve recent boot logs from journalctl to diagnose and troubleshoot boot problems on systemd-based systems.
Instructions
Retrieve recent boot logs from journalctl. Useful for troubleshooting boot issues. Works on systemd-based systems.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lines | No | Number of log lines to retrieve. Default: 100 |
Implementation Reference
- src/arch_ops_server/system.py:262-307 (handler)The core handler function that executes the tool logic: runs journalctl to fetch recent boot logs, parses output, handles errors, and returns structured response with log lines.async def get_boot_logs(lines: int = 100) -> Dict[str, Any]: """ Retrieve recent boot logs. Args: lines: Number of lines to retrieve Returns: Dict with boot log contents """ if not check_command_exists("journalctl"): return create_error_response( "NotSupported", "journalctl not available (systemd-based system required)" ) logger.info(f"Retrieving {lines} lines of boot logs") try: exit_code, stdout, stderr = await run_command( ["journalctl", "-b", "-n", str(lines), "--no-pager"], timeout=15, check=False ) if exit_code != 0: return create_error_response( "CommandError", f"Failed to retrieve boot logs: {stderr}" ) log_lines = stdout.strip().split('\n') logger.info(f"Retrieved {len(log_lines)} lines of boot logs") return { "line_count": len(log_lines), "logs": log_lines } except Exception as e: logger.error(f"Failed to get boot logs: {e}") return create_error_response( "LogRetrievalError", f"Failed to retrieve boot logs: {str(e)}" )
- Defines the JSON input schema for the get_boot_logs tool in the MCP server.list_tools() method, specifying the optional 'lines' parameter.Tool( name="get_boot_logs", description="[MONITORING] Retrieve recent boot logs from journalctl. Useful for troubleshooting boot issues. Works on systemd-based systems.", inputSchema={ "type": "object", "properties": { "lines": { "type": "integer", "description": "Number of log lines to retrieve. Default: 100", "default": 100 } }, "required": [] } ),
- src/arch_ops_server/server.py:1352-1355 (registration)Registers and dispatches execution of the get_boot_logs tool in the MCP server.call_tool() method by calling the handler function with parsed arguments.elif name == "get_boot_logs": lines = arguments.get("lines", 100) result = await get_boot_logs(lines) return [TextContent(type="text", text=json.dumps(result, indent=2))]
- Provides structured metadata for the tool, including category (monitoring), platform (systemd), workflow (diagnose), and related tools."get_boot_logs": ToolMetadata( name="get_boot_logs", category="monitoring", platform="systemd", permission="read", workflow="diagnose", related_tools=["check_failed_services"], prerequisite_tools=[] ),