Skip to main content
Glama
hqu

Datawrapper MCP

by hqu

update_chart

Modify existing Datawrapper chart data or configuration while preserving the original chart type. Update titles, styling, axes, and data points for visualizations.

Instructions

⚠️ DATAWRAPPER MCP TOOL ⚠️ This is part of the Datawrapper MCP server integration.


Update an existing Datawrapper chart's data or configuration using Pydantic models.

⚠️ IMPORTANT LIMITATION: You CANNOT change the chart type with this tool. Chart types are immutable once created. To change from one chart type to another (e.g., column → stacked_bar, or line → area), you must create a new chart instead.

WHAT YOU CAN UPDATE: • Chart data (add/modify/replace data points) • Title, intro, byline, source information • Colors, styling, axes configuration • Tooltips, annotations, labels • Any other configuration options for the existing chart type

WHAT YOU CANNOT UPDATE: ✗ Chart type (bar, line, column, etc.) - this is permanent

The chart_config must use high-level Pydantic fields only (title, intro, byline, source_name, source_url, etc.). Do NOT use low-level serialized structures like 'metadata', 'visualize', or other internal API fields.

STYLING UPDATES: Use get_chart_schema to see available fields, then apply styling changes:

  • Colors: {"color_category": {"sales": "#ff0000"}}

  • Line properties: {"lines": [{"column": "sales", "width": "style2"}]}

  • Axis settings: {"custom_range_y": [0, 200], "y_grid_format": "0,0"}

  • Tooltips: {"tooltip_number_format": "0.0"}

See https://datawrapper.readthedocs.io/en/latest/ for detailed examples. The provided config will be validated through Pydantic and merged with the existing chart configuration.

Args: chart_id: ID of the chart to update data: New chart data (optional). Same formats as create_chart. chart_config: Updated chart configuration using high-level Pydantic fields (optional)

