Skip to main content
Glama

renderChart

Generate static SVG charts from data using Semiotic visualization components like LineChart, BarChart, and Heatmap for data analysis and presentation.

Instructions

Render a Semiotic chart to static SVG. Returns SVG string or validation errors. Available components: AreaChart, BarChart, BoxPlot, BubbleChart, ChordDiagram, ChoroplethMap, CirclePack, ConnectedScatterplot, DistanceCartogram, DonutChart, DotPlot, FlowMap, ForceDirectedGraph, GroupedBarChart, Heatmap, LineChart, OrbitDiagram, PieChart, ProportionalSymbolMap, SankeyDiagram, Scatterplot, StackedAreaChart, StackedBarChart, SwarmPlot, TreeDiagram, Treemap.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentYesChart component name, e.g. 'LineChart', 'BarChart'
propsNoChart props object, e.g. { data: [...], xAccessor: 'x' }.

Implementation Reference

  • The handler function 'renderChartHandler' which processes the 'renderChart' MCP tool call. It validates the requested component, checks the component registry, and calls 'renderHOCToSVG' to produce the final SVG output.
    async function renderChartHandler(args: { component?: string; props?: Record<string, any> }): Promise<ToolResult> {
      const component = args.component
      const props: Record<string, any> = args.props ?? {}
    
      if (!component) {
        return {
          content: [{ type: "text" as const, text: `Missing 'component' field. Provide { component: '<name>', props: { ... } }. Available: ${componentNames.join(", ")}` }],
          isError: true,
        }
      }
    
      if (!COMPONENT_REGISTRY[component]) {
        return {
          content: [{ type: "text" as const, text: `Unknown component "${component}". Available: ${componentNames.join(", ")}` }],
          isError: true,
        }
      }
    
      const result = renderHOCToSVG(component, props)
      if (result.error) {
        return {
          content: [{ type: "text" as const, text: result.error }],
          isError: true,
        }
      }
      return {
        content: [{ type: "text" as const, text: result.svg! }],
      }
    }
  • Registration of the 'renderChart' MCP tool using the server instance, defining its schema (component name and props) and mapping it to 'renderChartHandler'.
    srv.tool(
      "renderChart",
      `Render a Semiotic chart to static SVG. Returns SVG string or validation errors. Available components: ${componentNames.join(", ")}.`,
      {
        component: z.string().describe("Chart component name, e.g. 'LineChart', 'BarChart'"),
        props: z.record(z.string(), z.unknown()).optional().describe("Chart props object, e.g. { data: [...], xAccessor: 'x' }."),
      },
      renderChartHandler
    )

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/nteract/semiotic'

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