Skip to main content
Glama
hermesagent

mcp-hermes

Official
by hermesagent

render_chart

Render Chart.js configuration as a chart image. Generate bar, line, pie, scatter charts from JSON data. Returns base64-encoded PNG or JPEG image for reports or documentation.

Instructions

Render a Chart.js configuration as a chart image.

Use this when you need to:

  • Visualize data as bar, line, pie, scatter, or other Chart.js chart types

  • Generate charts programmatically from data

  • Create charts for reports or documentation

Args: chart_config: A JSON string containing a valid Chart.js configuration object. Example: '{"type":"bar","data":{"labels":["A","B","C"],"datasets":[{"label":"Values","data":[1,2,3]}]}}' width: Chart width in pixels (default: 800) height: Chart height in pixels (default: 600) format: Image format - 'png' or 'jpeg' (default: 'png')

Returns: Base64-encoded chart image with data URI prefix.

Rate limits: Shared with screenshot API. Get a free API key at https://hermesforge.dev/api/keys

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chart_configYes
widthNo
heightNo
formatNopng

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main handler function for the render_chart tool. Accepts a Chart.js JSON config, width, height, and format, then posts to the Hermesforge chart rendering API and returns a base64-encoded image.
    @mcp.tool()
    def render_chart(
        chart_config: str,
        width: int = 800,
        height: int = 600,
        format: str = "png",
    ) -> str:
        """
        Render a Chart.js configuration as a chart image.
    
        Use this when you need to:
        - Visualize data as bar, line, pie, scatter, or other Chart.js chart types
        - Generate charts programmatically from data
        - Create charts for reports or documentation
    
        Args:
            chart_config: A JSON string containing a valid Chart.js configuration object.
                Example: '{"type":"bar","data":{"labels":["A","B","C"],"datasets":[{"label":"Values","data":[1,2,3]}]}}'
            width: Chart width in pixels (default: 800)
            height: Chart height in pixels (default: 600)
            format: Image format - 'png' or 'jpeg' (default: 'png')
    
        Returns:
            Base64-encoded chart image with data URI prefix.
    
        Rate limits: Shared with screenshot API. Get a free API key at https://hermesforge.dev/api/keys
        """
        import json
    
        # Validate JSON
        try:
            config = json.loads(chart_config)
        except json.JSONDecodeError as e:
            return f"Error: chart_config is not valid JSON: {e}"
    
        payload = {
            "config": config,
            "width": width,
            "height": height,
            "format": format,
        }
    
        try:
            resp = requests.post(
                f"{API_BASE}/api/charts/render",
                json=payload,
                headers={**_auth_headers(), "Content-Type": "application/json"},
                timeout=30,
            )
        except requests.RequestException as e:
            return f"Error: Could not reach Hermesforge API: {e}"
    
        if resp.status_code == 200:
            img_bytes = resp.content
            b64 = base64.b64encode(img_bytes).decode()
            mime = "image/jpeg" if format == "jpeg" else "image/png"
            return f"data:{mime};base64,{b64}"
        elif resp.status_code == 429:
            try:
                msg = resp.json().get("message", "")
            except Exception:
                msg = ""
            return (
                f"Rate limit reached. {msg} "
                f"Get a free API key at https://hermesforge.dev/api/keys"
            )
        else:
            return f"Error: API returned {resp.status_code}: {resp.text[:200]}"
  • Type signature/input schema for render_chart. chart_config (str, required), width (int, default 800), height (int, default 600), format (str, default 'png'). Returns str.
    def render_chart(
        chart_config: str,
        width: int = 800,
        height: int = 600,
        format: str = "png",
    ) -> str:
  • Registration decorator registering render_chart as an MCP tool via the FastMCP instance.
    @mcp.tool()
Behavior3/5

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

No annotations provided, so description carries full burden. Mentions rate limits and API key, but lacks details on error handling, auth requirements, or whether the tool is destructive. Adequate but not exhaustive.

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?

Description is structured with bullet points and brief sentences. Every line adds value. No redundancy.

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

Completeness4/5

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

Given 4 parameters, no annotations, and an output schema (mentioned), the description covers return type and key usage. Could add more about output schema details but sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates well: explains chart_config with example, width/height with defaults, format with options. Adds meaning beyond schema.

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 'Render a Chart.js configuration as a chart image' with a specific verb and resource. It also lists use cases (bar, line, pie, etc.) and distinguishes from siblings like screenshot_url.

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?

Explicitly lists when to use with bullet points (visualize data, generate charts, create reports). Does not mention when not to use or directly name alternatives, but the context from sibling tools implies differentiation.

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/hermesagent/hermesforge-mcp'

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