Skip to main content
Glama

get-hmr-events

Retrieve recent Hot Module Replacement events from the Vite dev server to track live code updates and modifications in real time.

Instructions

Retrieves recent HMR events

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of events to return

Implementation Reference

  • The async handler function for 'get-hmr-events' tool. It takes an optional 'limit' parameter, slices the lastHMREvents array accordingly, and returns the events as JSON text, or an error message if something fails.
      async ({ limit }) => {
        try {
          const eventsToReturn = limit ? lastHMREvents.slice(0, limit) : lastHMREvents;
    
          return {
            content: [
              {
                type: 'text',
                text: eventsToReturn.length > 0
                  ? `Recent HMR events:\n${JSON.stringify(eventsToReturn, null, 2)}`
                  : 'No HMR events detected yet.'
              }
            ]
          };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          Logger.error(`Failed to get HMR events: ${errorMessage}`);
          return {
            content: [
              {
                type: 'text',
                text: `Failed to get HMR events: ${errorMessage}`
              }
            ],
            isError: true
          };
        }
      }
    );
  • Input schema for the 'get-hmr-events' tool: an optional 'limit' number parameter that controls how many events to return.
    {
      limit: z.number().optional().describe('Maximum number of events to return')
    },
  • The registerHMRTools function that calls server.tool() to register 'get-hmr-events' with its schema and handler on the MCP server.
    export function registerHMRTools(
      server: McpServer,
      lastHMREvents: HMREvent[]
    ) {
      // Recent HMR events retrieval tool
      server.tool(
        'get-hmr-events',
        'Retrieves recent HMR events',
        {
          limit: z.number().optional().describe('Maximum number of events to return')
        },
        async ({ limit }) => {
          try {
            const eventsToReturn = limit ? lastHMREvents.slice(0, limit) : lastHMREvents;
    
            return {
              content: [
                {
                  type: 'text',
                  text: eventsToReturn.length > 0
                    ? `Recent HMR events:\n${JSON.stringify(eventsToReturn, null, 2)}`
                    : 'No HMR events detected yet.'
                }
              ]
            };
          } catch (error) {
            const errorMessage = error instanceof Error ? error.message : String(error);
            Logger.error(`Failed to get HMR events: ${errorMessage}`);
            return {
              content: [
                {
                  type: 'text',
                  text: `Failed to get HMR events: ${errorMessage}`
                }
              ],
              isError: true
            };
          }
        }
      );
    }
  • src/index.ts:85-85 (registration)
    Invocation of registerHMRTools(server, lastHMREvents) from the main setup function, where lastHMREvents is the state array defined at line 26.
    registerHMRTools(server, lastHMREvents);
  • The HMREvent type definition used by the tool's handler to type the event array.
    export type HMREvent = HMRUpdate | HMRError | HMRBrowserError | { type: string; [key: string]: unknown };
Behavior2/5

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

No annotations are provided, so the description carries full responsibility. It only states 'Retrieves recent HMR events' but omits behavioral details like whether it is read-only, side effects, rate limits, pagination behavior, or what 'recent' means. The parameter 'limit' suggests a subset, but no further context is given.

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, concise sentence. It is front-loaded with the verb and resource, and every word contributes meaning. No wasted text.

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 low complexity (one parameter, no output schema), the description is minimal. It lacks details about what HMR events are, typical usage, default limits, and return format. The agent needs more context to use this tool effectively.

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 coverage is 100% for the single parameter 'limit', which already has a clear description ('Maximum number of events to return'). The tool description adds no additional meaning beyond what the schema provides, so the baseline score of 3 applies.

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 'Retrieves recent HMR events' clearly states the action (retrieves) and resource (HMR events). The term 'recent' adds a temporal qualifier, distinguishing it from a generic 'get events' tool. Sibling tools focus on browser actions, so this tool's purpose is distinct and unambiguous.

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. The description does not mention typical scenarios, prerequisites, or limitations. The agent has no context for deciding between this and sibling tools.

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/ESnark/blowback'

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