Skip to main content
Glama

download_chart

Save chart images locally by providing Chart.js configurations and output paths for various chart types like bar, line, and pie charts.

Instructions

Download a chart image to a local file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
configYesChart configuration object
outputPathYesPath where the chart image should be saved

Implementation Reference

  • Handler for the 'download_chart' tool. Parses arguments, generates chart config and URL using helpers, downloads the image with axios, saves to outputPath using fs.promises.writeFile, and returns success message.
    case 'download_chart': {
      try {
        const { config, outputPath } = request.params.arguments as { 
          config: Record<string, unknown>;
          outputPath: string;
        };
        const chartConfig = this.generateChartConfig(config);
        const url = await this.generateChartUrl(chartConfig);
        
        const response = await axios.get(url, { responseType: 'arraybuffer' });
        const fs = await import('fs');
        await fs.promises.writeFile(outputPath, response.data);
        
        return {
          content: [
            {
              type: 'text',
              text: `Chart saved to ${outputPath}`
            }
          ]
        };
      } catch (error: any) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to download chart: ${error?.message || 'Unknown error'}`
        );
      }
    }
  • Input schema for download_chart tool, defining required 'config' object and 'outputPath' string.
    inputSchema: {
      type: 'object',
      properties: {
        config: {
          type: 'object',
          description: 'Chart configuration object'
        },
        outputPath: {
          type: 'string',
          description: 'Path where the chart image should be saved'
        }
      },
      required: ['config', 'outputPath']
    }
  • src/index.ts:197-214 (registration)
    Tool registration entry in ListTools response, including name, description, and input schema.
    {
      name: 'download_chart',
      description: 'Download a chart image to a local file',
      inputSchema: {
        type: 'object',
        properties: {
          config: {
            type: 'object',
            description: 'Chart configuration object'
          },
          outputPath: {
            type: 'string',
            description: 'Path where the chart image should be saved'
          }
        },
        required: ['config', 'outputPath']
      }
    }
  • Key helper function used by download_chart to validate and construct the ChartConfig from the input config argument.
    private generateChartConfig(args: any): ChartConfig {
      const { type, labels, datasets, title, options = {} } = args;
      
      this.validateChartType(type);
    
      const config: ChartConfig = {
        type,
        data: {
          labels: labels || [],
          datasets: datasets.map((dataset: any) => ({
            label: dataset.label || '',
            data: dataset.data,
            backgroundColor: dataset.backgroundColor,
            borderColor: dataset.borderColor,
            ...dataset.additionalConfig
          }))
        },
        options: {
          ...options,
          ...(title && {
            title: {
              display: true,
              text: title
            }
          })
        }
      };
    
      // Special handling for specific chart types
      switch (type) {
        case 'radialGauge':
        case 'speedometer':
          if (!datasets?.[0]?.data?.[0]) {
            throw new McpError(
              ErrorCode.InvalidParams,
              `${type} requires a single numeric value`
            );
          }
          config.options = {
            ...config.options,
            plugins: {
              datalabels: {
                display: true,
                formatter: (value: number) => value
              }
            }
          };
          break;
    
        case 'scatter':
        case 'bubble':
          datasets.forEach((dataset: any) => {
            if (!Array.isArray(dataset.data[0])) {
              throw new McpError(
                ErrorCode.InvalidParams,
                `${type} requires data points in [x, y${type === 'bubble' ? ', r' : ''}] format`
              );
            }
          });
          break;
      }
    
      return config;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool downloads to a local file, which implies file system write operations, but doesn't disclose permissions needed, whether it overwrites existing files, supported image formats, error conditions, or any rate limits. The description is minimal and lacks important behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a simple download operation and front-loads the core purpose immediately. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool that performs file system writes with no annotations and no output schema, the description is insufficient. It doesn't explain what happens on success/failure, what file formats are supported, whether the config parameter needs to match a previously generated chart, or any error conditions. The minimal description leaves too many operational questions unanswered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters adequately. The description mentions 'chart image' which aligns with the config parameter's purpose, and 'to a local file' which aligns with outputPath, but adds no additional semantic context beyond what the schema provides. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Download') and resource ('a chart image to a local file'), providing a specific verb+resource combination. However, it doesn't differentiate from the sibling tool 'generate_chart' - we can infer download might follow generation, but this isn't explicitly stated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives. The existence of 'generate_chart' as a sibling tool suggests potential workflow relationships, but the description offers no explicit when/when-not instructions or prerequisites for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Magic-Sauce/Quickchart-MCP-Server'

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