Content
# PlotBase (Figure Memory) MCP Server
**MCP Service for Scientific Figure Archives and AI Agent Context Management**
  
---
## Call for Examples
> **The PlotBase figure archive library is still being continuously improved and expanded!**
> If you have explored elegant R/Python plotting code, top journal color schemes, or specific chart Agent fine-tuning Prompts in your daily scientific research or engineering, **you are highly encouraged to submit issues or PRs with your examples**! We will add your high-quality templates to the PlotBase standard archive library to help more researchers eliminate plotting pain points.
---
## Project Introduction
`PlotBase-FigureMemory` is a **Model Context Protocol (MCP) service** specifically designed for AI Agents, large language models, and researchers.
Based on the architecture design of the PlotBase figure gallery indexing system, this MCP service extracts most scientific figures (such as **ridge plots, heatmaps, line plots, density plots, volcano plots, cloud rain plots, Manhattan plots**, etc.) into **complete figure archives** with 5 key dimensions:
```
┌────────────────────────────────────────────────────────────────────────┐
│ Figure Archive │
├────────────────────────────────────────────────────────────────────────┤
│ 1. Metadata : Title, category, chart type, R/Python dependencies │
│ 2. Executable Code: Complete and tunable R(ggplot2)/Python code │
│ 3. Sample Data: CSV/JSON data structure and example field mapping │
│ 4. Visual Rules: Top journal color schemes, layout ratios, font sizes, and theme rules │
│ 5. Agent Context: AI Agent exclusive modification guidance and data mapping rules │
└────────────────────────────────────────────────────────────────────────┘
```
---
## Core Features and MCP Tools
This MCP service provides a complete JSON-RPC interface for LLM clients such as Claude, Cursor, Windsurf, and Antigravity:
| Tool Name | Parameters | Description |
| --- | --- | --- |
| `list_categories()` | None | List all category indexes and figure quantity statistics |
| `search_figures(...)` | `query`, `category`, `chart_type`, `framework`, `tag` | Fuzzy search in the archive library by category, chart type, programming language, or keyword |
| `get_figure_archive(...)` | `figure_id` | Get the **complete figure archive** (source code, sample data, visual rules, and Agent context) |
| `create_figure_archive(...)` | `title`, `category`, `chart_type`, `framework`, `code`, `description`, ... | Save/import new figure archives to the PlotBase memory library |
| `recommend_figure(...)` | `data_description`, `goal` | **Intelligent recommendation engine**: Recommend the best figure scheme based on user input data features and research goals |
| `render_figure_template(...)` | `figure_id`, `column_mapping`, `color_palette`, `title_override` | **Code generation and adaptation**: Replace template code with user data column names and color configurations, and output executable code directly |
---
## Resources & Prompts
### Resources
- `plotbase://categories`: Read the entire library's figure classification hierarchy and real-time statistics.
- `plotbase://figures/{figure_id}`: Read the specified figure's archive resources.
### Prompts
- `generate_scientific_plot`: Guide the Agent through the complete process from demand analysis to archive extraction, code adaptation, and visual optimization.
- `adapt_figure_for_dataset`: Guide the Agent to accurately adapt the specified figure archive to the user's dataset structure.
---
## Installation and Configuration Guide
### 1. Environment Preparation
This service depends on Python 3.10+ and the official `mcp` SDK:
```bash
pip install "mcp[cli]"
```
### 2. Deployment and Testing
You can run the test suite directly in the terminal:
```bash
python3 /tmp/plotbase_mcp/test_server.py
```
### 3. Configuration to Claude Desktop
Edit the Claude Desktop configuration file:
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
Add the following MCP configuration:
```json
{
"mcpServers": {
"plotbase-figurememory": {
"command": "python3",
"args": [
"/tmp/plotbase_mcp/server.py"
]
}
}
}
```
### 4. Configuration to Cursor / Windsurf / Claude Code
Add the following configuration to the MCP settings in the editor that supports MCP:
```json
{
"mcpServers": {
"plotbase": {
"command": "python3",
"args": ["/tmp/plotbase_mcp/server.py"]
}
}
}
```
---
## Agent Actual Call Example
### Scenario 1: Intelligent Recommendation and Archive Extraction
> **User asks**: "I have a single-cell RNA-seq developmental trajectory pseudo-time series data and want to draw a figure showing gene expression changes. What are the recommendations?"
1. Agent calls `recommend_figure(data_description="single-cell RNA-seq developmental trajectory pseudo-time series", goal="show gene expression changes")`
2. MCP returns the recommended item: `fig_monocle2_heatmap_02` (ggplot modified monocle2 heatmap)
3. Agent calls `get_figure_archive("fig_monocle2_heatmap_02")` to obtain the complete archive, including `pheatmap` drawing code, Z-score standardization rules, and configuration instructions for Pseudotime gradient bars.
### Scenario 2: One-Click Column Mapping and Code Customization
> **User asks**: "Help me draw a figure using PlotBase's ridge plot template. My data column names are `CellType` and `Expression`, and the color should be `magma`."
1. Agent calls `render_figure_template("fig_ridge_ggplot2_01", column_mapping={"value": "Expression", "group": "CellType"}, color_palette="magma")`
2. MCP directly outputs the reconstructed and adjusted complete R source code and delivers it to the user for execution.
---
## Directory Structure
```
/tmp/plotbase_mcp/
├── server.py # FastMCP service core implementation (Tools, Resources, Prompts)
├── database.json # Figure archive database (including example figures)
├── test_server.py # Automated unit test suite
└── README.md # MCP service usage documentation
```
---
## Open Source License
[MIT License](LICENSE)