Skip to main content
Glama
markomitranic

Data Visualization MCP Server

visualize_data

Create data visualizations using Vega-Lite specifications to transform complex datasets into clear graphical representations for better analysis and understanding.

Instructions

A tool which allows you to produce a data visualization using the Vega-Lite grammar. When to use this tool:

  • At times, it will be advantageous to provide the user with a visual representation of some data, rather than just a textual representation.

  • This tool is particularly useful when the data is complex or has many dimensions, making it difficult to understand in a tabular format. It is not useful for singular data points. How to use this tool:

  • Prior to visualization, data must be saved to a named table using the save_data tool.

  • After saving the data, use this tool to visualize the data by providing the name of the table with the saved data and a Vega-Lite specification.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
data_nameYesThe name of the data table to visualize
vegalite_specificationYesThe vegalite v5 specification for the visualization. Do not include the data field, as this will be added automatically.

Implementation Reference

  • The core handler logic for the 'visualize_data' tool. It retrieves saved data by name, injects it into the provided Vega-Lite specification, and returns either a base64-encoded PNG image or a text artifact with the spec.
    elif name == "visualize_data":
        data_name = arguments["data_name"]
        vegalite_specification = eval(arguments["vegalite_specification"])
        data = saved_data[data_name]
        vegalite_specification["data"] = {"values": data}
    
        if output_type == "png":
            png = vlc.vegalite_to_png(vl_spec=vegalite_specification, scale=2)
            png = base64.b64encode(png).decode("utf-8")
            return [types.ImageContent(type="image", data=png, mimeType="image/png")]
        else:
            return [
                types.TextContent(
                    type="text",
                    text=f"Visualized data from table {data_name} with provided spec.",
                    artifact=vegalite_specification,
                )
            ]
  • Registration of the 'visualize_data' tool in the list_tools() handler, defining its name, description, and input schema.
    types.Tool(
        name="visualize_data",
        description=VISUALIZE_DATA_TOOL_DESCRIPTION,
        inputSchema={
            "type": "object",
            "properties": {
                "data_name": {
                    "type": "string",
                    "description": "The name of the data table to visualize",
                },
                "vegalite_specification": {
                    "type": "string",
                    "description": "The vegalite v5 specification for the visualization. Do not include the data field, as this will be added automatically.",
                },
            },
            "required": ["data_name", "vegalite_specification"],
        },
    ),
  • Input schema for the 'visualize_data' tool, specifying required parameters: data_name (string) and vegalite_specification (string).
    inputSchema={
        "type": "object",
        "properties": {
            "data_name": {
                "type": "string",
                "description": "The name of the data table to visualize",
            },
            "vegalite_specification": {
                "type": "string",
                "description": "The vegalite v5 specification for the visualization. Do not include the data field, as this will be added automatically.",
            },
        },
        "required": ["data_name", "vegalite_specification"],
    },
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/markomitranic/mcp-vegalite-server'

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