Skip to main content
Glama

system_logs

Read system logs from journalctl or log files to monitor infrastructure services and troubleshoot issues in Kubernetes, Docker, and other systems.

Instructions

Read system logs from journalctl or a log file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
unitNoSystemd unit name (e.g., 'nginx', 'docker')
linesNoNumber of lines to show (default: 50)
pathNoPath to a log file (alternative to journalctl)

Implementation Reference

  • The handler implementation for the 'system_logs' tool. It either reads a local file or queries journalctl.
    export async function systemLogs(args: Record<string, unknown>): Promise<string> {
      const unit = args.unit as string | undefined;
      const lines = (args.lines as number) || 50;
      const path = args.path as string | undefined;
    
      // If a file path is given, read from file
      if (path) {
        try {
          const content = await readFile(path, "utf-8");
          const allLines = content.trim().split("\n");
          const lastN = allLines.slice(-lines);
          return `Logs from '${path}' (last ${lastN.length} lines):\n\n${lastN.join("\n")}`;
        } catch (error: any) {
          throw new Error(`Failed to read log file: ${error.message}`);
        }
      }
    
      // Otherwise use journalctl
      try {
        const jArgs = ["--no-pager", `-n${lines}`];
        if (unit) jArgs.push("-u", unit);
    
        const { stdout } = await execFileAsync("journalctl", jArgs, { timeout: 15000 });
        return `System logs${unit ? ` (${unit})` : ""} (last ${lines} lines):\n\n${stdout.trim()}`;
      } catch (error: any) {
        throw new Error(`Failed to read system logs: ${error.message}`);
      }
    }
  • Schema definition for 'system_logs' tool.
      name: "system_logs",
      description: "Read system logs from journalctl or a log file",
      inputSchema: {
        type: "object" as const,
        properties: {
          unit: { type: "string", description: "Systemd unit name (e.g., 'nginx', 'docker')" },
          lines: { type: "number", description: "Number of lines to show (default: 50)" },
          path: { type: "string", description: "Path to a log file (alternative to journalctl)" },
        },
      },
    },
  • Routing of the 'system_logs' tool in handleSystemTool.
    case "system_logs": return systemLogs(a);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions reading logs but lacks critical behavioral details: required permissions (e.g., sudo), whether it's safe or destructive, output format, error handling, or rate limits. This is inadequate for a tool that likely needs elevated access.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core purpose and specifies sources without unnecessary elaboration, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects like safety, permissions, or output format, which are crucial for a system tool. The schema handles parameters well, but overall context for safe and effective use is lacking.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so parameters are well-documented in the schema. The description adds no additional meaning beyond implying 'unit' and 'path' correspond to journalctl and log file sources, but this is minimal value. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Read') and resource ('system logs'), specifying the sources ('journalctl or a log file'). It distinguishes from sibling tools like 'docker_container_logs' by focusing on system-level logs rather than container-specific ones, though it doesn't explicitly contrast with them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives is provided. While it implies usage for system logs (vs. container logs in siblings), there's no explicit direction on choosing between journalctl and file paths, or when to prefer this over similar tools like 'system_processes'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/batu-sonmez/infraclaude'

If you have feedback or need assistance with the MCP directory API, please join our Discord server