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"]
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves log events but doesn't mention critical details like whether it's read-only, what format the logs are returned in, if there are rate limits, or authentication requirements. This leaves significant gaps for an agent to understand the tool's behavior.

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 that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, 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 the lack of annotations and output schema, the description is incomplete for a tool that retrieves data. It doesn't explain what the return format looks like (e.g., structured logs, timestamps), potential limitations like pagination or time ranges, or error conditions. For a data retrieval tool with no structured output information, this leaves too many unknowns.

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?

The input schema has 100% description coverage, clearly documenting both parameters. The description doesn't add any additional semantic context beyond what the schema provides, such as examples or constraints. With high schema coverage, a baseline score of 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 ('Retrieves') and resource ('recent log events from a CloudWatch Log Group'), making the purpose understandable. However, it doesn't differentiate from the sibling tool 'search_cloudwatch_logs', which appears to be a related alternative for log operations, leaving some ambiguity about when to use each.

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 is provided on when to use this tool versus alternatives like 'search_cloudwatch_logs' or other log-related tools. The description lacks context about prerequisites, such as needing specific permissions or when this tool is preferred over others for accessing logs.

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

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