Skip to main content
Glama
gianlucamazza

MCP ASCII Charts

create_scatter_plot

Generate ASCII scatter plots to visualize data correlations and distributions directly in terminal environments for analysis.

Instructions

Generate ASCII scatter plots for correlation analysis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesArray of y-values (x-values will be indices)
labelsNoOptional point labels
titleNoOptional chart title
widthNoChart width (10-200, default: 60)
heightNoChart height (5-50, default: 15)
colorNoANSI color name

Implementation Reference

  • The core handler function that executes the logic for creating ASCII scatter plots from input data, including grid drawing, point plotting, optional trend line, and coloring.
    export function createScatterPlot(data: ChartData, options: ScatterPlotOptions = {}): ChartResult {
      const { data: values, title, width = 60, height = 15, color = 'white' } = data;
      const { pointChar = ASCII_CHARS.point, showTrendLine = false } = options;
      
      if (values.length === 0) {
        throw new Error('Data array cannot be empty');
      }
    
      const chartWidth = width - 10; // Reserve space for y-axis labels
      const chartHeight = height - 3; // Reserve space for x-axis and title
      
      // Create x-values (indices) and y-values (data)
      const xValues = values.map((_, i) => i);
      const yValues = values;
      
      const minX = Math.min(...xValues);
      const maxX = Math.max(...xValues);
      const minY = Math.min(...yValues);
      const maxY = Math.max(...yValues);
      
      // const xRange = maxX - minX || 1;
      const yRange = maxY - minY || 1;
      
      // Create the chart grid
      const grid = createGrid(width, height);
      
      // Draw y-axis labels and grid lines
      for (let y = 0; y < chartHeight; y++) {
        const value = maxY - (y / (chartHeight - 1)) * yRange;
        const label = value.toFixed(1);
        const labelStr = padLeft(label, 8);
        
        // Place y-axis label
        for (let i = 0; i < Math.min(labelStr.length, 8); i++) {
          if (8 - i < width) {
            grid[y][8 - i] = labelStr[i];
          }
        }
        
        // Draw y-axis line
        if (9 < width) {
          grid[y][9] = y === chartHeight - 1 ? ASCII_CHARS.bottomLeft : 
                       y === 0 ? ASCII_CHARS.topLeft : ASCII_CHARS.teeRight;
        }
        
        // Draw horizontal grid lines
        for (let x = 10; x < width; x++) {
          if (y === chartHeight - 1) {
            grid[y][x] = ASCII_CHARS.horizontal;
          } else if (y % 3 === 0) {
            grid[y][x] = '·'; // Light grid dots
          }
        }
      }
      
      // Draw x-axis labels
      const labelStep = Math.max(1, Math.floor(xValues.length / 8));
      for (let i = 0; i < xValues.length; i += labelStep) {
        const x = 10 + Math.floor(normalize(xValues[i], minX, maxX) * (chartWidth - 1));
        const label = xValues[i].toString();
        
        if (x + label.length <= width && height - 1 >= 0) {
          for (let j = 0; j < label.length && x + j < width; j++) {
            grid[height - 1][x + j] = label[j];
          }
        }
      }
      
      // Plot points
      const plotPoints: { x: number; y: number; originalX: number; originalY: number }[] = [];
      
      for (let i = 0; i < values.length; i++) {
        const normalizedX = normalize(xValues[i], minX, maxX);
        const normalizedY = normalize(yValues[i], minY, maxY);
        
        const plotX = 10 + Math.floor(normalizedX * (chartWidth - 1));
        const plotY = Math.floor((1 - normalizedY) * (chartHeight - 1));
        
        const x = clamp(plotX, 10, width - 1);
        const y = clamp(plotY, 0, chartHeight - 1);
        
        plotPoints.push({ 
          x, 
          y, 
          originalX: xValues[i], 
          originalY: yValues[i] 
        });
        
        // Draw the point
        if (x < width && y < chartHeight) {
          grid[y][x] = pointChar;
        }
      }
      
      // Draw trend line if requested
      if (showTrendLine && values.length > 1) {
        const trendLine = calculateLinearRegression(plotPoints.map(p => p.originalX), plotPoints.map(p => p.originalY));
        drawTrendLine(grid, trendLine, minX, maxX, minY, maxY, chartWidth, chartHeight);
      }
      
      // Convert grid to string and apply coloring
      let chart = gridToString(grid);
      
      if (color !== 'white') {
        chart = colorize(chart, color);
      }
      
      // Add title if provided
      if (title) {
        const titleLine = center(title, width);
        chart = titleLine + '\n' + chart;
      }
      
      return {
        chart,
        title,
        dimensions: { width, height }
      };
    }
  • src/index.ts:152-193 (registration)
    Tool registration in the MCP server's listTools handler, defining name, description, and input schema for create_scatter_plot.
    {
      name: 'create_scatter_plot',
      description: 'Generate ASCII scatter plots for correlation analysis',
      inputSchema: {
        type: 'object',
        properties: {
          data: {
            type: 'array',
            items: { type: 'number' },
            description: 'Array of y-values (x-values will be indices)'
          },
          labels: {
            type: 'array',
            items: { type: 'string' },
            description: 'Optional point labels',
            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
          }
        },
        required: ['data'],
        examples: getToolExamples('create_scatter_plot')
      }
    },
  • Input schema definition for the create_scatter_plot tool, outlining required data array and optional parameters like title, dimensions, and color.
    inputSchema: {
      type: 'object',
      properties: {
        data: {
          type: 'array',
          items: { type: 'number' },
          description: 'Array of y-values (x-values will be indices)'
        },
        labels: {
          type: 'array',
          items: { type: 'string' },
          description: 'Optional point labels',
          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
        }
      },
      required: ['data'],
      examples: getToolExamples('create_scatter_plot')
  • src/index.ts:358-364 (registration)
    Dispatch logic in the generateChart function that routes calls to the createScatterPlot handler.
    case 'create_scatter_plot': {
      progress.nextStep('Generating scatter plot');
      result = await withRequestTracking(
        () => Promise.resolve(createScatterPlot(chartData)),
        'create_scatter_plot'
      )();
      break;
  • Example data sets and parameters for testing the create_scatter_plot tool.
    create_scatter_plot: {
      correlation: {
        data: [1, 2, 3, 5, 8, 13, 21, 34],
        title: "Growth Pattern Analysis",
        width: 50,
        height: 12
      },
      distribution: {
        data: [12, 15, 18, 22, 19, 25, 30, 28, 35, 40],
        title: "Data Distribution",
        color: "magenta"
      },
      trend: {
        data: [100, 110, 105, 115, 120, 125, 130, 128, 135],
        title: "Trend Analysis",
        width: 60,
        height: 15
      }
    },
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. It states the tool generates ASCII scatter plots, implying a read-only output operation, but doesn't cover critical behaviors: whether it requires specific inputs beyond the schema, how errors are handled, if there are rate limits, or what the output format looks like (e.g., text-based plot). For a tool with no annotation coverage, this leaves significant gaps in understanding its operation.

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 extremely concise and front-loaded: 'Generate ASCII scatter plots for correlation analysis' is a single, efficient sentence that immediately conveys the core function. Every word earns its place, with no redundancy or unnecessary elaboration, making it easy for an AI agent to parse quickly.

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 (6 parameters, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks details on output format, error handling, or usage context relative to siblings. Without annotations or an output schema, the description should do more to explain behavioral aspects, but it meets a basic threshold by clarifying the tool's purpose and type of visualization.

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%, with all parameters well-documented in the schema (e.g., 'data' as 'Array of y-values (x-values will be indices)'). The description adds no additional parameter semantics beyond what's in the schema, such as explaining how 'data' relates to 'correlation analysis' or clarifying 'ANSI color name' options. Given the high schema coverage, a baseline score of 3 is appropriate, as the description doesn't compensate but doesn't need to heavily.

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: 'Generate ASCII scatter plots for correlation analysis.' It specifies the verb ('generate'), resource ('ASCII scatter plots'), and context ('for correlation analysis'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like create_line_chart or create_bar_chart, which likely also generate ASCII charts for different visualization types.

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. It mentions 'correlation analysis,' which implies a specific use case, but doesn't clarify when to choose scatter plots over line charts, histograms, or other siblings for similar data analysis tasks. There are no explicit when/when-not statements or named alternatives.

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