Skip to main content
Glama
VisActor

vchart-mcp-server

Official
by VisActor

generate_dual_axis_chart

Create dual-axis charts to visualize and compare two quantitative variables using combined bar and line series, enabling analysis of trends and magnitudes across distinct metrics.

Instructions

Generate a dual-axis chart for visualizing two quantitative variables using a combination of bar and line series. Ideal for comparing trends and magnitudes across two metrics with distinct y-axes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
outputNoChart output type. Defaults to 'image'.image
widthNoChart width. Optional, defaults to 500.
heightNoChart height. Optional, defaults to 500.
dataTableYesInput data for the dual axis chart, e.g., [{ x: '2018', gmv: 99.9, user: 1200 }].
xFieldYesDimension field. Must exist in the data.
yFieldYes
colorFieldNoColor grouping field. Should not duplicate the dimension field.
chartThemeNoChart theme. Optional, defaults to 'light'.
titleNoChart title text.
subTitleNoChart subtitle text.
titleOrientNoTitle position in the chart.
xAxisOrientNoX-axis position in the chart.
xAxisTitleNoX-axis title.
xAxisHasGridNoShow vertical grid lines for the X-axis.
xAxisHasLabelNoShow X-axis labels.
xAxisHasTickNoShow X-axis ticks.
leftYAxisTitleNoY-axis title.
leftYAxisHasGridNoShow horizontal grid lines for the Y-axis.
leftYAxisHasLabelNoShow Y-axis labels.
leftYAxisHasTickNoShow Y-axis ticks.
rightYAxisTitleNo
rightYAxisHasGridNo
rightYAxisHasLabelNo
rightYAxisHasTickNo
backgroundNoChart background color (hex). Optional, defaults to white.
colorsNoColor palette for chart elements.
stackOrPercentNoStacking mode: 'stack' for stacked data, 'percent' for percentage stacking. Requires 'color' field.

