Bayesian MCP
贝叶斯 MCP
用于贝叶斯推理、推断和信念更新的模型调用协议 (MCP) 服务器。该工具使法学硕士 (LLM) 能够执行严格的贝叶斯分析和概率推理。
特征
🧠贝叶斯推理:使用 MCMC 抽样,利用新证据更新信念
📊模型比较:使用信息标准比较竞争模型
🔮预测推理:通过不确定性量化生成预测
📈可视化:创建后验分布的可视化
🔌 MCP 集成:与任何支持 MCP 的 LLM 无缝集成
Related MCP server: Calculator MCP Server
安装
开发安装
克隆存储库并安装依赖项:
git clone https://github.com/wrenchchatrepo/bayesian-mcp.git
cd bayesian-mcp
pip install -e .要求
Python 3.9+
PyMC 5.0+
阿维兹
NumPy
Matplotlib
快速API
优维康
快速入门
启动服务器
# Run with default settings
python bayesian_mcp.py
# Specify host and port
python bayesian_mcp.py --host 0.0.0.0 --port 8080
# Set log level
python bayesian_mcp.py --log-level debug服务器将启动并监听指定主机和端口上的 MCP 请求。
API 使用
贝叶斯 MCP 服务器通过其 API 公开了几个功能:
1.创建模型
使用指定的变量创建一个新的贝叶斯模型。
# MCP Request
{
"function_name": "create_model",
"parameters": {
"model_name": "my_model",
"variables": {
"theta": {
"distribution": "normal",
"params": {"mu": 0, "sigma": 1}
},
"likelihood": {
"distribution": "normal",
"params": {"mu": "theta", "sigma": 0.5},
"observed": [0.1, 0.2, 0.3, 0.4]
}
}
}
}2.更新信念
用新证据更新模型信念。
# MCP Request
{
"function_name": "update_beliefs",
"parameters": {
"model_name": "my_model",
"evidence": {
"data": [0.1, 0.2, 0.3, 0.4]
},
"sample_kwargs": {
"draws": 1000,
"tune": 1000,
"chains": 2
}
}
}3. 做出预测
使用后验分布生成预测。
# MCP Request
{
"function_name": "predict",
"parameters": {
"model_name": "my_model",
"variables": ["theta"],
"conditions": {
"x": [1.0, 2.0, 3.0]
}
}
}4. 比较模型
使用信息标准比较多个模型。
# MCP Request
{
"function_name": "compare_models",
"parameters": {
"model_names": ["model_1", "model_2"],
"metric": "waic"
}
}5.创建可视化
生成模型后验分布的可视化。
# MCP Request
{
"function_name": "create_visualization",
"parameters": {
"model_name": "my_model",
"plot_type": "trace",
"variables": ["theta"]
}
}示例
examples/目录包含几个示例,演示如何使用贝叶斯 MCP 服务器:
线性回归
一个简单的线性回归示例来演示参数估计:
python examples/linear_regression.pyA/B 测试
贝叶斯 A/B 测试转化率的示例:
python examples/ab_test.py支持的发行版
贝叶斯引擎支持以下分布:
normal:正态(高斯)分布lognormal:对数正态分布beta:Beta 分布gamma:伽马分布exponential:指数分布uniform:均匀分布bernoulli:伯努利分布binomial:二项分布poisson:泊松分布deterministic:确定性变换
MCP 集成
此服务器实现了模型调用协议 (MCP),使其与各种 LLM 和框架兼容。要将其与您的 LLM 一起使用:
import requests
response = requests.post("http://localhost:8000/mcp", json={
"function_name": "create_model",
"parameters": {
"model_name": "example_model",
"variables": {...}
}
})
result = response.json()执照
麻省理工学院
致谢
基于 Wrench AI 框架的概念和代码。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for building and testing AI agents with multi-model experimentation and insights.
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
Related MCP Servers
- AlicenseAqualityCmaintenanceA Model Context Protocol server that provides basic mathematical and statistical functions to LLMs, enabling them to perform accurate numerical calculations through a simple API.13191MIT
- AlicenseCqualityDmaintenanceA Model Context Protocol server that enables LLMs to perform precise numerical calculations by evaluating mathematical expressions.16,210 PyPI160MIT
- FlicenseNot gradedqualityDmaintenanceEnables LLMs to perform statistical analysis and generate ML predictions on user data from databases or CSV files through a Model Context Protocol server.2-
- AlicenseAqualityCmaintenanceA Model Context Protocol server that empowers AI agents with metacognitive monitoring to detect reasoning loops and provide intelligent recovery using case-based reasoning and statistical analysis.948 npm9MIT