Skip to main content
Glama

get_recent_logs

Retrieve recent log events from AWS CloudWatch Log Groups to monitor application performance and troubleshoot issues.

Instructions

Retrieves recent log events from a CloudWatch Log Group.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
log_group_nameYesName of the Log Group.
limitNoNumber of log events to return (default: 20).

Implementation Reference

  • Executes the get_recent_logs tool: fetches the latest log stream from the specified CloudWatch Log Group and retrieves the most recent log events using AWS CloudWatchLogsClient.
    if (name === "get_recent_logs") { const groupName = (args as any).log_group_name; const limit = (args as any)?.limit || 20; // Get latest stream const streamCmd = new DescribeLogStreamsCommand({ logGroupName: groupName, orderBy: "LastEventTime", descending: true, limit: 1 }); try { const streamResp = await cloudWatchLogsClient.send(streamCmd); const streamName = streamResp.logStreams?.[0]?.logStreamName; if (!streamName) { return { content: [{ type: "text", text: "No log streams found." }] }; } const eventsCmd = new GetLogEventsCommand({ logGroupName: groupName, logStreamName: streamName, limit: limit, startFromHead: false }); const eventsResp = await cloudWatchLogsClient.send(eventsCmd); const logs = eventsResp.events?.map(e => ({ Timestamp: new Date(e.timestamp || 0).toISOString(), Message: e.message })) || []; return { content: [{ type: "text", text: JSON.stringify(logs, null, 2) }] }; } catch (err: any) { return { content: [{ type: "text", text: `Error fetching logs: ${err.message}` }], isError: true }; } }
  • src/index.ts:464-481 (registration)
    Registers the 'get_recent_logs' tool in the ListTools response, defining its name, description, and input schema.
    { name: "get_recent_logs", description: "Retrieves recent log events from a CloudWatch Log Group.", inputSchema: { type: "object", properties: { log_group_name: { type: "string", description: "Name of the Log Group." }, limit: { type: "number", description: "Number of log events to return (default: 20)." } }, required: ["log_group_name"] } },
  • Defines the input schema for the get_recent_logs tool, specifying required log_group_name and optional limit.
    inputSchema: { type: "object", properties: { log_group_name: { type: "string", description: "Name of the Log Group." }, limit: { type: "number", description: "Number of log events to return (default: 20)." } }, required: ["log_group_name"] }

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/Bhavesh8890/MCP-server'

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