Implementation Reference

  • MCP CallToolRequest handler that maps 'generate_dual_axis_chart' to chartType 'dual_axis', validates arguments using the specific schema, invokes generateChartByType, and returns the chart output (spec/image/html).
    server.setRequestHandler(CallToolRequestSchema, async request => {
      const toolName = request.params.name;
      const chartType = Object.keys(Charts).find(
        key => (Charts as any)[key].tool.name === toolName
      );
    
      if (!chartType) {
        throw new McpError(
          ErrorCode.MethodNotFound,
          `Unknown tool: ${request.params.name}.`
        );
      }
    
      try {
        // Validate input using Zod before generating chart
        const args = request.params.arguments || {};
    
        // Select the appropriate schema based on the chart type
        const schema = Charts[chartType as keyof typeof Charts].schema;
    
        if (schema) {
          const result = schema.safeParse(args);
          if (!result.success) {
            throw new McpError(
              ErrorCode.InvalidParams,
              `Invalid parameters: ${result.error.message}`
            );
          }
        }
    
        const res = await generateChartByType(chartType, args);
    
        if (res && (res as any).spec) {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify((res as any).spec, null, 2),
              },
            ],
          };
        }
    
        if (res && (res as any).image) {
          return {
            content: [
              {
                type: 'text',
                text: (res as any).image,
              },
            ],
          };
        }
    
        if (res && (res as any).html) {
          return {
            content: [
              {
                type: 'text',
                text: (res as any).html,
              },
            ],
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: 'Failed to generate chart',
            },
          ],
        };
      } catch (error: any) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to generate chart: ${error?.message || 'Unknown error.'}`
        );
      }
    });
  • Core chart generation function called for 'dual_axis' type. Processes dual-axis specific options (left/right y-axes), builds VChart configuration using @visactor/generate-vchart, generates spec, and renders to image/html via external service.
    export async function generateChartByType(chartType: string, options: any) {
      const {
        title,
        subTitle,
        titleOrient,
        xAxisType,
        xAxisOrient,
        xAxisTitle,
        xAxisHasGrid,
        xAxisHasLabel,
        xAxisHasTick,
    
        yAxisType,
        yAxisOrient,
        yAxisTitle,
        yAxisHasGrid,
        yAxisHasLabel,
        yAxisHasTick,
    
        leftYAxisTitle,
        leftYAxisHasGrid,
        leftYAxisHasLabel,
        leftYAxisHasTick,
    
        rightYAxisTitle,
        rightYAxisHasGrid,
        rightYAxisHasLabel,
        rightYAxisHasTick,
    
        angleAxisTitle,
        angleAxisHasGrid,
        angleAxisHasLabel,
        angleAxisHasTick,
        angleAxisType,
    
        radiusAxisHasGrid,
        radiusAxisHasLabel,
        radiusAxisHasTick,
        radiusAxisType,
        radiusAxisTitle,
    
        output,
        width,
        height,
        ...res
      } = options;
    
      const opts = { ...res };
      const titleObj = filterValidAttributes({
        text: title,
        subText: subTitle,
        orient: titleOrient,
      });
      const xAxisObj = filterValidAttributes({
        type: xAxisType,
        orient: xAxisOrient,
        title: xAxisTitle,
        hasGrid: xAxisHasGrid,
        hasLabel: xAxisHasLabel,
        hasTick: xAxisHasTick,
      });
      const yAxisObj = filterValidAttributes({
        type: yAxisType,
        orient: yAxisOrient,
        title: yAxisTitle,
        hasGrid: yAxisHasGrid,
        hasLabel: yAxisHasLabel,
        hasTick: yAxisHasTick,
      });
      const leftYAxisObj = filterValidAttributes({
        title: leftYAxisTitle,
        hasGrid: leftYAxisHasGrid,
        hasLabel: leftYAxisHasLabel,
        hasTick: leftYAxisHasTick,
      });
      const rightYAxisObj = filterValidAttributes({
        title: rightYAxisTitle,
        hasGrid: rightYAxisHasGrid,
        hasLabel: rightYAxisHasLabel,
        hasTick: rightYAxisHasTick,
      });
      const angleAxisObj = filterValidAttributes({
        title: angleAxisTitle,
        hasGrid: angleAxisHasGrid,
        hasLabel: angleAxisHasLabel,
        hasTick: angleAxisHasTick,
        type: angleAxisType,
      });
      const radiusAxisObj = filterValidAttributes({
        hasGrid: radiusAxisHasGrid,
        hasLabel: radiusAxisHasLabel,
        hasTick: radiusAxisHasTick,
        type: radiusAxisType,
        title: radiusAxisTitle,
      });
    
      const cell: Record<string, string> = {};
    
      [
        "xField",
        "yField",
        "colorField",
        "categoryField",
        "valueField",
        "wordField",
        "sizeField",
        "timeField",
        "sourceField",
        "targetField",
        "setsField",
        "radiusField",
      ].forEach((fieldName) => {
        if (isValid(options[fieldName])) {
          cell[fieldName.replace("Field", "")] = options[fieldName];
          delete opts[fieldName];
        }
      });
    
      opts.cell = cell;
    
      if (!isEmpty(titleObj)) {
        opts.title = titleObj;
      }
    
      const axes = [
        xAxisObj,
        yAxisObj,
        leftYAxisObj,
        rightYAxisObj,
        angleAxisObj,
        radiusAxisObj,
      ];
    
      if (axes.some((axis) => !isEmpty(axis))) {
        opts.axes = axes.filter((axis) => !isEmpty(axis));
      }
    
      const { spec } = generateChart(options.chartType ?? chartType, opts);
    
      if (!spec) {
        return null;
      }
    
      if (output === "spec") {
        if (isValid(width)) {
          spec.width = width;
        }
        if (isValid(height)) {
          spec.height = height;
        }
    
        return {
          spec: spec,
        };
      }
    
      return gentrateChartImageOrHtml(output, spec, {
        width: `${width ?? 500}px`,
        height: `${height ?? 500}px`,
      });
    }
  • Zod input schema specific to dual-axis charts, requiring two yFields, left/right y-axis configurations, dataTable, xField, etc.
    const schema = z.object({
      output: ChartOutputSchema,
      width: WidthSchema,
      height: HeightSchema,
      dataTable: z
        .array(z.any())
        .describe(
          "Input data for the dual axis chart, e.g., [{ x: '2018', gmv: 99.9, user: 1200 }]."
        )
        .nonempty({ message: "Data for the dual axis chart must not be empty." }),
      xField: XFieldSchema,
      yField: z.array(YFieldSchema).length(2),
      colorField: ColorFieldSchema,
      chartTheme: ThemeSchema,
      title: TitleTextSchema,
      subTitle: TitleSubTextSchema,
      titleOrient: TitleOrientSchema,
    
      xAxisOrient: XAxisOrientSchema,
      xAxisTitle: XAxisTitleSchema,
      xAxisHasGrid: XAxisHasGridSchema,
      xAxisHasLabel: XAxisHasLabelSchema,
      xAxisHasTick: XAxisHasTickSchema,
    
      leftYAxisTitle: YAxisTitleSchema,
      leftYAxisHasGrid: YAxisHasGridSchema,
      leftYAxisHasLabel: YAxisHasLabelSchema,
      leftYAxisHasTick: YAxisHasTickSchema,
    
      rightYAxisTitle: YAxisTitleSchema,
      rightYAxisHasGrid: YAxisHasGridSchema,
      rightYAxisHasLabel: YAxisHasLabelSchema,
      rightYAxisHasTick: YAxisHasTickSchema,
    
      background: BackgroundSchema,
      colors: ColorsSchema,
      stackOrPercent: StackSchema,
    });
  • Defines the tool metadata (name, description, JSON schema) and exports as 'dual_axis' module for server registration.
    const tool = {
      name: "generate_dual_axis_chart",
      description:
        "Generate a dual-axis chart for visualizing two quantitative variables using a combination of bar and line series. Ideal for comparing trends and magnitudes across two metrics with distinct y-axes.",
      inputSchema: convertZodToJsonSchema(schema),
    };
    
    export const dual_axis = {
      schema,
      tool,
    };
  • src/server.ts:34-38 (registration)
    Registers the generate_dual_axis_chart tool (via Charts.dual_axis.tool) for MCP tool listing.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: Object.values(Charts).map(chart => (chart as any).tool),
      };
    });
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. While it mentions the chart generation purpose, it doesn't describe important behavioral aspects like whether this is a read-only operation, what permissions might be needed, error handling, performance characteristics, or what the output actually looks like. For a complex 27-parameter tool with no annotations, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two sentences that efficiently convey the core purpose and ideal use case. It's front-loaded with the main action and doesn't contain redundant information. However, given the tool's complexity, a slightly more structured approach might be beneficial, preventing a perfect score.

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

Completeness2/5

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

For a complex 27-parameter chart generation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (chart specification, image, HTML?), doesn't mention default behaviors beyond what's in parameter defaults, and doesn't provide guidance on the many parameter interactions. The description should do more to help an agent navigate this complexity.

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 81%, which is high, so the baseline is 3. The description adds minimal parameter semantics beyond what's in the schema - it mentions 'two quantitative variables' which relates to yField, and 'bar and line series' which hints at visualization types, but doesn't provide additional context about parameter interactions or usage patterns that aren't already in the schema descriptions.

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 specific action ('generate'), resource ('dual-axis chart'), and purpose ('visualizing two quantitative variables using a combination of bar and line series'). It distinguishes this tool from siblings by specifying the dual-axis nature and bar+line combination, which is unique among the listed chart generation tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use this tool ('ideal for comparing trends and magnitudes across two metrics with distinct y-axes'), which helps the agent understand appropriate scenarios. However, it doesn't explicitly state when NOT to use it or mention specific alternatives among the sibling tools, which prevents a perfect score.

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/VisActor/vchart-mcp-server'

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