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
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "gridstack_get_grid_items"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| onlyVisible | No | Only return visible items |
Implementation Reference
- src/tools/index.ts:1043-1050 (handler)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});`, }); } - src/tools/index.ts:475-488 (registration)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, }, }, }, }, - src/tools/index.ts:816-817 (registration)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); - src/types.ts:256-258 (schema)TypeScript type definition for the tool's input parameters, used for type safety in the handler.
export interface GetGridItemsParams { onlyVisible?: boolean; } - src/utils/gridstack-utils.ts:16-27 (helper)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); }