Skip to main content
Glama

generate_sunburst_chart

Create a sunburst chart to visualize multi-level hierarchical data such as organizational structures, file system hierarchies, or category breakdowns. Input nested data with names and values; output as PNG, SVG, or ECharts option.

Instructions

Generate a sunburst chart to display multi-level hierarchical data, such as, organizational structure, file system hierarchy, or category breakdown.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesData for sunburst chart, such as, [{ name: 'Technology', value: 100, children: [{ name: 'Frontend', value: 60, children: [{ name: 'React', value: 30 }] }] }].
heightNoSet the height of the chart, default is 600px.
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.
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

Implementation Reference

  • The main tool definition for generate_sunburst_chart, containing both the schema (inputSchema) and the handler (run function). The run function constructs the ECharts sunburst series configuration and calls generateChartImage to produce the output.
    export const generateSunburstChartTool = {
      name: "generate_sunburst_chart",
      description:
        "Generate a sunburst chart to display multi-level hierarchical data, such as, organizational structure, file system hierarchy, or category breakdown.",
      inputSchema: z.object({
        data: z
          .array(SunburstNodeSchema)
          .describe(
            "Data for sunburst chart, such as, [{ name: 'Technology', value: 100, children: [{ name: 'Frontend', value: 60, children: [{ name: 'React', value: 30 }] }] }].",
          )
          .nonempty({ message: "Sunburst chart data cannot be empty." }),
        height: HeightSchema,
        theme: ThemeSchema,
        title: TitleSchema,
        width: WidthSchema,
        outputType: OutputTypeSchema,
      }),
      run: async (params: {
        data: Array<SunburstDataType>;
        height: number;
        theme?: "default" | "dark";
        title?: string;
        width: number;
        outputType?: "png" | "svg" | "option";
      }) => {
        const { data, height, theme, title, width, outputType } = params;
    
        const series: Array<SeriesOption> = [
          {
            type: "sunburst",
            data: data,
            radius: [0, "90%"],
            center: ["50%", "50%"],
            sort: undefined,
            emphasis: {
              focus: "ancestor",
            },
            label: {
              show: true,
              fontSize: 12,
              color: "#000",
              minAngle: 10,
            },
            itemStyle: {
              borderRadius: 7,
              borderWidth: 2,
              borderColor: "#fff",
            },
            levels: [
              {},
              {
                r0: "15%",
                r: "35%",
                itemStyle: {
                  borderWidth: 2,
                },
                label: {
                  rotate: "tangential",
                },
              },
              {
                r0: "35%",
                r: "70%",
                label: {
                  align: "right",
                },
              },
              {
                r0: "70%",
                r: "72%",
                label: {
                  position: "outside",
                  padding: 3,
                  silent: false,
                },
                itemStyle: {
                  borderWidth: 3,
                },
              },
            ],
          },
        ];
    
        const echartsOption: EChartsOption = {
          series,
          title: {
            left: "center",
            text: title,
          },
          tooltip: {
            trigger: "item",
          },
        };
    
        return await generateChartImage(
          echartsOption,
          width,
          height,
          theme,
          outputType,
          "generate_sunburst_chart",
        );
      },
    };
  • The SunburstNodeSchema is created via createHierarchicalSchema, defining the recursive structure with name, value, and optional children fields for hierarchical data.
    const SunburstNodeSchema = createHierarchicalSchema(
      "Node name, such as 'Technology'.",
      "Node value, such as 100.",
      false, // value is required for sunburst
      // biome-ignore lint/suspicious/noExplicitAny: Zod type inference requires any for recursive type compatibility
    ) satisfies z.ZodType<SunburstDataType, any, any>;
  • The reusable createHierarchicalSchema helper function that builds nested Zod schemas up to a configurable depth (default 5) to avoid unresolvable $ref in JSON Schema.
    export function createHierarchicalSchema(
      nameDesc: string,
      valueDesc: string,
      valueOptional: boolean,
      depth = 5,
      // biome-ignore lint/suspicious/noExplicitAny: This helper needs to return flexible types for different use cases
    ): any {
      // Build from deepest level up
      let currentLevel = z.object({
        name: z.string().describe(nameDesc),
        value: valueOptional
          ? z.number().optional().describe(valueDesc)
          : z.number().describe(valueDesc),
      });
    
      // Build each level from depth to 1
      for (let i = depth - 1; i >= 1; i--) {
        const childLevel = currentLevel;
        currentLevel = z.object({
          name: z.string().describe(nameDesc),
          value: valueOptional
            ? z.number().optional().describe(valueDesc)
            : z.number().describe(valueDesc),
          children: z
            .array(childLevel)
            .optional()
            .describe("Child nodes for hierarchical structure."),
        }) as typeof currentLevel;
      }
    
      return currentLevel;
    }
  • Import and registration of generateSunburstChartTool in the tools array, which is then iterated over in src/index.ts to register with the MCP server.
    import { generateSunburstChartTool } from "./sunburst";
    import { generateTreeChartTool } from "./tree";
    import { generateTreemapChartTool } from "./treemap";
    
    export const tools = [
      generateEChartsTool,
      generateAreaChartTool,
      generateLineChartTool,
      generateBarChartTool,
      generatePieChartTool,
      generateRadarChartTool,
      generateScatterChartTool,
      generateSankeyChartTool,
      generateFunnelChartTool,
      generateGaugeChartTool,
      generateTreemapChartTool,
      generateSunburstChartTool,
      generateHeatmapChartTool,
      generateCandlestickChartTool,
      generateBoxplotChartTool,
      generateGraphChartTool,
      generateParallelChartTool,
      generateTreeChartTool,
    ];
  • src/index.ts:22-35 (registration)
    The MCP server creation function that iterates over all tools and registers each with server.tool(name, description, inputSchema, run).
    function createEChartsServer(): McpServer {
      const server = new McpServer({
        name: "mcp-echarts",
        version: "0.1.0",
      });
    
      for (const tool of tools) {
        const { name, description, inputSchema, run } = tool;
        // biome-ignore lint/suspicious/noExplicitAny: <explanation>
        server.tool(name, description, inputSchema.shape as any, run as any);
      }
    
      return server;
    }
Behavior2/5

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

No annotations are provided, and the description fails to disclose any behavioral traits beyond the schema, such as output format limitations, performance considerations, or that the chart uses ECharts.

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 clear sentence that is front-loaded, but it could include a brief note on output types or usage without becoming verbose.

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

Completeness3/5

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

For a hierarchical chart with no output schema, the description is adequate but does not explain what the function returns (e.g., PNG, SVG, or option) or that it uses ECharts, leaving some gaps.

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 baseline is 3. The description does not add any additional meaning or context for the parameters beyond what the schema already provides.

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

Purpose5/5

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

The description clearly states it generates a sunburst chart for multi-level hierarchical data with concrete examples (organizational structure, file system hierarchy), making it distinct from siblings like pie or scatter charts.

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

Usage Guidelines3/5

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

The description implies use for hierarchical data but lacks explicit guidance on when to choose sunburst over sibling tools like treemap or tree charts, and does not mention when not to use it.

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

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