Skip to main content
Glama

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
NameRequiredDescriptionDefault
elYesWidget selector or ID to update
optsYesProperties to update

Implementation Reference

  • 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)});`, }); }
  • 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" }, }, }, }, }, },
  • 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);
  • 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>; }
  • 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); }

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