Skip to main content
Glama

get_recent_errors

Retrieve recent error and warning log entries from your project's log files. Deduplicated and timestamped with secrets redacted.

Instructions

Returns recent ERROR and WARN log entries from the detected project's log files. Deduped, timestamped, secrets redacted. Defaults to last 50 lines.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdNo
limitNo

Implementation Reference

  • The actual handler/implementation of get_recent_errors. Reads log files, parses ERROR/WARN lines, deduplicates, redacts secrets, compresses, and returns the last N entries.
    export async function getRecentErrors(
      cwd: string,
      logPaths: string[],
      limit: number = 50
    ): Promise<ErrorEntry[]> {
      try {
        const entries: ErrorEntry[] = [];
        const seenMessages = new Set<string>();
    
        for (const logPath of logPaths) {
          const fullPath = resolve(cwd, logPath);
          let fileStat;
          try {
            fileStat = await stat(fullPath);
            if (!fileStat.isFile()) {
              continue;
            }
          } catch {
            continue;
          }
    
          let content: string;
          try {
            content = await readFile(fullPath, "utf8");
          } catch {
            continue;
          }
    
          const ageMs = Date.now() - fileStat.mtimeMs;
          const relativeTime = getRelativeTimeFromMs(ageMs);
          const lines = content.split(/\r?\n/);
    
          for (const line of lines) {
            if (!/(error|warn)/i.test(line)) {
              continue;
            }
            const level: ErrorEntry["level"] = /error/i.test(line) ? "ERROR" : "WARN";
            const message = compress(redact(line));
    
            if (seenMessages.has(message)) {
              continue;
            }
            seenMessages.add(message);
    
            entries.push({
              time: relativeTime,
              level,
              message,
            });
          }
        }
    
        return entries.slice(-limit);
      } catch {
        return [];
      }
    }
  • The ErrorEntry interface defining the shape of each error entry returned by getRecentErrors.
    export interface ErrorEntry {
      time: string;
      level: "ERROR" | "WARN";
      message: string;
    }
  • src/index.ts:42-57 (registration)
    Registration of the get_recent_errors tool in the ListToolsRequestSchema handler, including its name, description, and input schema.
    {
      name: "get_recent_errors",
      description:
        "Returns recent ERROR and WARN log entries from the detected project's log files. Deduped, timestamped, secrets redacted. Defaults to last 50 lines.",
      inputSchema: {
        type: "object",
        properties: {
          cwd: {
            type: "string",
          },
          limit: {
            type: "number",
          },
        },
      },
    },
  • src/index.ts:105-134 (registration)
    CallToolRequestSchema handler that dispatches to getRecentErrors when toolName === 'get_recent_errors'. Invokes detectFramework first to get logPaths, then calls getRecentErrors.
    if (toolName === "get_recent_errors") {
      try {
        const args = request.params.arguments as
          | { cwd?: string; limit?: number }
          | undefined;
        const cwd = args?.cwd ?? process.cwd();
        const limit = args?.limit ?? 50;
        const framework = await detectFramework(cwd);
        const result = await getRecentErrors(cwd, framework.logPaths, limit);
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                error: `Failed to get recent errors: ${String(error)}`,
              }),
            },
          ],
        };
      }
    }
  • Helper function getRelativeTimeFromMs that converts a file's age in milliseconds to a human-readable relative time string (e.g., 'just now', '5m ago', '2h ago'). Used to timestamp error entries.
    function getRelativeTimeFromMs(ageMs: number): string {
      if (ageMs < 60_000) {
        return "just now";
      }
      const minutes = Math.floor(ageMs / 60_000);
      if (minutes < 60) {
        return `${minutes}m ago`;
      }
      const hours = Math.floor(minutes / 60);
      return `${hours}h ago`;
    }
Behavior4/5

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

With no annotations, the description covers key behaviors: returns only ERROR/WARN, deduped, timestamped, secrets redacted, defaults to last 50 lines. It does not mention idempotency or side effects, but as a read operation this is acceptable.

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?

Two sentences are concise and front-loaded with the tool's purpose. Every word adds value without redundancy.

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

Completeness4/5

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

Given the tool's simplicity and lack of output schema, the description covers core functionality and features. It lacks detail on return format or real-time behavior, but it is largely sufficient.

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 has 0% description coverage. The description mentions 'Defaults to last 50 lines' explaining the limit parameter, but 'cwd' (current working directory) is not explained. It adds some value beyond the bare schema but leaves ambiguity.

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

Purpose5/5

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

The description clearly states the tool returns ERROR and WARN log entries with dedup, timestamping, and secret redaction. It distinguishes itself from sibling tools (get_running_services, get_session_snapshot) which serve different purposes.

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

Usage Guidelines3/5

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

The description implies usage for retrieving recent log errors/warnings but does not explicitly state when to use this tool versus alternatives or provide exclusions. No guidance on prerequisites or context.

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/tao-izm/devpulse-mcp'

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