A powerful Model Context Protocol (MCP) server for creating interactive data visualizations using matplotlib. This server provides comprehensive visualization tools including relationship graphs, scatter plots, 3D visualizations, and more.
- π Relationship Graphs: Create network diagrams to visualize connections between entities
- π Scatter Plots: Basic and classification scatter plots with customizable styling
- π 3D Visualizations: Support for 3D scatter plots, surface plots, and wireframes
- π Statistical Charts: Histograms, line plots, and heatmaps
- πΎ Auto-save: Automatically saves high-resolution images to temporary directory
- πΌοΈ Live Display: Shows plots in interactive matplotlib windows
- π¨ Customizable: Extensive styling options for colors, labels, and layouts
$ python3 -m venv .venv --upgrade-deps
$ source .venv/bin/activate
$ pip install "mcp[cli]" httpx
$ pip install matplotlib numpy pandas networkx
git clone https://github.com/xlisp/visualization-mcp-server.git
cd visualization-mcp-server
python visualization_server.py
"visualization": {
"command": "/Users/clojure/Desktop/visualization-mcp-server/.venv/bin/python",
"args": [
"/Users/clojure/Desktop/visualization-mcp-server/visualization_server.py"
]
}
The server provides several visualization tools that can be called via MCP protocol:
Create network diagrams to show relationships between entities:
# Example: Show relationships between A, B, C, D
nodes = ["Alice", "Bob", "Charlie", "Diana"]
edges = [["Alice", "Bob"], ["Bob", "Charlie"], ["Alice", "Charlie"], ["Charlie", "Diana"]]
# Call: create_relationship_graph(nodes, edges, "Social Network")
Parameters:
nodes
: List of node namesedges
: List of connections (pairs of node names)title
: Graph title (optional)node_size
: Size of nodes (default: 1000)font_size
: Label font size (default: 12)
Create basic scatter plots with optional labels and colors:
# Example: Basic scatter plot
x_data = [1, 2, 3, 4, 5]
y_data = [2, 5, 3, 8, 7]
labels = ["Point A", "Point B", "Point C", "Point D", "Point E"]
# Call: create_scatter_plot(x_data, y_data, labels, title="My Scatter Plot")
Parameters:
x_data
: X-axis valuesy_data
: Y-axis valueslabels
: Point labels (optional)colors
: Point colors (optional)title
,x_label
,y_label
: Chart labelssize
: Point size (default: 50)
Visualize data points grouped by categories:
# Example: Classification visualization
x_data = [1, 2, 3, 4, 5, 6]
y_data = [2, 3, 1, 5, 4, 6]
categories = ["Type A", "Type A", "Type B", "Type B", "Type C", "Type C"]
# Call: create_classification_plot(x_data, y_data, categories)
Parameters:
x_data
: X-axis valuesy_data
: Y-axis valuescategories
: Category labels for each pointtitle
,x_label
,y_label
: Chart labels
Create 3D plots with multiple visualization types:
# Example: 3D scatter plot
x_data = [1, 2, 3, 4, 5]
y_data = [2, 4, 1, 5, 3]
z_data = [3, 1, 4, 2, 5]
# Call: create_3d_plot(x_data, y_data, z_data, plot_type="scatter")
Parameters:
x_data
,y_data
,z_data
: 3D coordinatesplot_type
: "scatter", "surface", or "wireframe"title
,x_label
,y_label
,z_label
: Chart labels
# create_histogram(data, bins=30, title="Distribution")
# create_line_plot(x_data, y_data, line_style="-", color="blue")
# create_heatmap(data_matrix, x_labels, y_labels, colormap="viridis")
Each visualization function:
- Displays the plot in an interactive matplotlib window
- Saves a high-resolution PNG file to the system temporary directory
- Returns the file path where the image was saved
Example output:
"Graph saved to: /tmp/relationship_graph_20250802_143022.png and displayed"
- Images are saved with timestamps to avoid conflicts
- Files are stored in the system temporary directory:
- Windows:
C:\Users\username\AppData\Local\Temp\
- macOS/Linux:
/tmp/
- Windows:
- High resolution (300 DPI) PNG format
This server follows the Model Context Protocol standard and can be integrated with MCP-compatible clients. The server runs on stdio transport by default.
if __name__ == "__main__":
mcp.run(transport='stdio')
# Visualize social connections
nodes = ["Alice", "Bob", "Charlie", "Diana", "Eve"]
relationships = [
["Alice", "Bob"],
["Bob", "Charlie"],
["Charlie", "Diana"],
["Alice", "Eve"],
["Eve", "Diana"]
]
# Creates a network graph showing social connections
# Visualize machine learning results
features_x = [1.2, 2.3, 1.8, 3.1, 2.9, 1.5]
features_y = [2.1, 3.2, 1.9, 4.1, 3.8, 2.2]
predictions = ["Class A", "Class B", "Class A", "Class B", "Class B", "Class A"]
# Creates a classification scatter plot
# 3D scientific visualization
x_coords = [0, 1, 2, 3, 4]
y_coords = [0, 1, 4, 9, 16]
z_coords = [0, 1, 8, 27, 64]
# Creates a 3D surface or scatter plot
The server includes comprehensive error handling:
- Invalid data format detection
- Missing parameter validation
- Matplotlib rendering error recovery
- File system permission checks
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
matplotlib
: Core plotting librarynetworkx
: Graph/network visualizationnumpy
: Numerical computationspandas
: Data manipulationmcp
: MCP server framework
- Interactive plot widgets
- Animation support
- Export to multiple formats (SVG, PDF)
- Custom color schemes
- Statistical analysis integration
- Real-time data streaming plots
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed description
- Include sample data and error messages
Made with β€οΈ for the MCP ecosystem