export-chart
Export charts from PI Dashboard in JSON or CSV formats by specifying the chart ID and desired format for data analysis or sharing.
Instructions
Export a chart in various formats
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Chart ID | |
| format | Yes | Export format |
Implementation Reference
- build/index.js:835-868 (handler)Complete inline implementation of the 'export-chart' MCP tool handler. Registers the tool with Zod schema for inputs (chart ID and format: json/csv), makes authenticated API request to export endpoint, handles binary (base64 preview) or JSON/text responses, and returns formatted content or error.server.tool("export-chart", "Export a chart in various formats", { id: z.number().describe("Chart ID"), format: z.enum(["json", "csv"]).describe("Export format") }, async ({ id, format }) => { try { const result = await authenticatedRequest(`/charts/${id}/${format}`); if (result && typeof result === 'object' && 'contentType' in result && 'data' in result && typeof result.data === 'string') { // This is a binary response return { content: [{ type: "text", text: `Chart exported successfully as ${format.toUpperCase()}.\nContent type: ${result.contentType}\nBase64 data: ${result.data.substring(0, 100)}...` }] }; } else { // This is a JSON or text response return { content: [{ type: "text", text: typeof result === 'string' ? result : JSON.stringify(result, null, 2) }] }; } } catch (error) { return { isError: true, content: [{ type: "text", text: `Error exporting chart: ${getErrorMessage(error)}` }] }; } });
- build/index.js:836-837 (schema)Input schema for the export-chart tool using Zod: requires numeric chart ID and format enum (json or csv).id: z.number().describe("Chart ID"), format: z.enum(["json", "csv"]).describe("Export format")
- build/index.js:835-835 (registration)Registration of the 'export-chart' tool on the MCP server with name, description, schema, and handler.server.tool("export-chart", "Export a chart in various formats", {