Skip to main content
Glama

gridstack_get_cell_from_pixel

Convert pixel coordinates to grid cell positions for precise widget placement in GridStack dashboard layouts.

Instructions

Convert pixel coordinates to grid cell position

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
positionYes
useOffsetNoUse offset coordinates

Implementation Reference

  • The handler function that implements the tool logic. It destructures the input parameters (position and optional useOffset), then uses GridStackUtils to generate JavaScript code that invokes the GridStack library's getCellFromPixel method.
    private async getCellFromPixel(params: any): Promise<string> { const { position, useOffset = false } = params; return this.utils.generateGridStackCode("getCellFromPixel", { position, useOffset, code: `const cell = grid.getCellFromPixel(${JSON.stringify( position )}, ${useOffset});`, }); }
  • The tool definition including name, description, and inputSchema for validation of parameters: position (with top and left pixels) and optional useOffset.
    { name: "gridstack_get_cell_from_pixel", description: "Convert pixel coordinates to grid cell position", inputSchema: { type: "object", required: ["position"], properties: { position: { type: "object", required: ["top", "left"], properties: { top: { type: "number", description: "Top pixel position" }, left: { type: "number", description: "Left pixel position" }, }, }, useOffset: { type: "boolean", description: "Use offset coordinates", default: false, }, }, }, },
  • The switch case in the callTool method that registers and dispatches calls to the specific handler for this tool.
    case "gridstack_get_cell_from_pixel": return this.getCellFromPixel(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