MCP Server¶
dartwork-mpl includes a built-in Model Context Protocol (MCP) server that lets AI coding assistants — such as Claude Code, Cursor, Windsurf, and any MCP-compatible client — access library documentation, style guides, and helper tools inside the chat context.
What can MCP do?¶
When the dartwork-mpl MCP server is connected, your AI assistant gains access to resources, tools, and prompts without you having to copy-paste documentation.
Resources¶
Read-only data that the AI assistant can retrieve on demand.
URI |
Description |
|---|---|
|
Complete usage guide — styles, colors, layout, fonts, save/export, workflow |
|
Deep-dive into |
|
Full list of registered colors with hex codes ( |
|
Sorted list of all fonts available to matplotlib |
|
Available mplstyle preset names |
|
Content of a specific mplstyle preset file |
|
Available plot template types |
|
Boilerplate Python script for a specific plot type |
Tools¶
Callable functions the AI assistant can invoke during a conversation.
Tool |
Description |
|---|---|
|
Fetch any raw file from GitHub (README, CHANGELOG, examples, etc.) |
|
Get the hex code for a dartwork-mpl or matplotlib color name |
|
Blend two colors and return the resulting hex code |
|
List color families ( |
|
Analyze Python code for dartwork-mpl best practices and antipatterns |
|
Validate whether a data structure matches a plot type’s requirements |
|
Get a structured summary of all capabilities, presets, and templates |
Prompts¶
Interactive prompt templates that guide the AI through multi-step tasks.
Prompt |
Description |
|---|---|
|
Generate a complete dartwork-mpl script from a natural language description |
|
Review and fix a script for dartwork-mpl style compliance |
Practical use-cases¶
Here are specific examples of how an AI assistant behaves differently when the dartwork-mpl MCP server is connected:
Zero-shot accurate coding
You ask: “I need a bar chart for a Korean research paper.”
MCP in action: The assistant reads the
general-guideresource and immediately outputs correct code usingdm.subplots(style=['lang-kr']).
Automated layout debugging
You ask: “I used simple_layout but my legend is overlapping the plot.”
MCP in action: The assistant reads the
layout-guideresource, understands the library’s specific constraints, and provides the exact code to fix the issue.
Live color lookup
You ask: “What’s the hex code for dc.blue500?”
MCP in action: The assistant calls
get_color_value("dc.blue500")and returns the exact hex code — no guessing.
Code quality check
You ask: “Review my plotting script for dartwork-mpl best practices.”
MCP in action: The assistant uses the
lint_dartwork_mpl_codetool to check for antipatterns (e.g.,figsize=,tight_layout(),plt.subplots()) and suggests fixes.
Guided plot creation
You ask: “Create a tornado chart comparing energy savings.”
MCP in action: The assistant uses the
create_plotprompt with thetornadotemplate fromdartwork-mpl://templates/tornadoto generate a complete, standards-compliant script.
Data validation before plotting
You ask: “Plot this data as a heatmap.”
MCP in action: The assistant calls
validate_plot_data("heatmap", ...)to verify the data structure is correct before generating the plot code.
Installation¶
Prerequisites¶
Python ≥ 3.10
dartwork-mplinstalled (see Installation)The
[mcp]optional dependencies:# uv (recommended) uv pip install -e ".[mcp]" # pip pip install "dartwork-mpl[mcp]"
This pulls in
fastmcp ≥ 2.13andhttpx ≥ 0.27.
Client configuration¶
Every MCP-capable client has its own config format. Below are copy-paste-ready snippets for the most popular ones.
Add to ~/.claude.json (global) or <project>/.claude/mcp_servers.json:
{
"mcpServers": {
"dartwork-mpl": {
"command": "uv",
"args": [
"run",
"--directory",
"/absolute/path/to/dartwork-mpl",
"dartwork-mpl-mcp"
]
}
}
}
Add to ~/.cursor/mcp.json (or the Windsurf equivalent):
{
"mcpServers": {
"dartwork-mpl": {
"command": "uv",
"args": [
"run",
"--directory",
"/absolute/path/to/dartwork-mpl",
"dartwork-mpl-mcp"
]
}
}
}
Add to ~/.gemini/antigravity/mcp_config.json:
{
"mcpServers": {
"dartwork-mpl": {
"command": "uv",
"args": [
"run",
"--directory",
"/absolute/path/to/dartwork-mpl",
"dartwork-mpl-mcp"
],
"env": {}
}
}
}
After saving the config, restart Antigravity (or start a new conversation) for the server to be picked up. You can verify the connection by asking the assistant to list its available MCP resources.
Any client that supports the MCP stdio transport can launch the server directly:
uv run --directory /path/to/dartwork-mpl dartwork-mpl-mcp
Or via the Python module:
uv run python -m dartwork_mpl.mcp.server
Important: Replace
/absolute/path/to/dartwork-mplwith the actual path where the package source lives on your machine. If you installeddartwork-mplfrom PyPI (once published), the--directoryflag can be dropped and thecommandcan simply bedartwork-mpl-mcp.
Verification¶
After configuring your client, verify the server is reachable.
Quick smoke test (terminal)¶
# Send a JSON-RPC initialize request via stdin
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"0.1"}}}' \
| uv run dartwork-mpl-mcp
Expected output (key fields):
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2024-11-05",
"capabilities": {
"resources": { "subscribe": false, "listChanged": false },
"tools": { "listChanged": true },
"prompts": { "listChanged": false }
},
"serverInfo": { "name": "dartwork-mpl", "version": "..." }
}
}
If you see this response, the server is working correctly. ✅
Python import test¶
from dartwork_mpl.mcp.server import mcp
print(mcp.name) # → "dartwork-mpl"
print(mcp) # FastMCP instance info
Troubleshooting¶
Symptom |
Fix |
|---|---|
|
Install the MCP extras: |
|
The |
Server starts but client shows no resources |
Verify the |
|
The |