Skip to main content
Glama

gridstack_add_widget

Add a new widget to a GridStack dashboard by specifying its position, size, content, and behavior settings for custom dashboard layouts.

Instructions

Add a new widget to the grid

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
widgetYesWidget configuration
triggerAddEventNoTrigger 'added' event

Implementation Reference

  • The main handler function for the 'gridstack_add_widget' tool. It extracts parameters and uses GridStackUtils to generate executable JavaScript code that calls GridStack's addWidget method.
    private async addWidget(params: AddWidgetParams): Promise<string> {
      const { widget, triggerAddEvent = true } = params;
    
      return this.utils.generateGridStackCode("addWidget", {
        widget,
        triggerAddEvent,
        code: `grid.addWidget(${JSON.stringify(widget, null, 2)});`,
      });
    }
  • Input schema definition for the gridstack_add_widget tool, specifying the required 'widget' object and optional triggerAddEvent flag.
    {
      name: "gridstack_add_widget",
      description: "Add a new widget to the grid",
      inputSchema: {
        type: "object",
        required: ["widget"],
        properties: {
          widget: {
            type: "object",
            description: "Widget configuration",
            properties: {
              id: {
                oneOf: [{ type: "string" }, { type: "number" }],
                description: "Unique widget identifier",
              },
              x: { type: "number", description: "X position" },
              y: { type: "number", description: "Y position" },
              w: { type: "number", description: "Width in columns" },
              h: { type: "number", description: "Height in rows" },
              minW: { type: "number", description: "Minimum width" },
              maxW: { type: "number", description: "Maximum width" },
              minH: { type: "number", description: "Minimum height" },
              maxH: { type: "number", description: "Maximum height" },
              locked: {
                type: "boolean",
                description: "Lock widget position/size",
              },
              noResize: { type: "boolean", description: "Disable resizing" },
              noMove: { type: "boolean", description: "Disable moving" },
              autoPosition: {
                type: "boolean",
                description: "Auto-position widget",
              },
              resizeToContent: {
                type: "boolean",
                description: "Resize to content",
              },
              content: { type: "string", description: "Widget HTML content" },
            },
          },
          triggerAddEvent: {
            type: "boolean",
            description: "Trigger 'added' event",
            default: true,
          },
        },
      },
    },
  • Dispatch registration in the callTool switch statement that maps the tool name to its handler function.
    case "gridstack_add_widget":
      return this.addWidget(args as AddWidgetParams);
  • TypeScript interface defining the parameters for the addWidget handler.
    export interface AddWidgetParams {
      widget: GridStackWidget;
      triggerAddEvent?: boolean;
    }
  • Core code generation logic that produces the GridStack.addWidget call, delegated to GridStackUtils but specific to this tool.
      return this.utils.generateGridStackCode("addWidget", {
        widget,
        triggerAddEvent,
        code: `grid.addWidget(${JSON.stringify(widget, null, 2)});`,
      });
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states the action ('Add') but doesn't describe what happens after addition (e.g., visual update, event triggering, persistence), whether it requires grid initialization, or potential side effects like layout changes. The description is minimal and misses key operational details.

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, clear sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly. No extraneous information or redundancy is present.

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 complexity (2 parameters with nested object, no output schema, no annotations), the description is incomplete. It doesn't address what the tool returns, how errors are handled, dependencies on other tools like 'gridstack_init', or integration with the broader grid system. For a mutation tool in a rich sibling set, more context is needed.

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%, providing detailed parameter documentation. The description adds no additional meaning beyond the schema, not explaining relationships between parameters (e.g., how 'autoPosition' interacts with 'x'/'y') or usage context. Baseline 3 is appropriate as the schema handles parameter semantics adequately.

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 ('Add') and resource ('widget to the grid'), making the purpose understandable. It distinguishes from siblings like 'gridstack_update_widget' or 'gridstack_move_widget' by specifying 'new widget', but doesn't explicitly contrast with 'gridstack_make_widget' or 'gridstack_load' which might have overlapping functionality.

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. With many sibling tools like 'gridstack_make_widget', 'gridstack_update_widget', and 'gridstack_load', the description lacks any context about prerequisites, timing, or comparisons, leaving the agent to infer usage from tool names alone.

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