Skip to main content
Glama

get_chart_snippet

Generates a ready-to-use HTML and JavaScript snippet for creating line, area, bar, horizontal bar, donut, or stacked charts.

Instructions

Returns a ready-to-use ElegantEChart.* HTML+JS snippet for a chart type.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chart_typeYes

Implementation Reference

  • The MCP tool handler for 'get_chart_snippet'. It receives a chart_type (line, area, bar, hbar, donut, stacked), looks it up in CHART_SNIPPETS, and returns the HTML+JS snippet.
    /* 5. get_chart_snippet */
    server.tool("get_chart_snippet", "ElegantEChart HTML+JS snippet.", { chart_type: z.enum(["line","area","bar","hbar","donut","stacked"]) }, async ({ chart_type }) => {
      const s = CHART_SNIPPETS[chart_type];
      return { content: [{ type: "text" as const, text: s ? `## ${chart_type} Chart\n\n${s}` : `Unknown: ${chart_type}` }] };
    });
  • Input schema for get_chart_snippet: chart_type is a Zod enum allowing only 'line', 'area', 'bar', 'hbar', 'donut', 'stacked'.
    server.tool("get_chart_snippet", "ElegantEChart HTML+JS snippet.", { chart_type: z.enum(["line","area","bar","hbar","donut","stacked"]) }, async ({ chart_type }) => {
  • The CHART_SNIPPETS data registry mapping chart type keys to their HTML+ElegantEChart JS code snippets. Contains predefined snippets for line, area, bar, hbar, donut, and stacked charts.
    const CHART_SNIPPETS: Record<string, string> = {
      line: `<div id="chart-line" style="width:100%;min-height:220px;"></div>\n<script>\nElegantEChart.line('chart-line', {\n  labels: ['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],\n  datasets: [\n    { label: 'Series A', values: [120,180,140,220,190,160,210], color: '#2C66DD', fill: false },\n    { label: 'Series B', values: [80,110,95,140,120,100,130],  color: '#009CBB', fill: false }\n  ]\n});\n<\/script>`,
      area: `<div id="chart-area" style="width:100%;min-height:220px;"></div>\n<script>\nElegantEChart.line('chart-area', {\n  labels: ['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],\n  datasets: [\n    { label: 'Series A', values: [120,180,140,220,190,160,210], color: '#2C66DD', fill: true },\n    { label: 'Series B', values: [80,110,95,140,120,100,130],  color: '#009CBB', fill: true }\n  ]\n});\n<\/script>`,
      bar: `<div id="chart-bar" style="width:100%;min-height:220px;"></div>\n<script>\nElegantEChart.bar('chart-bar', {\n  labels: ['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],\n  datasets: [\n    { label: 'Series A', values: [24,18,31,22,27,19,26], color: '#2C66DD' },\n    { label: 'Series B', values: [8,5,12,6,9,4,7],       color: '#DD1616' }\n  ]\n});\n<\/script>`,
      hbar: `<div id="chart-hbar" style="width:100%;min-height:220px;"></div>\n<script>\nElegantEChart.hbar('chart-hbar', {\n  labels: ['Item A','Item B','Item C','Item D','Item E'],\n  datasets: [\n    { label: 'Count', values: [866,3452,1231,4567,987], color: '#2C66DD' }\n  ]\n});\n<\/script>`,
      donut: `<div id="chart-donut" style="width:100%;min-height:220px;"></div>\n<script>\nElegantEChart.donut('chart-donut', {\n  labels: ['Critical','High','Medium','Low'],\n  values: [18,34,56,92],\n  colors: ['#DD1616','#D14900','#FABB34','#198019']\n});\n<\/script>`,
      stacked: `<div id="chart-stacked" style="width:100%;min-height:220px;"></div>\n<script>\nElegantEChart.bar('chart-stacked', {\n  labels: ['Mon','Tue','Wed','Thu','Fri'],\n  datasets: [\n    { label: 'Critical', values: [12,19,8,15,22], color: '#DD1616' },\n    { label: 'High',     values: [8,14,11,9,17],  color: '#D14900' },\n    { label: 'Medium',   values: [20,25,18,22,30], color: '#FABB34' }\n  ]\n}, { stacked: true });\n<\/script>`,
    };
Behavior3/5

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

With no annotations, the description carries the full burden. It implies a read-only operation ('returns'), but does not disclose any additional behavioral traits such as whether the snippet is generated dynamically or cached, or any authentication requirements.

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, concise sentence with no wasted words. It effectively communicates the tool's purpose without unnecessary elaboration.

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

Completeness4/5

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

For a tool with one enum parameter and no output schema, the description is fairly complete. However, it could mention what the snippet includes (e.g., HTML+JS) and that it is ready-to-use, which it does. Minor gap: no mention of output format beyond 'snippet'.

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 schema has 0% description coverage, but the single required parameter 'chart_type' is an enum, so the parameter is self-explanatory. The description mentions 'chart type' but does not add detail beyond the schema.

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 the verb 'returns' and the resource 'ready-to-use ElegantEChart.* HTML+JS snippet for a chart type', making the purpose specific and distinct from siblings like get_component or get_shell.

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 on when to use this tool vs. alternatives. The description lacks any mention of context, prerequisites, or exclusions, leaving the agent to infer usage from the tool name alone.

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/Anguraj-zoho/elegant-mcp'

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