KEMBAR78
All the charting tools should contain `outputType` schema · Issue #23 · hustcc/mcp-echarts · GitHub
Skip to content

All the charting tools should contain outputType schema #23

@hustcc

Description

@hustcc

Similar with generate_echarts tool.

Image
export const generateEChartsTool = {
  name: "generate_echarts",
  description:
    "Generate visual charts using Apache ECharts with echarts option and configuration dynamically. Apache ECharts is an Open Source JavaScript Visualization Library, which is used to create interactive charts and visualizations in web applications. It supports a wide range of chart types, including line charts, bar charts, pie charts, scatter plots, and more. ECharts is highly customizable and can be integrated with various data sources to create dynamic visualizations.",
  inputSchema: z.object({
    echartsOption: z
      .string()
      .describe(
        `ECharts option and configuration used to generate charts. For example:
{
  "title": {
    "text": "ECharts Entry Example",
    "left": "center",
    "top": "2%"
  },
  "tooltip": {},
  "xAxis": {
    "data": ["shirt", "cardigan", "chiffon", "pants", "heels", "socks"]
  },
  "yAxis": {},
  "series": [{
    "name": "Sales",
    "type": "bar",
    "data": [5, 20, 36, 10, 10, 20]
  }]
}

ATTENTION: A valid ECharts option must be a valid JSON string, and cannot be empty.
`,
      )
      .nonempty({
        message:
          "A valid ECharts option must be a valid JSON string, and cannot be empty.",
      }),
    width: z
      .number()
      .min(
        50,
        "Width must be at least 50 pixels to ensure proper chart rendering",
      )
      .max(5000, "Width cannot exceed 5000 pixels")
      .describe("The width of the ECharts in pixels. Default is 800.")
      .optional()
      .default(800),
    height: z
      .number()
      .min(
        50,
        "Height must be at least 50 pixels to ensure proper chart rendering",
      )
      .max(5000, "Height cannot exceed 5000 pixels")
      .describe("The height of the ECharts in pixels. Default is 600.")
      .optional()
      .default(600),
    theme: z
      .enum(["default", "dark"])
      .describe("ECharts theme, optional. Default is 'default'.")
      .optional()
      .default("default"),
    outputType: z
      .enum(["png", "svg", "option"])
      .describe(
        "The output type of the diagram. Can be 'png', 'svg' or 'option'. Default is 'png', 'png' will return the rendered PNG image, 'svg' will return the rendered SVG string, and 'option' will return the valid ECharts option.",
      )
      .optional()
      .default("png"),
  }),
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions