statsmodels-mcp is an MCP server for people writing code with statsmodels. It helps an MCP client choose an estimator, generate starter formulas and code, suggest diagnostics and post-estimation checks, and search the bundled statsmodels docs with a local BM25 index.
- Recommend statsmodels estimators from task characteristics.
- Profile row-oriented sample data and infer likely estimator families.
- Inspect supported model families and compare nearby alternatives.
- Generate Patsy formulas for formula-capable models.
- Generate runnable starter code and fit templates for common
statsmodelsworkflows. - Rewrite model code and append diagnostics blocks.
- Suggest covariance strategies for heteroskedastic, autocorrelated, or clustered settings.
- Debug fitting failures and explain pasted summary output.
- Suggest diagnostics, robustness checks, and post-estimation analyses.
- Search the vendored
docs/*.rstcorpus locally withbm25sand extract doc examples. - Expose MCP tools, resources, prompts, plus HTTP health/readiness routes.
list_model_familiesrecommend_modelsget_model_detailsprofile_dataframeinfer_model_from_dataframegenerate_formula_templategenerate_code_examplefit_model_templatedebug_fit_failureexplain_summary_tableadd_diagnostics_to_coderewrite_model_codesuggest_covariance_strategysuggest_diagnosticssuggest_post_estimationcompare_modelssearch_docsextract_doc_examplesread_doc_pageget_docs_for_modellist_statsmodels_apis
statsmodels://server/capabilitiesstatsmodels://project/settingsstatsmodels://models/catalogstatsmodels://docs/manifeststatsmodels://docs/{doc_path}statsmodels://reference/overview
choose statsmodels modelgenerate statsmodels workflowdebug model fitinterpret regression results
Install dependencies:
uv syncRun over stdio:
uv run python mcp_server.py --transport stdioRun over HTTP:
uv run python mcp_server.py --transport http --host 127.0.0.1 --port 8000Health endpoints:
GET /healthzGET /readyz
Important environment variables:
STATSMODELS_MCP_DOCS_DIRSTATSMODELS_MCP_DOCS_TOP_KSTATSMODELS_MCP_TRANSPORTSTATSMODELS_MCP_HOSTSTATSMODELS_MCP_PORTSTATSMODELS_MCP_HTTP_HEALTH_PATHSTATSMODELS_MCP_HTTP_READY_PATH
Example:
STATSMODELS_MCP_DOCS_DIR=./docs \
STATSMODELS_MCP_DOCS_TOP_K=8 \
uv run python mcp_server.py --transport stdiojust test