Skip to main content
Glama

gridstack_get_margin

Retrieve current margin values from GridStack.js layouts to maintain consistent spacing and alignment in dashboard widgets and responsive grid systems.

Instructions

Get current margin values

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that implements the core logic for the 'gridstack_get_margin' tool. It generates JavaScript code to retrieve the current grid margin using GridStack's getMargin() method.
    private async getMargin(): Promise<string> { return this.utils.generateGridStackCode("getMargin", { code: `const margin = grid.getMargin();`, }); }
  • The tool definition in listTools(), providing the name, description, and empty input schema (no parameters required).
    { name: "gridstack_get_margin", description: "Get current margin values", inputSchema: { type: "object", properties: {}, }, },
  • Registration and dispatch of the tool handler in the callTool switch statement.
    case "gridstack_get_margin": return this.getMargin();
  • Supporting utility method used by the handler to generate a formatted response including the code snippet, description, example, and notes for the getMargin operation.
    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); }
  • Helper method providing the specific description for the 'getMargin' operation used in the tool response.
    private getOperationDescription(operation: string): string { const descriptions: Record<string, string> = { init: "Initialize a new GridStack instance with the specified options", addWidget: "Add a new widget to the grid at the specified position", removeWidget: "Remove a widget from the grid", updateWidget: "Update widget properties (position, size, constraints)", moveWidget: "Move a widget to a new position", resizeWidget: "Resize a widget to new dimensions", compact: "Compact the grid layout to remove gaps", float: "Enable or disable floating widget mode", column: "Change the number of columns in the grid", cellHeight: "Update the height of grid cells", margin: "Update the margin/gap between grid items", batchUpdate: "Enable batch update mode for efficient multiple operations", save: "Serialize the current grid layout to JSON", load: "Load a grid layout from JSON data", enable: "Enable or disable grid interactions", destroy: "Destroy the grid instance and clean up", getGridItems: "Get all grid items (widgets)", setResponsive: "Configure responsive breakpoints", willItFit: "Check if a widget will fit at the specified position", isAreaEmpty: "Check if a grid area is empty", getCellHeight: "Get the current cell height", getCellFromPixel: "Convert pixel coordinates to grid cell position", addEventListener: "Add an event listener for grid events", removeEventListener: "Remove an event listener", makeWidget: "Convert an existing DOM element into a grid widget", removeAll: "Remove all widgets from the grid", getMargin: "Get current margin values", getColumn: "Get current number of columns", getFloat: "Get current float mode state", addGrid: "Create a new grid with options and children (static method)", }; return descriptions[operation] || "GridStack operation"; }

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