Skip to main content
Glama

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
NameRequiredDescriptionDefault
idYesChart ID
formatYesExport format

Implementation Reference

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

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/mingzilla/pi-api-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server