Skip to main content
Glama
gianlucamazza

MCP ASCII Charts

create_bar_chart

Generate ASCII bar charts in terminal environments to visualize numeric data with customizable orientation, labels, and dimensions.

Instructions

Create horizontal or vertical ASCII bar charts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesArray of numeric values to plot
labelsNoOptional labels for bars
titleNoOptional chart title
widthNoChart width (10-200, default: 60)
heightNoChart height (5-50, default: 15)
colorNoANSI color name
orientationNoBar orientation (default: horizontal)

Implementation Reference

  • Main handler function that orchestrates bar chart creation, dispatching to horizontal or vertical renderers based on options.
    export function createBarChart(data: ChartData, options: BarChartOptions = {}): ChartResult {
      const { data: values } = data;
      const { orientation = 'horizontal', showValues = true } = options;
      
      if (values.length === 0) {
        throw new Error('Data array cannot be empty');
      }
    
      if (orientation === 'horizontal') {
        return createHorizontalBarChart(data, showValues);
      } else {
        return createVerticalBarChart(data, showValues);
      }
    }
  • JSON schema defining the input parameters and validation rules for the create_bar_chart tool.
    inputSchema: {
      type: 'object',
      properties: {
        data: {
          type: 'array',
          items: { type: 'number' },
          description: 'Array of numeric values to plot'
        },
        labels: {
          type: 'array',
          items: { type: 'string' },
          description: 'Optional labels for bars',
          optional: true
        },
        title: {
          type: 'string',
          description: 'Optional chart title',
          optional: true
        },
        width: {
          type: 'number',
          description: 'Chart width (10-200, default: 60)',
          optional: true
        },
        height: {
          type: 'number',
          description: 'Chart height (5-50, default: 15)',
          optional: true
        },
        color: {
          type: 'string',
          description: 'ANSI color name',
          optional: true
        },
        orientation: {
          type: 'string',
          enum: ['horizontal', 'vertical'],
          description: 'Bar orientation (default: horizontal)',
          optional: true
        }
      },
      required: ['data'],
      examples: getToolExamples('create_bar_chart')
  • src/index.ts:104-151 (registration)
    Registration of the create_bar_chart tool in the MCP server's tool list response.
    {
      name: 'create_bar_chart',
      description: 'Create horizontal or vertical ASCII bar charts',
      inputSchema: {
        type: 'object',
        properties: {
          data: {
            type: 'array',
            items: { type: 'number' },
            description: 'Array of numeric values to plot'
          },
          labels: {
            type: 'array',
            items: { type: 'string' },
            description: 'Optional labels for bars',
            optional: true
          },
          title: {
            type: 'string',
            description: 'Optional chart title',
            optional: true
          },
          width: {
            type: 'number',
            description: 'Chart width (10-200, default: 60)',
            optional: true
          },
          height: {
            type: 'number',
            description: 'Chart height (5-50, default: 15)',
            optional: true
          },
          color: {
            type: 'string',
            description: 'ANSI color name',
            optional: true
          },
          orientation: {
            type: 'string',
            enum: ['horizontal', 'vertical'],
            description: 'Bar orientation (default: horizontal)',
            optional: true
          }
        },
        required: ['data'],
        examples: getToolExamples('create_bar_chart')
      }
    },
  • Helper function implementing the horizontal bar chart rendering logic with labels, scaling, and ASCII art generation.
    function createHorizontalBarChart(data: ChartData, showValues: boolean): ChartResult {
      const { data: values, labels, title, width = 60, height = 15, color = 'white' } = data;
      
      const maxValue = Math.max(...values);
      const minValue = Math.min(...values, 0); // Include 0 for proper scaling
      const valueRange = maxValue - minValue;
      
      // Calculate label width
      const maxLabelLength = labels ? Math.max(...labels.map(l => l.length)) : 0;
      const labelWidth = Math.min(maxLabelLength, 15);
      
      // Calculate bar area
      const barAreaWidth = width - labelWidth - 15; // Reserve space for labels and values
      const barsHeight = Math.min(values.length, height - (title ? 1 : 0));
      
      let result = '';
      
      // Add title
      if (title) {
        result += center(title, width) + '\n';
      }
      
      // Create bars
      for (let i = 0; i < values.length && i < barsHeight; i++) {
        let line = '';
        
        // Add label
        const label = labels && labels[i] ? labels[i].substring(0, labelWidth) : `Item ${i + 1}`;
        line += padRight(label, labelWidth);
        
        // Calculate bar length
        const normalizedValue = valueRange === 0 ? 0.5 : normalize(values[i], minValue, maxValue);
        const barLength = Math.floor(normalizedValue * barAreaWidth);
        
        // Create bar
        const fullBlocks = Math.floor(barLength);
        const remainder = barLength - fullBlocks;
        
        line += ' ';
        line += ASCII_CHARS.fullBlock.repeat(fullBlocks);
        
        // Add partial block if needed
        if (remainder > 0.75) {
          line += ASCII_CHARS.darkShade;
        } else if (remainder > 0.5) {
          line += ASCII_CHARS.mediumShade;
        } else if (remainder > 0.25) {
          line += ASCII_CHARS.lightShade;
        }
        
        // Add value if requested
        if (showValues) {
          const valueStr = ` ${values[i].toFixed(1)}`;
          line += valueStr;
        }
        
        result += line + '\n';
      }
      
      // Apply coloring
      if (color !== 'white') {
        result = colorize(result, color);
      }
      
      return {
        chart: result.trimEnd(),
        title,
        dimensions: { width, height }
      };
    }
  • Example input data sets for the create_bar_chart tool, used to populate schema examples.
    create_bar_chart: {
      horizontal: {
        data: [85, 67, 54, 92],
        labels: ["Frontend", "Backend", "DevOps", "QA"],
        title: "Team Performance",
        orientation: "horizontal"
      },
      vertical: {
        data: [12, 19, 15, 25, 22, 18],
        labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
        title: "Monthly Sales",
        orientation: "vertical",
        color: "cyan"
      },
      comparison: {
        data: [45, 55, 60, 40, 70],
        labels: ["Product A", "Product B", "Product C", "Product D", "Product E"],
        title: "Product Comparison",
        width: 70,
        height: 18
      }
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions the chart type (ASCII bar charts) and orientation options, it doesn't describe output format (e.g., text string), error handling, performance characteristics, or any constraints beyond what's in the schema. For a tool with 7 parameters and no annotations, this is insufficient.

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: 'Create horizontal or vertical ASCII bar charts.' It's front-loaded with the core purpose, uses no unnecessary words, and every element (creation action, orientation options, chart type) earns its place.

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?

Given the tool's moderate complexity (7 parameters, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks context about output format, error conditions, or when to use versus siblings. With no annotations to cover behavioral aspects, the description should provide more completeness for effective agent use.

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 description coverage is 100%, so all parameters are documented in the schema. The description adds no additional parameter semantics beyond what the schema provides (e.g., it doesn't explain data formatting, label alignment, or color usage). The baseline score of 3 is appropriate when the 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 tool's purpose: 'Create horizontal or vertical ASCII bar charts.' It specifies the verb ('create'), resource ('ASCII bar charts'), and distinguishes chart types (horizontal/vertical). However, it doesn't explicitly differentiate from sibling tools like create_histogram or create_line_chart, which prevents a perfect score.

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 its siblings (create_histogram, create_line_chart, create_scatter_plot, create_sparkline). It doesn't mention use cases, prerequisites, or alternatives. The only implied usage is for creating bar charts, but no context for choosing this over other chart types.

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/gianlucamazza/mcp-ascii-charts'

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