mcp-wandb
🔬 通过模型上下文协议直接从LLM代理查询您的权重和偏差实验📊
mcp-wandb是一个小型模型上下文协议服务器,用于从mcp兼容客户端查询权重和偏差。它通过stdio将W&B项目、运行、指标、运行细节和指标图作为FastMCP工具公开。
当您希望代理在不切换到W&B仪表板或手动复制运行元数据的情况下检查实验数据时,请使用它。
安装
git clone https://github.com/tsilva/mcp-wandb.git
cd mcp-wandb
uv sync
export WANDB_API_KEY=your_api_key
python server.py配置您的MCP客户端以运行仓库 server.py 文件,然后重新启动客户端。
{
"mcpServers": {
"wandb": {
"command": "python",
"args": ["/path/to/mcp-wandb/server.py"],
"env": {
"WANDB_API_KEY": "your_api_key"
}
}
}
}命令
uv sync # install dependencies into the local uv environment
python server.py # run the MCP server over stdio
pytest tests/ # run tests; W&B credentials are required for live API checks工具
get_wandb_projects(entity)列出W&B实体的项目。list_wandb_runs(entity, project_name)列表运行名称、ID和状态。list_project_metrics(entity, project_name)返回跨运行找到的度量名称。plot_run_metric(entity, project_name, run_id, metric_names)将PNG度量图作为FastMCP图像返回。get_run_details(entity, project_name, run_id)返回概述、配置、摘要和系统元数据。
备注
- 需要Python 3.13或更高版本。
WANDB_API_KEY必须在环境中设置,或在.env文件加载人python-dotenv.- 服务器使用
wandb.Api直接访问,不保留本地数据库。 - 测试调用真正的W&B API,并在缺少所需的凭据或测试项目变量时跳过。
- 实时测试变量为
TEST_WANDB_ENTITY,TEST_WANDB_PROJECT,TEST_WANDB_RUN_ID,以及TEST_WANDB_METRICS.
建筑
mcp-wandb architecture diagram
