Stats Engine MCP Server
A statistical analysis MCP server offering 30 tools for descriptive statistics, hypothesis tests, regression, and time series, all returning Markdown reports with automatic interpretations to enable AI agents to perform comprehensive data analysis.
README
MCP 统计分析服务器 (mcp-stats-engine)
一个基于 Model Context Protocol (MCP) 的统计分析服务器,提供 30 个专业统计工具,涵盖描述性统计、假设检验、回归分析和时间序列分析四大模块。所有工具返回 Markdown 格式的分析报告,数组参数以逗号分隔字符串传递,便于 AI 代理直接调用和展示。
特性
- 30 个专业统计工具: 覆盖统计分析全流程
- Markdown 输出: 所有工具返回格式化的 Markdown 字符串,包含表格、统计量和结论解读
- FastMCP 框架: 基于
mcp.server.fastmcp.FastMCP和@mcp.tool()装饰器 - 科学计算引擎: 使用 scipy.stats 和 statsmodels 实现统计计算
- 简洁的参数设计: 数组参数以逗号分隔字符串传递,多组数据以分号分隔
- 自动结论解读: 每个工具都包含基于 p 值和效应量的自动统计结论
安装方法
1. 安装依赖
pip install -r requirements.txt
依赖包列表:
mcp>=1.0.0- MCP 协议框架scipy- 科学计算statsmodels- 统计建模numpy- 数值计算pandas- 数据处理
2. 配置 MCP 客户端
在 MCP 客户端配置文件中添加以下配置(以 Claude Desktop 为例):
{
"mcpServers": {
"stats-engine": {
"command": "python",
"args": ["path/to/mcp-stats-engine/server.py"]
}
}
}
3. 启动服务器
python server.py
使用示例
描述性统计
工具: descriptive_statistics_tool
参数: data = "12,15,14,10,18,20,17,16,13,19"
双样本 t 检验
工具: two_sample_ttest_tool
参数:
group1 = "25,28,30,32,35,27,29,31,33,26"
group2 = "20,22,24,26,28,21,23,25,27,22"
equal_var = true
单因素方差分析
工具: anova_test_tool
参数: groups_data = "1,2,3,4,5;2,4,6,8,10;3,5,7,9,11"
OLS 线性回归
工具: ols_regression_tool
参数:
y_data = "1,2,3,4,5,6,7,8,9,10"
x_data = "2,4,5,7,9,11,12,14,15,17"
ARIMA 预测
工具: arima_forecast_tool
参数:
data = "30,28,32,35,33,31,29,27,30,33,36,34,32,30,33,36,38,35,33,31"
order = "1,0,1"
forecast_steps = 5
正态性检验
工具: normality_test_tool
参数:
data = "12,15,14,10,18,20,17,16,13,19,22,25"
method = "shapiro"
工具列表
辅助工具 (4个)
| 工具 | 说明 |
|---|---|
parse_data_string_tool |
数据解析(逗号分隔字符串转数值列表) |
confidence_interval_tool |
置信区间计算(基于 t 分布) |
effect_size_tool |
效应量计算(Cohen's d / Glass's delta) |
power_analysis_tool |
功效分析(样本量计算) |
描述性统计 (6个)
| 工具 | 说明 |
|---|---|
descriptive_statistics_tool |
描述性统计(均值/中位数/众数/方差/偏度/峰度/四分位数) |
frequency_distribution_tool |
频数分布表 |
five_number_summary_tool |
五数概括(Min/Q1/Median/Q3/Max) |
correlation_analysis_tool |
相关分析(Pearson/Spearman/Kendall) |
covariance_matrix_tool |
协方差矩阵 |
outlier_detection_tool |
异常值检测(IQR/Z-score) |
假设检验 (8个)
| 工具 | 说明 |
|---|---|
one_sample_ttest_tool |
单样本 t 检验 |
two_sample_ttest_tool |
双样本 t 检验(含 Welch's t 检验) |
paired_ttest_tool |
配对 t 检验 |
chi_square_test_tool |
卡方检验(拟合优度) |
anova_test_tool |
单因素方差分析 (ANOVA) |
mann_whitney_test_tool |
Mann-Whitney U 检验(非参数) |
wilcoxon_test_tool |
Wilcoxon 符号秩检验(非参数配对) |
normality_test_tool |
正态性检验(Shapiro-Wilk/K-S) |
回归分析 (6个)
| 工具 | 说明 |
|---|---|
ols_regression_tool |
OLS 线性回归(一元) |
multiple_regression_tool |
多元线性回归 |
logistic_regression_tool |
Logistic 回归(统计视角) |
weighted_regression_tool |
加权最小二乘回归 (WLS) |
residual_analysis_tool |
残差分析(正态性/独立性/同方差性) |
multicollinearity_check_tool |
多重共线性检验 (VIF) |
时间序列分析 (6个)
| 工具 | 说明 |
|---|---|
decompose_timeseries_tool |
时间序列分解(趋势/季节/残差) |
acf_pacf_analysis_tool |
ACF/PACF 分析 |
adf_test_tool |
ADF 单位根检验 |
kpss_test_tool |
KPSS 平稳性检验 |
arima_forecast_tool |
ARIMA 预测 |
granger_causality_tool |
Granger 因果检验 |
技术栈
| 技术 | 用途 |
|---|---|
| MCP | Model Context Protocol 通信框架 |
| FastMCP | MCP Python 服务器框架 |
| SciPy | 科学计算与统计检验 (scipy.stats) |
| Statsmodels | 统计建模 (OLS/WLS/Logit/ARIMA/时间序列) |
| NumPy | 数值计算 |
| Pandas | 数据处理 |
项目结构
mcp-stats-engine/
├── server.py # 主入口,FastMCP 服务器
├── descriptive_tools.py # 描述性统计工具(6个)
├── hypothesis_tools.py # 假设检验工具(8个)
├── regression_tools.py # 回归分析工具(6个)
├── timeseries_tools.py # 时间序列工具(6个)
├── utils.py # 辅助函数(4个工具)
├── README.md # 项目文档
├── SKILL.md # SkillHub 技能描述
└── requirements.txt # 依赖
许可证
MIT License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。