Skip to main content
Glama

get-logs

Retrieve and filter stdout logs from a named pipe for debugging or analysis. Specify line count, text filters, or timestamps to query application output efficiently.

Instructions

Retrieve logs from the named pipe with optional filtering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNoText to filter logs by
linesNoNumber of log lines to return
sinceNoTimestamp to get logs after

Implementation Reference

  • The handler function for the 'get-logs' tool. It filters the in-memory log store based on optional parameters (lines, filter, since) and returns the most recent logs as a JSON-formatted text content block.
    async ({ lines, filter, since }) => { try { let logs = [...logStore]; if (filter) { logs = logs.filter((entry) => entry.message.toLowerCase().includes(filter.toLowerCase()), ); } if (since) { logs = logs.filter((entry) => { const timestamp = new Date(entry.timestamp).getTime(); return timestamp > since; }); } // Take the last N lines and reverse them so oldest is first logs = logs.slice(-lines).reverse(); return { content: [ { type: "text", text: JSON.stringify(logs, null, 2), }, ], }; } catch (error) { logJson(`Error retrieving logs: ${error}`); throw new Error("Failed to retrieve logs"); } },
  • Input schema for the 'get-logs' tool defined using Zod, with optional parameters for number of lines, filter text, and timestamp threshold.
    { lines: z .number() .optional() .default(50) .describe("Number of log lines to return"), filter: z.string().optional().describe("Text to filter logs by"), since: z.number().optional().describe("Timestamp to get logs after"), },
  • src/index.ts:165-211 (registration)
    Registration of the 'get-logs' tool on the MCP server, including description, input schema, and inline handler function.
    // Register get-logs tool server.tool( "get-logs", "Retrieve logs from the named pipe with optional filtering", { lines: z .number() .optional() .default(50) .describe("Number of log lines to return"), filter: z.string().optional().describe("Text to filter logs by"), since: z.number().optional().describe("Timestamp to get logs after"), }, async ({ lines, filter, since }) => { try { let logs = [...logStore]; if (filter) { logs = logs.filter((entry) => entry.message.toLowerCase().includes(filter.toLowerCase()), ); } if (since) { logs = logs.filter((entry) => { const timestamp = new Date(entry.timestamp).getTime(); return timestamp > since; }); } // Take the last N lines and reverse them so oldest is first logs = logs.slice(-lines).reverse(); return { content: [ { type: "text", text: JSON.stringify(logs, null, 2), }, ], }; } catch (error) { logJson(`Error retrieving logs: ${error}`); throw new Error("Failed to retrieve logs"); } }, );
  • In-memory store for log entries used by the get-logs handler.
    const logStore: LogEntry[] = [];
  • Type definition for log entries stored in logStore.
    interface LogEntry { timestamp: string; message: string; }

Other Tools

Related 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/amitdeshmukh/stdout-mcp-server'

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