share_dashboard
Generates a public link to share a dashboard by providing its ID.
Instructions
Share a dashboard and create a public link
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dashboardId | Yes | ID of the dashboard to share |
Implementation Reference
- src/index.ts:776-789 (handler)MCP tool handler function for share_dashboard. Validates input via shareDashboardSchema, calls redashClient.shareDashboard(), and returns the public_url and api_key or an error.
async function shareDashboard(params: z.infer<typeof shareDashboardSchema>) { try { const result = await redashClient.shareDashboard(params.dashboardId); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { logger.error(`Error sharing dashboard ${params.dashboardId}: ${error}`); return { isError: true, content: [{ type: "text", text: `Error sharing dashboard ${params.dashboardId}: ${error instanceof Error ? error.message : String(error)}` }] }; } } - src/index.ts:772-774 (schema)Zod schema for share_dashboard tool input validation. Expects a single dashboardId (coerced to number).
const shareDashboardSchema = z.object({ dashboardId: z.coerce.number() }); - src/index.ts:1885-1895 (registration)MCP tool registration for share_dashboard in the ListToolsRequestSchema handler, defining its name, description, and input schema.
{ name: "share_dashboard", description: "Share a dashboard and create a public link", inputSchema: { type: "object", properties: { dashboardId: { type: "number", description: "ID of the dashboard to share" } }, required: ["dashboardId"] } }, - src/index.ts:2418-2420 (registration)Call routing for share_dashboard in the CallToolRequestSchema handler. Parses arguments with shareDashboardSchema and delegates to the shareDashboard handler function.
case "share_dashboard": logger.debug(`Handling share_dashboard`); return await shareDashboard(shareDashboardSchema.parse(args)); - src/redashClient.ts:814-822 (helper)RedashClient helper method that POSTs to /api/dashboards/{dashboardId}/share to create a public link for the dashboard. Returns public_url and api_key.
async shareDashboard(dashboardId: number): Promise<{ public_url: string; api_key: string }> { try { const response = await this.client.post(`/api/dashboards/${dashboardId}/share`); return response.data; } catch (error) { logger.error(`Error sharing dashboard ${dashboardId}: ${error}`); throw new Error(`Failed to share dashboard ${dashboardId}: ${error instanceof Error ? error.message : String(error)}`); } }