Skip to main content
Glama

gridstack_get_grid_items

Retrieve all items from a GridStack.js dashboard layout, with an option to filter for only visible widgets to manage dynamic grid content.

Instructions

Get all grid items

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
onlyVisibleNoOnly return visible items

Implementation Reference

  • The primary handler function for the 'gridstack_get_grid_items' tool. It destructures the input parameters and uses GridStackUtils to generate executable JavaScript code that calls GridStack's getGridItems() method, optionally filtering for visible items only.
    private async getGridItems(params: GetGridItemsParams): Promise<string> { const { onlyVisible = false } = params; return this.utils.generateGridStackCode("getGridItems", { onlyVisible, code: `const items = grid.getGridItems(${onlyVisible});`, }); }
  • Tool registration entry in the listTools() method, defining the tool's name, description, and JSON input schema for MCP tool discovery and validation.
    { name: "gridstack_get_grid_items", description: "Get all grid items", inputSchema: { type: "object", properties: { onlyVisible: { type: "boolean", description: "Only return visible items", default: false, }, }, }, },
  • Dispatch registration in the callTool switch statement, casting arguments to the correct type and invoking the handler method.
    case "gridstack_get_grid_items": return this.getGridItems(args as GetGridItemsParams);
  • TypeScript type definition for the tool's input parameters, used for type safety in the handler.
    export interface GetGridItemsParams { onlyVisible?: boolean; }
  • Supporting utility method called by the handler to format the response with generated code, parameters, description, example, and notes specific to the 'getGridItems' 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); }

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