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";
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. 'Get' implies a read-only operation, but it doesn't specify whether this requires the grid to be initialized, if it returns a specific data structure, or any error conditions. The description is too minimal to provide adequate behavioral context for a tool with potential dependencies.

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, efficient sentence with no wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly. This is an excellent example of conciseness for a simple tool.

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 tool's simplicity (0 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain what 'margin values' refer to (e.g., CSS margins, grid spacing), the return format, or any context needed for proper use among many sibling tools. This leaves significant gaps for an agent to operate effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and the input schema has 100% description coverage (though empty). The description doesn't need to compensate for any parameter gaps, so it meets the baseline for a parameterless tool. No additional parameter information is provided or needed.

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 'Get current margin values' clearly states the verb ('Get') and resource ('current margin values'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'gridstack_margin' (which might set margins) or other 'gridstack_get_*' tools, so it doesn't reach the highest clarity level.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention context (e.g., after initialization, before layout changes), prerequisites, or exclusions, leaving the agent to infer usage from the name 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