Plotnine MCP Server
Create publication-quality statistical visualizations through natural language using Python's plotnine implementation of ggplot2's grammar of graphics.
Visualization Capabilities:
Multi-layer plots - Combine multiple geometries (scatter + trend lines, boxplots + jitter, etc.)
20+ geometry types - Points, lines, bars, histograms, boxplots, violins, density plots, heatmaps, and more
Grammar of graphics composition - Build plots using aesthetics, geometries, scales, themes, facets, coordinates, and statistical transformations
Multiple output formats - PNG, PDF, SVG with configurable dimensions and DPI
Data Handling:
Multiple data sources - Load from CSV, JSON, Parquet, Excel files, URLs, or inline JSON
12 data transformations - Filter, group_summarize, sort, select, rename, mutate, drop_na, fill_na, sample, unique, rolling, and pivot operations
Data preview - Inspect data structure, column types, statistics, and missing values before plotting
Smart Features:
9 pre-configured templates - Time series, scatter with trend, distribution comparison, and other common patterns
AI-powered recommendations - Analyzes data to suggest appropriate plot types
Smart error handling - Fuzzy matching suggests corrections for typos in column names, geometries, and themes
Batch processing - Create multiple plots in one operation
Configuration management - Export/import plot configurations as JSON files for reuse
Customization:
7 built-in themes - Gray, bw, minimal, classic, dark, light, void with extensive customization options
21 color palettes - Across 6 categories including colorblind-safe, scientific, categorical, corporate, sequential, and diverging
Flexible styling - Customize scales, labels, titles, subtitles, captions, facets, and coordinate systems
Enables creation of publication-quality statistical graphics using plotnine, Python's implementation of the grammar of graphics, with support for 20+ geometry types, multi-layer plots, theming, faceting, and statistical transformations.
Implements R's ggplot2 grammar of graphics paradigm in Python through plotnine, allowing composition of visualizations using aesthetics, geometries, scales, themes, facets, and coordinate systems.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Plotnine MCP Server create a scatter plot of sales vs advertising spend with a trend line"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Plotnine MCP Server
A Model Context Protocol (MCP) server that brings ggplot2's grammar of graphics to Python through plotnine, enabling AI-powered data visualization via natural language.
Create publication-quality statistical graphics through chat using plotnine's Python implementation of R's beloved ggplot2. This modular MCP server allows Claude and other AI assistants to generate highly customizable visualizations by composing layers through the grammar of graphics paradigm.
Features
Core Visualization
π¨ Multi-Layer Plots: Combine multiple geometries in a single plot (scatter + trend lines, boxplots + jitter, etc.)
Grammar of Graphics: Compose plots using aesthetics, geometries, scales, themes, facets, and coordinates
20+ Geometry Types: Points, lines, bars, histograms, boxplots, violins, and more
Multiple Data Sources: Load data from files (CSV, JSON, Parquet, Excel), URLs, or inline JSON
Multiple Output Formats: PNG, PDF, SVG with configurable dimensions and DPI
Smart Features (NEW!)
π 9 Plot Templates: Pre-configured templates for common patterns (time series, scatter with trend, distribution comparison, etc.)
π€ AI Template Suggestions: Analyzes your data and recommends appropriate plot types
π¨ 21 Color Palettes: Colorblind-safe, scientific, categorical, corporate, sequential, and diverging palettes
π Data Preview: Inspect data before plotting with comprehensive summaries
π― Smart Error Messages: Fuzzy matching suggests corrections for typos in column names, geom types, and themes
πΎ Config Export/Import: Save and reuse plot configurations as JSON files
Data Manipulation (NEW!)
π 12 Data Transformations: filter, group_summarize, sort, select, rename, mutate, drop_na, fill_na, sample, unique, rolling, pivot
β‘ Batch Processing: Create multiple plots in one operation
π Chained Transforms: Apply multiple transformations in sequence
Theming & Customization
Flexible Theming: Built-in themes with extensive customization options
Statistical Transformations: Add smoothing, binning, density estimation, and summaries
Faceting: Split plots by categorical variables using wrap or grid layouts
Related MCP server: ML Research MCP
Installation
1. Clone or download this repository
cd plotnine-mcp2. Install dependencies
Using pip:
pip install -e .For full functionality (parquet and Excel support):
pip install -e ".[full]"3. Configure Your MCP Client
Finding Your Installation Path
First, find where the plotnine-mcp command was installed:
which plotnine-mcpThis will show something like /path/to/python/bin/plotnine-mcp. Use this full path in the configurations below.
Claude Desktop
Add the server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Recommended (using entry point):
{
"mcpServers": {
"plotnine": {
"command": "/path/to/your/python/bin/plotnine-mcp",
"args": []
}
}
}Alternative (using python -m):
{
"mcpServers": {
"plotnine": {
"command": "python",
"args": ["-m", "plotnine_mcp.server"]
}
}
}If you installed in a virtual environment, replace with the full path:
{
"mcpServers": {
"plotnine": {
"command": "/path/to/venv/bin/plotnine-mcp",
"args": []
}
}
}Cursor
Recommended approach: Configure via .cursor/mcp.json in your project:
{
"mcpServers": {
"plotnine": {
"command": "/path/to/your/python/bin/plotnine-mcp",
"args": []
}
}
}Alternative: Add to Cursor global settings by opening the command palette (Cmd/Ctrl+Shift+P) and searching for "Preferences: Open User Settings (JSON)":
{
"mcp.servers": {
"plotnine": {
"command": "/path/to/your/python/bin/plotnine-mcp",
"args": []
}
}
}Using python -m alternative:
{
"mcpServers": {
"plotnine": {
"command": "python",
"args": ["-m", "plotnine_mcp.server"]
}
}
}VSCode (with Cline/Roo-Cline)
Add to your VSCode MCP settings file:
macOS/Linux: ~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
Windows: %APPDATA%\Code\User\globalStorage\rooveterinaryinc.roo-cline\settings\cline_mcp_settings.json
{
"mcpServers": {
"plotnine": {
"command": "/path/to/your/python/bin/plotnine-mcp",
"args": []
}
}
}For other MCP clients in VSCode, consult their specific documentation for MCP server configuration.
4. Restart Your Application
Restart Claude Desktop, Cursor, or VSCode for the changes to take effect. The plotnine MCP server should now be available!
Usage
Basic Example
Create a scatter plot from data.csv with x=age and y=heightAdvanced Example
Create a line plot from sales_data.csv showing:
- x: date, y: revenue, color by region
- Use a minimal theme with figure size 12x6
- Add a smooth trend line
- Facet by product category
- Label the plot "Q4 Sales Performance"
- Save as PDFAvailable Tools (11 Total)
Core Tools
create_plot
Create a plotnine visualization with full customization.
Required Parameters:
data_source: Data source configurationaes: Aesthetic mappings (column names)geomorgeoms: Geometry specification(s)
Optional Parameters:
scales: Array of scale configurationstheme: Theme configurationfacets: Faceting configurationlabels: Plot labels (title, x, y, caption, subtitle)coords: Coordinate system configurationstats: Statistical transformationstransforms: Data transformations (NEW!)output: Output configuration (format, size, DPI, directory)
list_geom_types
List all 20+ available geometry types with descriptions.
Data Tools (NEW!)
preview_data
Preview and inspect data before creating plots. Returns dataset shape, column types, first rows, statistics, and missing values.
Parameters:
data_source: Data source configurationrows: Number of rows to preview (default: 5)
Template Tools (NEW!)
list_plot_templates
List all 9 available plot templates with descriptions:
time_series
scatter_with_trend
distribution_comparison
category_breakdown
correlation_heatmap
boxplot_comparison
multi_line
histogram_with_density
before_after
create_plot_from_template
Create a plot using a predefined template. Just provide data and aesthetics; the template handles the rest.
Parameters:
template_name: Name of the templatedata_source: Data source configurationaes: Aesthetic mappingslabels: Optional labelsoutput: Optional output configoverrides: Optional overrides for template settings
suggest_plot_templates
Analyze your data and get AI-powered plot recommendations based on column types and optional goal.
Parameters:
data_source: Data source to analyzegoal: Optional goal (e.g., "compare distributions", "show trend")
Style Tools (NEW!)
list_themes
List all available themes for plot styling with descriptions and customization options.
list_color_palettes
List 21 color palettes across 6 categories:
Colorblind-safe (3 palettes)
Scientific (4 palettes)
Categorical (4 palettes)
Corporate (3 palettes)
Sequential (4 palettes)
Diverging (3 palettes)
Parameters:
category: Optional category filter
Configuration Tools
export_plot_config
Export plot configuration to JSON for reuse and sharing.
Parameters:
config: The plot configuration to exportfilename: Output filenamedirectory: Output directory (default: './plot_configs')
import_plot_config
Import and use a saved plot configuration with optional overrides.
Parameters:
config_path: Path to saved configurationoverrides: Optional parameter overrides
Batch Tools (NEW!)
batch_create_plots
Create multiple plots in one operation. Perfect for generating plots for all columns, pairwise comparisons, or different visualizations of the same data.
Parameters:
plots: Array of plot configurations
Geometry Types
point: Scatter plot points
line: Line plot connecting points
bar: Bar chart (counts by default)
col: Column chart (identity stat)
histogram: Histogram of continuous data
boxplot: Box and whisker plot
violin: Violin plot for distributions
area: Filled area under line
density: Kernel density plot
smooth: Smoothed conditional means
jitter: Jittered points (reduces overplotting)
tile: Heatmap/tile plot
text: Text annotations
errorbar: Error bars
hline/vline/abline: Reference lines
path: Path connecting points in order
polygon: Filled polygon
ribbon: Ribbon for intervals
Examples
Simple Scatter Plot
{
"data_source": {
"type": "file",
"path": "./data/iris.csv"
},
"aes": {
"x": "sepal_length",
"y": "sepal_width",
"color": "species"
},
"geom": {
"type": "point",
"params": {"size": 3, "alpha": 0.7}
}
}Line Plot with Theme
{
"data_source": {
"type": "url",
"path": "https://example.com/timeseries.csv"
},
"aes": {
"x": "date",
"y": "value",
"color": "category"
},
"geom": {
"type": "line",
"params": {"size": 1.5}
},
"scales": [
{
"aesthetic": "x",
"type": "datetime",
"params": {"date_breaks": "1 month"}
}
],
"theme": {
"base": "minimal",
"customizations": {
"figure_size": [12, 6],
"legend_position": "bottom"
}
},
"labels": {
"title": "Time Series Analysis",
"x": "Date",
"y": "Value"
}
}Faceted Boxplot
{
"data_source": {
"type": "inline",
"data": [
{"group": "A", "category": "X", "value": 10},
{"group": "A", "category": "Y", "value": 15},
{"group": "B", "category": "X", "value": 12}
]
},
"aes": {
"x": "group",
"y": "value",
"fill": "group"
},
"geom": {
"type": "boxplot"
},
"facets": {
"type": "wrap",
"facets": "~ category"
},
"theme": {
"base": "bw"
}
}Multi-Layer Plot: Scatter + Smooth Trend
NEW! Layer multiple geometries to create complex visualizations:
{
"data_source": {
"type": "file",
"path": "./data/measurements.csv"
},
"aes": {
"x": "time",
"y": "value",
"color": "sensor"
},
"geoms": [
{
"type": "point",
"params": {"size": 2, "alpha": 0.6}
},
{
"type": "smooth",
"params": {"method": "lm", "se": false}
}
],
"theme": {
"base": "minimal",
"customizations": {"figure_size": [12, 6]}
},
"labels": {
"title": "Sensor Readings with Trend Lines",
"x": "Time",
"y": "Measurement"
}
}Boxplot with Jittered Points
Show both distribution summary and individual data points:
{
"data_source": {
"type": "file",
"path": "./data/experiment.csv"
},
"aes": {
"x": "treatment",
"y": "response",
"fill": "treatment"
},
"geoms": [
{
"type": "boxplot",
"params": {"alpha": 0.7}
},
{
"type": "jitter",
"params": {"width": 0.2, "alpha": 0.5, "size": 1}
}
],
"theme": {
"base": "bw"
},
"labels": {
"title": "Treatment Effects with Individual Observations"
}
}Chat Examples
You can create plots through natural language:
"Create a histogram of the 'age' column from users.csv"
"Make a scatter plot with smooth trend line showing price vs size, colored by category"
"Plot a line chart from sales.csv with date on x-axis and revenue on y-axis, faceted by region, using a dark theme"
"Create a violin plot comparing distributions of test scores across different schools"
"Make a boxplot with individual points overlaid showing temperature by season"
"Create a scatter plot with a linear trend line for each category, showing the relationship between hours studied and test scores"
Using New Tools
"Preview the data from sales.csv before plotting"
"What themes are available?"
"Show me all available plot templates"
"Suggest appropriate plot types for my data"
"Create a time series plot using the template"
"List color palettes in the scientific category"
"Export this plot configuration so I can reuse it later"
"Load the plot config from my_config.json and use it with a different dataset"
"Create a plot from the saved configuration but change the theme to minimal"
"Create plots for each category in my dataset" (batch processing)
"Filter the data to show only active users, then create a histogram" (data transformations)
New Examples
Using Templates
Create a scatter plot with trend line using a template:
"Use the scatter_with_trend template to plot height vs weight from my data"This automatically creates a plot with:
Scatter points (with transparency)
Linear regression line
Confidence interval
Minimal theme
Using Color Palettes
"Create a bar chart colored using the colorblind-safe Okabe-Ito palette"Data Transformations
"Filter sales data to show only Q4, group by region, sum the revenue, and create a bar chart"This applies transformations before plotting:
Filter:
"quarter == 'Q4'"Group & summarize: by region, sum revenue
Plot: bar chart of results
Batch Processing
"Create histogram plots for all numeric columns in my dataset"Configuration Options
Themes
Available base themes:
gray(default)bw(black and white)minimalclassicdarklightvoid
Scale Types
Positional: continuous, discrete, log10, sqrt, datetime
Color/Fill: gradient, discrete, brewer
Coordinate Systems
cartesian(default)flip(swap x and y)fixed(fixed aspect ratio)trans(transformed coordinates)
Output
By default, plots are saved to ./output directory as PNG files with 300 DPI. You can customize:
format: png, pdf, svg
filename: Custom filename (auto-generated by default)
width/height: Dimensions in inches
dpi: Resolution for raster formats
directory: Output directory path
Troubleshooting
"Module not found" errors
Ensure you've installed the package:
pip install -e .Parquet/Excel support
Install optional dependencies:
pip install -e ".[full]""Cannot find data file"
Use absolute paths or paths relative to where Claude Desktop is running.
Plot not rendering
Check that:
Column names in
aesmatch your dataData types are appropriate for the geometry
Required aesthetics are provided (e.g.,
xandyfor most geoms)
Development
Running tests
pytestCode formatting
black src/
ruff check src/License
MIT
Contributing
Contributions welcome! Please open an issue or submit a pull request.
Resources
Available Tools
11 toolsbatch_create_plotsB
Create multiple plots in one batch operation.
Useful for:
Creating plots for all numeric columns in a dataset
Generating pairwise scatter plots
Creating plots for each category separately
Comparing different plot types
Each plot configuration is processed independently, and all plots are created in sequence.
Inputs: plots (required).
create_plotA
Create a plotnine visualization from data.
This tool allows you to create highly customizable plots using the grammar of graphics. You can specify data sources (file, URL, or inline), aesthetic mappings, geometries, scales, themes, facets, labels, and coordinate systems.
NEW: Multi-layer plots! Use 'geoms' array to combine multiple geometries in one plot.
Example usage:
Simple scatter plot: provide data_source, aes (x, y), and geom (type: "point")
Multi-layer plot: use geoms array with multiple geometries (e.g., point + smooth)
Line plot with custom theme: add theme config with base and customizations
Faceted plot: include facet config to split by categorical variables
Multiple scales: provide list of scale configs for x, y, color, etc.
All parameters support extensive customization through nested objects.
Inputs: data_source (required), aes (required), geom, geoms, +8 more.
create_plot_from_templateA
Create a plot using a predefined template.
Templates provide optimized configurations for common plot types:
time_series: Line plot with date formatting
scatter_with_trend: Points with regression line
distribution_comparison: Violin + jitter for group comparison
category_breakdown: Bar chart with categories
correlation_heatmap: Tile plot for correlations
boxplot_comparison: Boxplot with points overlay
multi_line: Multiple lines for trend comparison
histogram_with_density: Histogram with density curve
before_after: Side-by-side comparison
You only need to provide data and aesthetics; the template handles the rest. You can override any template settings if needed.
Inputs: template_name (required), data_source (required), aes (required), labels, +2 more.
export_plot_configA
Export plot configuration to a JSON file for reuse.
This saves the exact configuration used to create a plot, allowing you to:
Recreate the same plot later
Share configurations with others
Version control your visualizations
Use as templates for similar plots
Inputs: config (required), filename (required), directory.
import_plot_configA
Import and use a saved plot configuration.
Load a previously exported plot configuration and create a plot from it. You can optionally override specific parameters (like data_source) while keeping the rest of the configuration intact.
Inputs: config_path (required), overrides.
list_color_palettesB
List available color palettes with preview colors.
Palettes are organized by category:
colorblind_safe: Accessible palettes (Okabe-Ito, Tol)
scientific: Perceptually uniform (viridis, plasma, inferno, magma)
categorical: Distinct colors for categories
corporate: Professional business colors
sequential: Gradual scales for ordered data
diverging: Two-tone scales for data with midpoints
Use these palettes by adding a scale configuration to your plot.
Inputs: category.
list_geom_typesB
List all available geometry types that can be used in plots
Inputs: no named parameters.
list_plot_templatesB
List all available plot templates with descriptions. Templates provide preset configurations for common visualization patterns like time series, scatter with trend, distribution comparison, etc.
Inputs: no named parameters.
list_themesB
List all available themes for plot styling
Inputs: no named parameters.
preview_dataA
Preview and inspect data before creating plots.
Returns a comprehensive summary including:
Dataset shape (rows and columns)
Column names and data types
First few rows of data
Basic statistics for numeric columns
Missing value counts
This helps verify data loaded correctly and understand its structure.
Inputs: data_source (required), rows.
suggest_plot_templatesB
Analyze data and suggest appropriate plot templates.
Examines data characteristics (number of numeric/categorical columns, presence of time data) and optionally a user goal to recommend suitable templates.
Inputs: data_source (required), goal.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 11 tools
Each tool has a clearly distinct purpose with no ambiguity: batch_create_plots handles multiple plots, create_plot builds custom visualizations, create_plot_from_template uses predefined templates, export/import_plot_config manage configurations, list_color_palettes/geom_types/templates/themes provide discovery, preview_data inspects data, and suggest_plot_templates offers recommendations. The tools cover different aspects of the plotting workflow without overlap.
All tool names follow a consistent snake_case verb_noun pattern (e.g., create_plot, list_color_palettes, preview_data). The naming is predictable and readable throughout, with verbs like create, list, export, import, preview, and suggest clearly indicating actions.
With 11 tools, the server is well-scoped for a plotting library, covering creation (custom, batch, template-based), configuration management, data inspection, and discovery of palettes, geometries, templates, and themes. Each tool earns its place by addressing a specific need in the visualization workflow.
The tool surface is complete for the plotnine domain, offering full lifecycle coverage: data inspection (preview_data), creation (create_plot, batch_create_plots, create_plot_from_template), customization (list tools for discovery), configuration management (export/import_plot_config), and intelligent assistance (suggest_plot_templates). There are no obvious gaps that would hinder agent workflows.
Maintenance
Related MCP Connectors
Clean messy tabular data and render publication-ready PNG charts from your AI assistant.
Interactive data visualization and executive PDF dashboards for ChatGPT, Claude, and Cursor.
Renders interactive Chart.js charts and dashboards inline in AI conversations.
Create, inspect, manage, and render charts and data visualizations as SVG/PNG or interactive embeds.
Related MCP Servers
- -licenseNot gradedqualityNot gradedmaintenanceEnables generation of 25+ types of charts and data visualizations using AntV, including bar charts, line charts, maps, mind maps, and specialized diagrams like fishbone and sankey charts. Supports both statistical charts and geographic visualizations for comprehensive data analysis and presentation.340 npm-
- AlicenseAqualityDmaintenanceProvides machine learning researchers with tools for creating publication-quality scientific visualizations, statistical plots, and 2D data representations. It streamlines the research workflow by enabling AI assistants to generate complex figures from CSV, JSON, or direct data inputs.9MIT
- FlicenseNot gradedqualityDmaintenanceEnables creating Plotly charts from natural language in Cursor, supporting a wide variety of trace types with full customization.9-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to generate publication-quality bioinformatics visualizations (volcano plots, PCA, heatmaps, etc.) directly from raw biological data.MIT