Skip to main content
Glama

generate_pie_chart

Create proportional pie charts or donut charts to visualize data like market shares or budget allocations. Customize dimensions, themes, and output formats (PNG, SVG, ECharts option) for clear graphical representation.

Instructions

Generate a pie chart to show the proportion of parts, such as, market share and budget allocation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesData for pie chart, such as, [{ category: 'Category A', value: 27 }, { category: 'Category B', value: 25 }].
heightNoSet the height of the chart, default is 600px.
innerRadiusNoSet the innerRadius of pie chart, the value between 0 and 1. Set the pie chart as a donut chart. Set the value to 0.6 or number in [0 ,1] to enable it.
outputTypeNoThe output type of the diagram. Can be 'png', 'svg' or 'option'. Default is 'png', 'png' will return the rendered PNG image, 'svg' will return the rendered SVG string, and 'option' will return the valid ECharts option.png
themeNoSet the theme for the chart, optional, default is 'default'.default
titleNoSet the title of the chart.
widthNoSet the width of the chart, default is 800px.

Implementation Reference

  • The async 'run' handler function that implements the core logic for generating a pie chart using ECharts, transforming input data, configuring series and options, and calling generateChartImage to produce the output.
    run: async (params: {
      data: Array<{ category: string; value: number }>;
      height: number;
      innerRadius?: number;
      theme?: "default" | "dark";
      title?: string;
      width: number;
      outputType?: "png" | "svg" | "option";
    }) => {
      const {
        data,
        height,
        innerRadius = 0,
        theme,
        title,
        width,
        outputType,
      } = params;
    
      // Transform data for ECharts
      const pieData = data.map((item) => ({
        name: item.category,
        value: item.value,
      }));
    
      const series: Array<SeriesOption> = [
        {
          data: pieData,
          radius: innerRadius > 0 ? [`${innerRadius * 100}%`, "70%"] : "70%",
          type: "pie",
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: "rgba(0, 0, 0, 0.5)",
            },
          },
        },
      ];
    
      const echartsOption: EChartsOption = {
        legend: {
          left: "center",
          orient: "horizontal",
          top: "bottom",
        },
        series,
        title: {
          left: "center",
          text: title,
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b}: {c} ({d}%)",
        },
      };
    
      return await generateChartImage(
        echartsOption,
        width,
        height,
        theme,
        outputType,
        "generate_pie_chart",
      );
    },
  • Zod input schema defining parameters for the tool: data array, dimensions (width/height), innerRadius, theme, title, and outputType.
    inputSchema: z.object({
      data: z
        .array(data)
        .describe(
          "Data for pie chart, such as, [{ category: 'Category A', value: 27 }, { category: 'Category B', value: 25 }].",
        )
        .nonempty({ message: "Pie chart data cannot be empty." }),
      height: HeightSchema,
      innerRadius: z
        .number()
        .default(0)
        .describe(
          "Set the innerRadius of pie chart, the value between 0 and 1. Set the pie chart as a donut chart. Set the value to 0.6 or number in [0 ,1] to enable it.",
        ),
      theme: ThemeSchema,
      title: TitleSchema,
      width: WidthSchema,
      outputType: OutputTypeSchema,
    }),
  • The generatePieChartTool is included in the exported 'tools' array, which aggregates all available chart tools for registration in the MCP server.
    export const tools = [
      generateEChartsTool,
      generateLineChartTool,
      generateBarChartTool,
      generatePieChartTool,
      generateRadarChartTool,
      generateScatterChartTool,
      generateSankeyChartTool,
      generateFunnelChartTool,
      generateGaugeChartTool,
      generateTreemapChartTool,
      generateSunburstChartTool,
      generateHeatmapChartTool,
      generateCandlestickChartTool,
      generateBoxplotChartTool,
      generateGraphChartTool,
      generateParallelChartTool,
      generateTreeChartTool,
    ];
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 mentions what the tool does but lacks critical behavioral information: it doesn't specify output format (though the schema covers this), doesn't mention whether this is a read-only operation or has side effects, doesn't discuss performance characteristics, error conditions, or authentication requirements. The description is purely functional without 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.

Conciseness4/5

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

The description is a single, efficient sentence that gets straight to the point. It states the core function immediately and provides relevant examples. There's no unnecessary elaboration or repetition. However, it could be slightly more structured by separating the core function from the examples for even better clarity.

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 with 7 parameters, no annotations, and no output schema, the description is insufficiently complete. While the schema covers parameters well, the description doesn't address key contextual aspects: it doesn't explain what the tool returns (image data? file path? chart object?), doesn't mention dependencies or prerequisites, and provides no guidance on appropriate use cases versus sibling tools. The functional statement alone doesn't provide enough context for effective tool selection.

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?

The description provides no parameter information beyond the tool's purpose. However, with 100% schema description coverage, all 7 parameters are well-documented in the schema with clear descriptions, defaults, and constraints. The description doesn't add value beyond what's already in the schema, but the schema provides comprehensive parameter documentation, meeting the baseline requirement.

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 tool's purpose: 'Generate a pie chart to show the proportion of parts'. It specifies the verb ('generate') and resource ('pie chart'), and provides examples of use cases ('market share and budget allocation'). However, it doesn't explicitly differentiate from sibling tools like 'generate_bar_chart' or 'generate_sunburst_chart' beyond the chart type name.

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?

The description provides no guidance on when to use this tool versus alternatives. With 15 sibling chart-generation tools, there's no mention of when a pie chart is appropriate (e.g., for showing proportions/percentages) versus when other chart types might be better suited. The examples ('market share and budget allocation') imply proportional data but don't establish clear boundaries.

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

Related 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/hustcc/mcp-echarts'

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