Vega-Lite Data Visualization MCP server

Create data visualizations using Vega-Lite syntax by saving data tables and generating charts.
Back to servers
Provider
Isaac Wasserman
Release date
Dec 12, 2024
Language
Python
Stats
54 stars

This MCP server allows you to visualize data using Vega-Lite syntax, providing your LLM with tools to save data tables and generate visualizations through the Model Context Protocol interface.

Installation

To use the data visualization MCP server, follow these steps:

  1. Clone or download the repository to your local machine
  2. Navigate to the server directory
  3. Install the server using your package manager of choice

Configuration for Claude Desktop

To integrate the server with Claude Desktop, you need to add it to your configuration file:

  1. Open your claude_desktop_config.json file
  2. Add the server configuration to the mcpServers section:
{
  "mcpServers": {
    "datavis": {
        "command": "uv",
        "args": [
            "--directory",
            "/absolute/path/to/mcp-datavis-server",
            "run",
            "mcp_server_datavis",
            "--output_type",
            "png" # or "text"
        ]
    }
  }
}

Configuration Options

  • Replace /absolute/path/to/mcp-datavis-server with the actual path to the server directory on your system
  • For --output_type, you can choose:
    • png: Returns visualizations as base64 encoded PNG images
    • text: Returns the complete Vega-Lite specification with data

Using the Server

The MCP server provides two main tools for data visualization:

Saving Data

Use the save_data tool to store data tables for visualization:

  • Input Parameters:
    • name (string): A unique identifier for your data table
    • data (array): An array of objects representing your data table

For example:

# Save a sample dataset
save_data(
    name="sales_data",
    data=[
        {"month": "Jan", "sales": 120},
        {"month": "Feb", "sales": 150},
        {"month": "Mar", "sales": 200}
    ]
)

Creating Visualizations

After saving your data, use the visualize_data tool to create visualizations:

  • Input Parameters:
    • data_name (string): The name of the previously saved data table
    • vegalite_specification (string): A JSON string with the Vega-Lite specification

For example:

# Create a bar chart visualization
visualize_data(
    data_name="sales_data",
    vegalite_specification='''
    {
      "mark": "bar",
      "encoding": {
        "x": {"field": "month", "type": "nominal"},
        "y": {"field": "sales", "type": "quantitative"}
      }
    }
    '''
)

Output Types

The visualization output depends on your configuration:

  • With --output_type set to text: You'll receive a success message containing the complete Vega-Lite specification with data
  • With --output_type set to png: You'll receive a base64 encoded PNG image of the visualization

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later