list_widgets
Retrieve a list of all widgets in Redash to manage and review visualizations across dashboards.
Instructions
List all widgets
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1268-1281 (handler)Handler function for the list_widgets tool. Calls redashClient.getWidgets() and returns the result as JSON text.
async function listWidgets() { try { const result = await redashClient.getWidgets(); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { logger.error(`Error listing widgets: ${error}`); return { isError: true, content: [{ type: "text", text: `Error listing widgets: ${error instanceof Error ? error.message : String(error)}` }] }; } } - src/index.ts:2162-2169 (registration)Registration of the list_widgets tool in the ListToolsRequestSchema handler, defining name, description, and empty inputSchema.
{ name: "list_widgets", description: "List all widgets", inputSchema: { type: "object", properties: {} } }, - src/index.ts:2512-2515 (registration)Dispatch case in CallToolRequestSchema handler that routes 'list_widgets' requests to the listWidgets() handler function.
// Widget tools case "list_widgets": logger.debug(`Handling list_widgets`); return await listWidgets(); - src/redashClient.ts:1108-1116 (helper)The getWidgets() helper method on RedashClient that makes the actual GET /api/widgets HTTP request to the Redash API.
async getWidgets(): Promise<RedashWidget[]> { try { const response = await this.client.get('/api/widgets'); return response.data; } catch (error) { logger.error(`Error fetching widgets: ${error}`); throw new Error(`Failed to fetch widgets: ${error instanceof Error ? error.message : String(error)}`); } } - src/redashClient.ts:204-212 (schema)The RedashWidget interface defining the shape of widget data returned by the API.
export interface RedashWidget { id: number; dashboard_id: number; visualization_id?: number; visualization?: RedashVisualization; text?: string; width: number; options: any; }