Skip to main content
Glama

gridstack_add_grid

Create a new dynamic grid layout with customizable widgets and options for building responsive dashboards using GridStack.js functionality.

Instructions

Create a new grid with options and children (static method)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
parentYesParent element selector
optNoGrid options including children

Implementation Reference

  • The handler function that implements the core logic for the 'gridstack_add_grid' tool. It extracts parameters and generates JavaScript code using GridStackUtils to call the static GridStack.addGrid method, creating a new grid instance.
    private async addGrid(params: any): Promise<string> {
      const { parent, opt = {} } = params;
    
      return this.utils.generateGridStackCode("addGrid", {
        parent,
        options: opt,
        code: `const grid = GridStack.addGrid('${parent}', ${JSON.stringify(
          opt,
          null,
          2
        )});`,
      });
    }
  • The input schema and tool definition for 'gridstack_add_grid', defining required parameters like parent selector and optional grid options.
    {
      name: "gridstack_add_grid",
      description:
        "Create a new grid with options and children (static method)",
      inputSchema: {
        type: "object",
        required: ["parent"],
        properties: {
          parent: {
            type: "string",
            description: "Parent element selector",
          },
          opt: {
            type: "object",
            description: "Grid options including children",
            properties: {
              children: {
                type: "array",
                items: {
                  type: "object",
                  description: "Child widget configuration",
                },
                description: "Array of child widgets to load",
              },
            },
          },
        },
      },
    },
  • Registration of the tool handler in the central callTool switch statement, dispatching calls to the addGrid method.
    case "gridstack_add_grid":
      return this.addGrid(args);

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