Skip to main content
Glama
gianlucamazza

MCP ASCII Charts

create_sparkline

Generate compact ASCII sparklines to visualize numeric trends inline in terminal environments, using customizable width and color options for clear data representation.

Instructions

Generate compact ASCII sparklines for inline charts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesArray of numeric values to plot
titleNoOptional sparkline title
widthNoSparkline width (10-100, default: 40)
colorNoANSI color name

Implementation Reference

  • The main handler function that executes the create_sparkline tool logic, generating ASCII sparklines with optional min/max labels, coloring, and titles.
    export function createSparkline(data: ChartData, options: SparklineOptions = {}): ChartResult {
      const { data: values, title, width = 40, color = 'white' } = data;
      const { showMinMax = true, fillChar } = options;
      
      if (values.length === 0) {
        throw new Error('Data array cannot be empty');
      }
    
      const minValue = Math.min(...values);
      const maxValue = Math.max(...values);
      const valueRange = maxValue - minValue;
      
      // Calculate sparkline width (reserve space for min/max if shown)
      const sparklineWidth = showMinMax ? width - 20 : width;
      
      let sparkline = '';
      
      // Generate sparkline using block characters
      if (fillChar) {
        // Use custom fill character
        for (let i = 0; i < Math.min(values.length, sparklineWidth); i++) {
          sparkline += fillChar;
        }
      } else {
        // Use gradient block characters
        const blocks = ASCII_CHARS.sparkBlocks;
        
        for (let i = 0; i < Math.min(values.length, sparklineWidth); i++) {
          const normalizedValue = valueRange === 0 ? 0.5 : normalize(values[i], minValue, maxValue);
          const blockIndex = Math.floor(normalizedValue * (blocks.length - 1));
          sparkline += blocks[blockIndex];
        }
      }
      
      // Add min/max values if requested
      if (showMinMax) {
        const minStr = minValue.toFixed(1);
        const maxStr = maxValue.toFixed(1);
        sparkline = `${minStr} ${sparkline} ${maxStr}`;
      }
      
      // Apply coloring
      if (color !== 'white') {
        sparkline = colorize(sparkline, color);
      }
      
      // Add title if provided
      let result = sparkline;
      if (title) {
        const titleLine = center(title, sparkline.length);
        result = titleLine + '\n' + sparkline;
      }
      
      return {
        chart: result,
        title,
        dimensions: { 
          width: sparkline.length, 
          height: title ? 2 : 1 
        }
      };
    }
  • src/index.ts:377-384 (registration)
    Tool dispatch/registration in the CallToolRequestSchema handler's switch statement, calling the createSparkline implementation.
    case 'create_sparkline': {
      progress.nextStep('Generating sparkline');
      result = await withRequestTracking(
        () => Promise.resolve(createSparkline(chartData)),
        'create_sparkline'
      )();
      break;
    }
  • Input schema definition for the create_sparkline tool, listed in ListToolsRequestSchema response.
    name: 'create_sparkline',
    description: 'Generate compact ASCII sparklines for inline charts',
    inputSchema: {
      type: 'object',
      properties: {
        data: {
          type: 'array',
          items: { type: 'number' },
          description: 'Array of numeric values to plot'
        },
        title: {
          type: 'string',
          description: 'Optional sparkline title',
          optional: true
        },
        width: {
          type: 'number',
          description: 'Sparkline width (10-100, default: 40)',
          minimum: 10,
          maximum: 100,
          optional: true
        },
        color: {
          type: 'string',
          description: 'ANSI color name',
          optional: true
        }
      },
      required: ['data'],
      examples: getToolExamples('create_sparkline')
    }
  • Type definition for SparklineOptions used in the handler function.
    export interface SparklineOptions {
      showMinMax?: boolean;
      fillChar?: string;
    }
  • Example inputs for the create_sparkline tool.
    create_sparkline: {
      compact: {
        data: [1, 3, 2, 5, 4, 7, 6, 8],
        title: "Quick Trend"
      },
      metrics: {
        data: [23, 25, 22, 28, 30, 27, 31, 29, 33],
        title: "System Load",
        color: "red",
        width: 30
      },
      inline: {
        data: [100, 102, 98, 105, 110, 108, 112],
        width: 25
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but lacks details on output format (e.g., text string), error handling, performance characteristics, or any constraints beyond what's implied by 'compact' and 'inline'. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 that front-loads the core purpose without unnecessary words. Every part of the sentence ('Generate compact ASCII sparklines for inline charts') contributes essential information, making it highly concise and well-structured.

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 (4 parameters, no output schema, no annotations), the description is minimally adequate. It covers the purpose but lacks details on output (what the sparkline looks like as text), usage guidelines, and behavioral traits. With no output schema, the description should ideally hint at the return format, but it doesn't, leaving gaps in completeness.

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 the schema already documents all parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain data formatting, color options, or width implications). Baseline 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.

Purpose5/5

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

The description clearly states the verb ('Generate') and resource ('compact ASCII sparklines for inline charts'), specifying both the output format (ASCII sparklines) and use case (inline charts). It effectively distinguishes from sibling tools like create_bar_chart or create_line_chart by focusing on compact, text-based visualizations rather than full graphical charts.

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 like create_line_chart or create_bar_chart. It mentions 'inline charts' but doesn't explain scenarios where sparklines are preferable over other chart types, nor does it mention any prerequisites or exclusions for usage.

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