Skip to main content
Glama
hermesagent

mcp-hermes

Official
by hermesagent

render_chart

Generate chart images from Chart.js configuration. Visualize data as bar, line, pie, or scatter charts for reports and 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

  • The render_chart tool handler function. Decorated with @mcp.tool() to register it as an MCP tool. Accepts a Chart.js JSON config, validates it, POSTs it to the Hermesforge API (/api/charts/render), and returns a base64-encoded data URI of the rendered chart 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]}"
  • Input schema for render_chart: chart_config (str - JSON string of Chart.js config), width (int, default 800), height (int, default 600), format (str, default 'png'). Returns a base64 data URI string.
    def render_chart(
        chart_config: str,
        width: int = 800,
        height: int = 600,
        format: str = "png",
    ) -> str:
  • Registration via the @mcp.tool() decorator from FastMCP, which registers render_chart as an MCP tool on the 'Hermesforge' server.
    @mcp.tool()
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses that the tool returns a Base64-encoded chart image with data URI prefix, and mentions rate limits shared with the screenshot API along with a link to get an API key. It does not cover potential errors, validation, or performance characteristics, but the key behavioral aspects (output format, rate limiting, auth requirement) are addressed.

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 remarkably concise and well-structured. It opens with a one-sentence summary, followed by bulleted use cases, then an Args section listing parameters with explanations, a Returns line, and a Rate limits note. Every sentence adds value, and the structure makes it scannable for an AI agent.

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 the tool's moderate complexity (rendering a chart from a JSON config), the description covers input parameters, output format, and rate limits. The output schema exists but is not detailed; however, the description clarifies the return type (Base64 image with data URI). It lacks error handling details, but overall it provides sufficient contextual information for basic usage.

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

Parameters5/5

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

The input schema has 0% description coverage, so the description must compensate. It does so thoroughly with an Args section explaining chart_config (including a valid JSON example), width and height with defaults, and format with accepted values ('png' or 'jpeg') and default. This adds significant meaning beyond the schema's type and default annotations.

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 tool renders a Chart.js configuration as a chart image. It lists specific use cases (visualize data as bar/line/pie/scatter charts, generate charts programmatically, create charts for reports) and the primary verb 'render' with the resource 'chart image' is precise. This effectively distinguishes it from sibling tools (get_api_usage, screenshot_url) which serve different purposes.

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 a 'Use this when you need to' section enumerating three common scenarios, giving clear context for when the tool is appropriate. However, it does not explicitly mention when not to use it or compare against alternatives, but the use cases are sufficiently illustrative for an AI agent to infer appropriate usage.

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