Skip to main content
Glama

create_bar_chart

Generate horizontal or vertical ASCII bar charts directly in terminal environments using numeric data, labels, and customizable options like width, height, and color.

Instructions

Create horizontal or vertical ASCII bar charts

Input Schema

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

Implementation Reference

  • Core handler function that implements the create_bar_chart tool logic, validating input and dispatching to horizontal or vertical bar chart generators 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 for the create_bar_chart tool, including data array, optional labels, title, dimensions, color, and orientation.
    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 ListTools response, specifying name, description, and reference to input schema.
    { 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') } },
  • MCP CallToolRequest dispatch handler for create_bar_chart, extracting orientation and invoking the core createBarChart function.
    case 'create_bar_chart': { progress.nextStep('Generating bar chart'); const orientation = params.orientation || 'horizontal'; result = await withRequestTracking( () => Promise.resolve(createBarChart(chartData, { orientation })), 'create_bar_chart' )(); break; }
  • Helper examples providing sample inputs for testing the create_bar_chart tool in different configurations (horizontal, vertical, comparison).
    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 } },

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

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