Skip to main content
Glama
kocierik
by kocierik

list-events

Retrieve and filter all events by name using the Consul MCP Server, enabling efficient event monitoring and management.

Instructions

List all events

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoFilter events by name

Implementation Reference

  • Registration of the 'list-events' tool, including inline schema and handler function.
        "list-events",
        "List all events",
        {
          name: z.string().default("").optional().describe("Filter events by name"),
        },
        async ({ name }) => {
          try {
            const events = await consul.event.list({ name });
            if (!events || events.length === 0) {
              return { content: [{ type: "text", text: "No events found" }] };
            }
            const eventsText = events.map(event => 
              `ID: ${event.ID}, Name: ${event.Name}, Payload: ${event.Payload || 'None'}`
            ).join("\n");
            return { content: [{ type: "text", text: `Events:\n\n${eventsText}` }] };
          } catch (error) {
            console.error("Error listing events:", error);
            return { content: [{ type: "text", text: "Error listing events" }] };
          }
        }
      );
    }
  • The handler function executes the tool logic: lists events from Consul (optionally filtered by name), formats them, and returns as text content.
      async ({ name }) => {
        try {
          const events = await consul.event.list({ name });
          if (!events || events.length === 0) {
            return { content: [{ type: "text", text: "No events found" }] };
          }
          const eventsText = events.map(event => 
            `ID: ${event.ID}, Name: ${event.Name}, Payload: ${event.Payload || 'None'}`
          ).join("\n");
          return { content: [{ type: "text", text: `Events:\n\n${eventsText}` }] };
        } catch (error) {
          console.error("Error listing events:", error);
          return { content: [{ type: "text", text: "Error listing events" }] };
        }
      }
    );
  • Input schema using Zod: optional 'name' parameter to filter events.
    {
      name: z.string().default("").optional().describe("Filter events by name"),
    },
  • src/server.ts:44-44 (registration)
    Top-level call to registerEventTools, which includes the 'list-events' tool registration.
    registerEventTools(server, consul);
  • Helper function that registers event-related tools, including 'list-events'.
    export function registerEventTools(server: McpServer, consul: Consul) {
      // Fire an event
      server.tool(
        "fire-event",
        "Fire a new event",
        {
          name: z.string().default("").describe("Name of the event"),
          payload: z.string().default("").optional().describe("Event payload"),
        },
        async ({ name, payload }) => {
          try {
            // @ts-ignore - The Consul type definitions are incomplete
            const event = await consul.event.fire(name, payload || "");
            return { content: [{ type: "text", text: `Fired event: ${event.ID}` }] };
          } catch (error) {
            console.error("Error firing event:", error);
            return { content: [{ type: "text", text: `Error firing event: ${name}` }] };
          }
        }
      );
    
      // List events
      server.tool(
        "list-events",
        "List all events",
        {
          name: z.string().default("").optional().describe("Filter events by name"),
        },
        async ({ name }) => {
          try {
            const events = await consul.event.list({ name });
            if (!events || events.length === 0) {
              return { content: [{ type: "text", text: "No events found" }] };
            }
            const eventsText = events.map(event => 
              `ID: ${event.ID}, Name: ${event.Name}, Payload: ${event.Payload || 'None'}`
            ).join("\n");
            return { content: [{ type: "text", text: `Events:\n\n${eventsText}` }] };
          } catch (error) {
            console.error("Error listing events:", error);
            return { content: [{ type: "text", text: "Error listing events" }] };
          }
        }
      );
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.9/5.0
Behavior2/5

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

No annotations provided, and the description does not disclose behavioral traits such as side effects, required permissions, or rate limits. A list operation is likely read-only, but this is not stated.

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

Conciseness4/5

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

Extremely concise at 3 words, front-loading the purpose. However, it may be overly terse; a slightly longer description could improve clarity without significant verbosity.

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 output schema and no annotations, the description lacks information about return values, pagination, or event scope. It is insufficient for an agent to fully understand tool behavior.

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% (the only parameter 'name' is described as 'Filter events by name'). The description adds no additional semantic value beyond the schema, so baseline 3 is appropriate.

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?

Description 'List all events' clearly states verb and resource, distinguishing it from sibling tools like 'fire-event' which create events. However, it lacks specificity about what 'events' refers to.

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. The description does not mention dependencies, prerequisites, or when it would be inappropriate to use.

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