Skip to main content
Glama

gridstack_on

Add event listeners to GridStack.js dashboard layouts to monitor widget actions like drag, resize, add, remove, and enable/disable changes.

Instructions

Add event listener

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
eventNameYesEvent name to listen for
callbackYesJavaScript callback function code

Implementation Reference

  • The handler function that implements the core logic for the 'gridstack_on' tool. It destructures the eventName and callback from input parameters and uses GridStackUtils to generate executable JavaScript code that attaches the specified event listener to the GridStack grid instance via grid.on(eventName, callback). This is the exact implementation executing the tool.
    private async addEventListener(params: any): Promise<string> {
      const { eventName, callback } = params;
    
      return this.utils.generateGridStackCode("addEventListener", {
        eventName,
        callback,
        code: `grid.on('${eventName}', ${callback});`,
      });
    }
  • The tool registration entry in listTools() method, defining the name 'gridstack_on', description, and complete inputSchema specifying required eventName (enum of GridStack events) and callback as string JavaScript code.
    {
      name: "gridstack_on",
      description: "Add event listener",
      inputSchema: {
        type: "object",
        required: ["eventName", "callback"],
        properties: {
          eventName: {
            type: "string",
            enum: [
              "added",
              "change",
              "disable",
              "drag",
              "dragstart",
              "dragstop",
              "dropped",
              "enable",
              "removed",
              "resize",
              "resizestart",
              "resizestop",
            ],
            description: "Event name to listen for",
          },
          callback: {
            type: "string",
            description: "JavaScript callback function code",
          },
        },
      },
  • The dispatch case in callTool switch statement that routes 'gridstack_on' calls to the addEventListener handler method.
    case "gridstack_on":
      return this.addEventListener(args);
  • The inputSchema definition for the 'gridstack_on' tool, validating eventName as one of the supported GridStack events and callback as a string containing JavaScript function code.
    inputSchema: {
      type: "object",
      required: ["eventName", "callback"],
      properties: {
        eventName: {
          type: "string",
          enum: [
            "added",
            "change",
            "disable",
            "drag",
            "dragstart",
            "dragstop",
            "dropped",
            "enable",
            "removed",
            "resize",
            "resizestart",
            "resizestop",
          ],
          description: "Event name to listen for",
        },
        callback: {
          type: "string",
          description: "JavaScript callback function code",
        },
      },
  • Documentation reference to the 'gridstack_on' tool in the API documentation markdown.
    - \`gridstack_on\` - Add event listener
    - \`gridstack_off\` - Remove event listener
Behavior2/5

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

With no annotations, the description carries full burden but only states the action without disclosing behavioral traits like side effects (e.g., event persistence, memory implications), error handling, or what happens if the same listener is added multiple times. It's minimal and lacks operational context.

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?

Extremely concise with a single phrase 'Add event listener' that is front-loaded and wastes no words. Every part earns its place by directly stating the tool's core function without fluff.

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 annotations, no output schema, and a tool that modifies behavior (adding listeners), the description is incomplete. It doesn't explain what the listener does, how it integrates with Gridstack, or what to expect after invocation, leaving significant gaps for an AI agent.

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%, so the schema fully documents parameters. The description adds no meaning beyond the schema's details for 'eventName' and 'callback'. Baseline 3 is appropriate as the schema handles parameter semantics effectively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Add event listener' states a general action but lacks specificity about what resource it acts on (Gridstack grid/widget events) and how it differs from sibling 'gridstack_off' (which removes listeners). It's not tautological but remains vague about scope.

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 like 'gridstack_off' for removing listeners or other event-related tools. It implies usage for adding listeners but provides no context about prerequisites, timing, or exclusions.

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/raghavsharma-simpplr/gridstack-mcp-server'

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