gridstack_update_widget
Modify widget properties like position, size, and behavior in GridStack dashboards to customize layout appearance and functionality.
Instructions
Update widget properties
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| el | Yes | Widget selector or ID to update | |
| opts | Yes | Properties to update |
Implementation Reference
- src/tools/index.ts:906-914 (handler)The primary handler function for the gridstack_update_widget tool. It destructures the input parameters (el and opts), constructs the GridStack 'update' JavaScript code snippet, and delegates code generation and formatting to the GridStackUtils helper.private async updateWidget(params: UpdateWidgetParams): Promise<string> { const { el, opts } = params; return this.utils.generateGridStackCode("updateWidget", { element: el, options: opts, code: `grid.update('${String(el)}', ${JSON.stringify(opts, null, 2)});`, }); }
- src/tools/index.ts:203-234 (schema)Tool schema definition including name, description, and detailed inputSchema specifying required 'el' (widget selector/ID) and 'opts' (partial widget properties to update). This is returned by listTools() for MCP tool discovery.{ name: "gridstack_update_widget", description: "Update widget properties", inputSchema: { type: "object", required: ["el", "opts"], properties: { el: { type: "string", description: "Widget selector or ID to update", }, opts: { type: "object", description: "Properties to update", properties: { x: { type: "number" }, y: { type: "number" }, w: { type: "number" }, h: { type: "number" }, minW: { type: "number" }, maxW: { type: "number" }, minH: { type: "number" }, maxH: { type: "number" }, locked: { type: "boolean" }, noResize: { type: "boolean" }, noMove: { type: "boolean" }, content: { type: "string" }, }, }, }, }, },
- src/tools/index.ts:777-778 (registration)Dispatch registration in the central callTool switch statement, casting arguments to UpdateWidgetParams and invoking the specific handler.case "gridstack_update_widget": return this.updateWidget(args as UpdateWidgetParams);
- src/types.ts:189-192 (schema)TypeScript interface defining the exact parameter shape for the tool: 'el' as string or HTMLElement selector, and 'opts' as partial GridStackWidget properties.export interface UpdateWidgetParams { el: string | HTMLElement; opts: Partial<GridStackWidget>; }
- src/utils/gridstack-utils.ts:16-27 (helper)Core utility method invoked by the handler to format the response. It structures the output with operation details, generated code, description, example, and notes specific to 'updateWidget'.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); }