Skip to main content
Glama

gridstack_init

Initialize a GridStack instance to create dynamic dashboard layouts with drag-and-drop widgets, customizable grid options, and responsive design capabilities.

Instructions

Initialize a new GridStack instance with specified options

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorNoCSS selector for the grid container element.grid-stack
optionsNoGridStack initialization options

Implementation Reference

  • Registration of the 'gridstack_init' tool in the listTools() method, including name, description, and full input schema definition.
    { name: "gridstack_init", description: "Initialize a new GridStack instance with specified options", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for the grid container element", default: ".grid-stack", }, options: { type: "object", description: "GridStack initialization options", properties: { acceptWidgets: { oneOf: [{ type: "boolean" }, { type: "string" }], description: "Accept widgets from other grids or external elements", }, alwaysShowResizeHandle: { type: "boolean", description: "Always show resize handles", }, animate: { type: "boolean", description: "Enable animations", }, auto: { type: "boolean", description: "Auto-position widgets", }, cellHeight: { oneOf: [{ type: "number" }, { type: "string" }], description: "Cell height (px, 'auto', 'initial', CSS units)", }, cellHeightThrottle: { type: "number", description: "Throttle time for cellHeight='auto' (ms)", }, column: { oneOf: [ { type: "number" }, { type: "string", enum: ["auto"] }, ], description: "Number of columns or 'auto' for nested grids", }, disableDrag: { type: "boolean", description: "Disable dragging of widgets", }, disableResize: { type: "boolean", description: "Disable resizing of widgets", }, float: { type: "boolean", description: "Enable floating widgets", }, handle: { type: "string", description: "Draggable handle selector", }, margin: { oneOf: [{ type: "number" }, { type: "string" }], description: "Gap between grid items (px or CSS units)", }, maxRow: { type: "number", description: "Maximum number of rows", }, minRow: { type: "number", description: "Minimum number of rows", }, removable: { oneOf: [{ type: "boolean" }, { type: "string" }], description: "Allow widgets to be removed by dragging out", }, rtl: { type: "boolean", description: "Right-to-left support", }, staticGrid: { type: "boolean", description: "Make grid static (no drag/resize)", }, }, }, }, }, },
  • The main handler function for 'gridstack_init' that destructures parameters, formats options, and generates the JavaScript code snippet for initializing a GridStack instance using the utility.
    private async initGrid(params: InitGridParams): Promise<string> { const { selector = ".grid-stack", options = {} } = params; return this.utils.generateGridStackCode("init", { selector, options: this.utils.formatOptions(options), code: `const grid = GridStack.init(${JSON.stringify( options, null, 2 )}, '${selector}');`, }); }
  • Tool dispatcher switch case in callTool() method that routes 'gridstack_init' calls to the initGrid handler function.
    switch (name) { case "gridstack_init": return this.initGrid(args as InitGridParams);
  • TypeScript interface defining the input parameters for the gridstack_init tool handler, referencing broader GridStackOptions.
    export interface InitGridParams { selector?: string; options?: GridStackOptions; }
  • Utility method used by the handler to format and enrich the response with operation description, example code, notes, and standardized JSON structure.
    generateGridStackCode(operation: string, params: any): string { const result: GridStackCodeResult = { operation, parameters: params, code: params.code || "", description: this.getOperationDescription(operation), example: this.getOperationExample(operation), notes: this.getOperationNotes(operation), }; return this.formatResponse(result); }

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