Skip to main content
Glama

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

Implementation Reference

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

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