scvi-tools-mcp block diagram
Architecture map for the scvi-tools-mcp package: MCP client consumers,
a FastMCP stdio server, seven tool-module groups
(model guidance, data preparation, tutorials,
workflows, API reference, hub, troubleshooting),
shared utilities, a structured Markdown/JSON knowledge base bundled with the package,
and an offline build-script pipeline that populates the knowledge base
from upstream notebooks, documentation, community sources, and Hugging Face Hub metadata.
Layer colors
Arrows
MCP clients
Any MCP-compatible AI client connects over the Model Context Protocol. Claude Desktop and Claude Code are the primary consumers; any agent framework that supports MCP (Zed, Cursor, custom LLM agents) works out of the box. The server exposes 17 registered tools.
scvi-tools-mcp server
main.py is the CLI entry point — run_app() calls
mcp.run(transport="stdio").
mcp.py holds the FastMCP singleton and its system prompt.
Tool modules self-register via @mcp.tool() on import —
no manual wiring needed. Deployable as a Docker container or via pip install.
Tool modules
src/scvi_tools_mcp/tools/ — 7 modules · 17 registered tools
Model Guidance
Recommends and explains scvi-tools models ranked by suitability for a given task and data type. Entry point for any model-selection workflow.
Data Preparation
Generates exact setup_anndata() calls and validates AnnData
obs / var requirements for each model before training.
Hugging Face Hub
Lists, inspects, and suggests official scvi-tools Hugging Face Hub model repos from a bundled quarterly snapshot. No runtime network calls.
Tutorials
Lists, retrieves, and keyword-searches paginated Markdown tutorials derived from scvi-tools Jupyter notebooks across 12 categories.
Workflow Templates
Returns runnable, commented Python templates for common analysis tasks and downstream result extraction after training.
API Reference
Looks up and keyword-searches the full scvi-tools public API surface — class signatures, method docs, and parameter tables.
Troubleshooting & FAQ
Surfaces FAQ answers from Discourse community threads and runs broad keyword search across all knowledge files.
Utilities
get_knowledge_dir() resolves the package-bundled knowledge path at runtime.
truncate() enforces MCP response size limits.
paginate() handles multi-page tutorial delivery, returning
page and total_pages for large files.
Constants
MODEL_NAMES — a typed Literal union of all 30+ supported model names.
Shared across tool modules for Pydantic parameter validation.
Knowledge base
src/scvi_tools_mcp/knowledge/ — static Markdown and JSON, bundled with the package
Model Docs
30+ MD files. One per model: scvi, scanvi, totalvi, peakvi, multivi, mrvi, resolvi, …
API Reference
15 MD files. Per-model API signatures, parameter tables, and docstrings.
Tutorials
12 categories (scrna, multimodal, spatial, atac, hub, r, cytometry, …). Notebook-derived MD.
Hub Registry
Quarterly Hugging Face snapshot: 121 pretrained scvi-tools repos with class, modality, tissue, and files.
Skills
20+ MD files. Step-by-step workflow recipes referenced by Claude Code skills.
User Guide
8 guides: training config, callbacks, multi-GPU, model saving, hyperparameter tuning, criticism.
Background
5 MD files: variational inference, DE, transfer learning, counterfactual prediction.
FAQ
Discourse thread extracts. Community-sourced answers to common scvi-tools questions.
Build scripts
scripts/ — run offline to populate and refresh the knowledge base
Notebook Converter
Downloads scvi-tools Jupyter notebooks from upstream and converts them to Markdown for the
tutorials/ knowledge directory.
External Scraper
Scrapes upstream documentation (ReadTheDocs, Discourse, GitHub) into
background/ and faq/ knowledge.
API Doc Extractor
Extracts API signatures and docstrings from the installed scvi-tools package into
api/ knowledge files.
Hub Snapshotter
Fetches public scvi-tools Hugging Face model metadata into
hub/models.json and hub/summary.md.