export-chart
Export charts from PI Dashboard in JSON or CSV formats using the MCP Server, enabling secure access and management of chart resources for AI assistants and users.
Instructions
Export a chart in various formats
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | Yes | Export format | |
| id | Yes | Chart ID |
Implementation Reference
- build/index.js:838-868 (handler)The handler function for the 'export-chart' tool. It makes an authenticated request to the API endpoint `/charts/${id}/${format}`, handles both binary (base64) and text/JSON responses, and returns formatted content or an error response.}, 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)Zod input schema validating the required 'id' parameter (number) and optional 'format' parameter (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 using server.tool(), providing the tool name, description, schema, and inline handler function.server.tool("export-chart", "Export a chart in various formats", {