Returns: Confirmation message with editor URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chart_idYes
dataNo
chart_configNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'update_chart' handler function that processes data updates and configuration adjustments for a Datawrapper chart.
    async def update_chart(arguments: UpdateChartArgs) -> list[TextContent]:
        """Update an existing chart's data or configuration."""
        chart_id = arguments["chart_id"]
    
        # Get chart using factory function - returns correct Pydantic class instance
        chart = get_chart(chart_id)
    
        # Update data if provided
        if "data" in arguments:
            df = json_to_dataframe(arguments["data"])
            chart.data = df
    
        # Update config if provided
        if "chart_config" in arguments:
            # Directly set attributes on the chart instance
            # Pydantic will validate each assignment automatically due to validate_assignment=True
            try:
                # Build a mapping of aliases to field names
                alias_to_field = {}
                for field_name, field_info in chart.model_fields.items():
                    # Add the field name itself
                    alias_to_field[field_name] = field_name
                    # Add any aliases
                    if field_info.alias:
                        alias_to_field[field_info.alias] = field_name
    
                for key, value in arguments["chart_config"].items():
                    # Convert alias to field name if needed
                    field_name = alias_to_field.get(key, key)
                    setattr(chart, field_name, value)
    
            except Exception as e:
                raise ValueError(
                    f"Invalid chart configuration: {str(e)}\n\n"
                    f"Use get_chart_schema to see the valid schema for this chart type. "
                    f"Only high-level Pydantic fields are accepted."
                )
    
        # Update using Pydantic instance method
        chart.update()
    
        result = {
            "chart_id": chart.chart_id,
            "message": "Chart updated successfully!",
            "edit_url": chart.get_editor_url(),
        }
    
        return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • The 'UpdateChartArgs' TypedDict defining the expected input structure for the 'update_chart' handler.
    class UpdateChartArgs(TypedDict):
        """Arguments for update_chart handler."""
    
        chart_id: str
        data: NotRequired[str | list[dict] | dict[str, list]]
        chart_config: NotRequired[dict[str, Any]]
  • server.py:289-349 (registration)
    The 'update_chart' tool registration in the MCP server, which interfaces with the 'update_chart_handler'.
    async def update_chart(
        chart_id: str,
        data: str | list | dict | None = None,
        chart_config: dict | None = None,
    ) -> str:
        """⚠️ DATAWRAPPER MCP TOOL ⚠️
        This is part of the Datawrapper MCP server integration.
    
        ---
    
        Update an existing Datawrapper chart's data or configuration using Pydantic models.
    
        ⚠️ IMPORTANT LIMITATION: You CANNOT change the chart type with this tool.
        Chart types are immutable once created. To change from one chart type to another
        (e.g., column → stacked_bar, or line → area), you must create a new chart instead.
    
        WHAT YOU CAN UPDATE:
        • Chart data (add/modify/replace data points)
        • Title, intro, byline, source information
        • Colors, styling, axes configuration
        • Tooltips, annotations, labels
        • Any other configuration options for the existing chart type
    
        WHAT YOU CANNOT UPDATE:
        ✗ Chart type (bar, line, column, etc.) - this is permanent
    
        The chart_config must use high-level Pydantic fields only (title, intro,
        byline, source_name, source_url, etc.). Do NOT use low-level serialized structures
        like 'metadata', 'visualize', or other internal API fields.
    
        STYLING UPDATES:
        Use get_chart_schema to see available fields, then apply styling changes:
        - Colors: {"color_category": {"sales": "#ff0000"}}
        - Line properties: {"lines": [{"column": "sales", "width": "style2"}]}
        - Axis settings: {"custom_range_y": [0, 200], "y_grid_format": "0,0"}
        - Tooltips: {"tooltip_number_format": "0.0"}
    
        See https://datawrapper.readthedocs.io/en/latest/ for detailed examples.
        The provided config will be validated through Pydantic and merged with the existing
        chart configuration.
    
        Args:
            chart_id: ID of the chart to update
            data: New chart data (optional). Same formats as create_chart.
            chart_config: Updated chart configuration using high-level Pydantic fields (optional)
    
        Returns:
            Confirmation message with editor URL
        """
        arguments: dict[str, Any] = {"chart_id": chart_id}
        if data is not None:
            arguments["data"] = data
        if chart_config is not None:
            arguments["chart_config"] = chart_config
    
        try:
            result = await update_chart_handler(cast(UpdateChartArgs, arguments))
            return result[0].text
        except Exception as e:
            return f"Error updating chart with ID '{chart_id}': {str(e)}"
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 of behavioral disclosure. It does an excellent job describing limitations (chart type immutability), what can and cannot be updated, validation behavior (Pydantic validation), and merge behavior (config merged with existing). It also mentions the return format (confirmation message with editor URL). The only minor gap is no mention of authentication requirements or rate limits.

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

Conciseness3/5

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

The description is comprehensive but lengthy (over 400 words). While most content is valuable, some sections like the styling examples and documentation link could be more concise. The information is well-structured with clear sections, but it's not optimally front-loaded for quick scanning.

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

Completeness5/5

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

Given the tool's complexity (mutation operation with 3 parameters, no annotations, but with output schema), the description is remarkably complete. It covers purpose, limitations, usage guidelines, parameter semantics, behavioral details, and references to other tools. The output schema handles return values, so the description appropriately focuses on everything else the agent needs to know.

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 must compensate for all three parameters. It clearly explains chart_id ('ID of the chart to update'), data ('New chart data (optional). Same formats as create_chart'), and chart_config ('Updated chart configuration using high-level Pydantic fields (optional)'). It provides formatting guidance and examples for chart_config, though more detail on data formats would be helpful.

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's purpose: 'Update an existing Datawrapper chart's data or configuration using Pydantic models.' It specifies the verb ('update'), resource ('existing Datawrapper chart'), and scope ('data or configuration'), and distinguishes it from sibling tools like create_chart by emphasizing it's for existing charts only.

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

Usage Guidelines5/5

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

The description provides explicit usage guidelines: it states when to use this tool (for updating existing charts) and when not to use it (cannot change chart type, must use create_chart instead). It also mentions get_chart_schema as a reference for available fields, giving clear alternatives and prerequisites.

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/hqu/datawrapper-mcp'

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