PubFiguremcp
README.md
# PubFigure & ClusterCraft — Open-Source Python SDK & Local MCP Server
[](https://pubfigure.youxunzhangjim.workers.dev/)
[](./LICENSE)
Open-source **Python Matplotlib SDK (`pubfigure`)** and **100% local, zero-upload Model Context Protocol (MCP) Server (`clustercraft-mcp`)** for researchers, PhD students, and HPC/AI labs.
- **Interactive Web Workbench — PubFigure (42 Journals × 18 Plot Types × 30 Templates)**:
[https://pubfigure.youxunzhangjim.workers.dev/?tool=pubfigure&lang=en](https://pubfigure.youxunzhangjim.workers.dev/?tool=pubfigure&lang=en)
(繁體中文版:[https://pubfigure.youxunzhangjim.workers.dev/?tool=pubfigure&lang=zh-TW](https://pubfigure.youxunzhangjim.workers.dev/?tool=pubfigure&lang=zh-TW))
- **Interactive Web Workbench — ClusterCraft (13 Global Supercomputers Slurm Debugger & GPU Audit)**:
[https://pubfigure.youxunzhangjim.workers.dev/?tool=slurm&lang=en](https://pubfigure.youxunzhangjim.workers.dev/?tool=slurm&lang=en)
---
## 1. Local MCP Server (`clustercraft-mcp`) — 8 Deterministic Scientific Tools
Stop AI coding agents from hallucinating `#SBATCH` directives, QOS walltime limits, nonlinear curve fits, or p-values. Runs 100% locally over `stdio` with **zero runtime dependencies** and **zero telemetry**:
1. `list_cluster_profiles` — Specs for 13 global supercomputers (Taiwan NCHC Nano5 H100 / Taiwania 2 / Forerunner 1, Canada DRAC 2026 Fir/Nibi/Rorqual/Trillium/Narval, USA NERSC Perlmutter / TACC Vista `ibrun` / NCSA Delta, EuroHPC JUWELS Booster).
2. `lint_sbatch_script` — Pre-submission `.sbatch` validator (GPU directives, walltime/RAM QOS limits, offline compute-node `HF_HUB_OFFLINE=1` / `WANDB_MODE=offline` traps, TACC `ibrun`, DRAC Conda-on-Lustre checks).
3. `generate_slurm_script` — Validated `.sbatch` generator with `torchrun` DDP, MPI, job arrays, `$SLURM_TMPDIR` staging, and `24h` `--requeue` checkpoint chains.
4. `diagnose_slurm_log` — 12 offline diagnostic rules (OOM Exit 137 + `MaxRSS` patch, PyTorch `/dev/shm` `SIGBUS`, CUDA VRAM OOM, NCCL timeout, `seff` efficiency) + unified diff.
5. `audit_lab_sacct` — Bulk `sacct -P` lab GPU/RAM waste auditor.
6. `analyze_grouped_statistics` — Exact One-Way ANOVA + Welch's t-test / Student's t-test / Mann–Whitney U with Holm–Bonferroni correction + ready-to-paste Methods boilerplate.
7. `fit_scientific_curve` — Safe zero-`eval()` weighted Levenberg–Marquardt (`1/σ²`) nonlinear regression (10 curated models including 4PL Hill IC50, Michaelis–Menten, Lorentzian/Gaussian peaks, power law, or custom formula `y = f(x)`).
8. `render_publication_figure` — Compiles grouped or XY CSV data + any of **42 journal specs** (*Nature, Science, Cell, JAMA, Elsevier, Springer, AIP, IOP, Optica, ASME, ASCE, APA 7th, SAGE, MDPI, Frontiers, A4 Thesis*) into true-vector SVG and reproducible Matplotlib + SciPy Python code.
### Quick Setup (Cursor / Claude Desktop / Claude Code / Antigravity)
```bash
git clone https://github.com/youxunzhangjim-netizen/pubfigure-mcp.git
```
Add to `mcp_config.json` / `.cursor/mcp.json`:
```json
{
"mcpServers": {
"clustercraft": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/pubfigure-mcp/mcp-server/dist/clustercraft-mcp.mjs"]
}
}
}
```
Or deploy directly via **Smithery** (`smithery.yaml`) or **Glama** (`glama.json` + `Dockerfile`).
---
## 2. Python SDK (`pubfigure`) — 42 Journal Presets + Curve Fitting for Matplotlib
```bash
pip install pubfigure
# or from source:
pip install -e ./python
```
```python
import pubfigure as pf
fig = pf.Figure(journal="nature-single", palette="npg-nature")
fit = fig[0].fit(
x=[0.01, 0.03, 0.1, 0.3, 1.0, 3.0, 10.0, 30.0],
y=[99.2, 97.5, 91.8, 76.4, 49.8, 25.6, 12.4, 8.1],
yerr=[2.1, 2.4, 2.8, 3.2, 3.0, 2.5, 1.9, 1.6],
preset="hill_4pl",
log_x=True,
label="Kinase Inhibitor",
)
fig[0].set_labels(title="Dose-Response", xlabel="Conc. (µM)", ylabel="Viability (%)")
fig.save("fig1_nature_89mm.pdf")
fig.save_workspace("fig1_workspace.json") # Round-trips directly into the PubFigure Web UI!
print(fit.methods_sentence)
```
See [`python/README.md`](./python/README.md) and [`mcp-server/README.md`](./mcp-server/README.md) for full API docs.
---
Built by **YFind Digital Studio**.