wb运行mcp
用于权重和偏差的最小可组合MCP服务器。专为需要读取实验数据而无需与GraphQL搏斗的LLM而构建。
为什么?
官方的W&B MCP服务器公开原始GraphQL,并期望LLM通过分页、过滤器转义和连接模式构造有效的查询。它总是失败。
此服务器有5个直接使用W&B Python SDK的工具:
| 工具 | 它做什么 |
|---|---|
list_projects | 发现可用项目 |
list_runs | 搜索/过滤器使用正则表达式、状态、日期、配置、标签运行 |
get_run | 完整细节:配置、指标名称、摘要值、步数 |
get_metrics | 具有自动下采样+汇总统计的时间序列数据 |
compare_runs | 与配置差异和对齐指标进行并排比较 |
设置
1.安装
# Using uv (recommended)
uv pip install wb-runs-mcp
# Or from source
git clone https://github.com/your-org/wb-runs-mcp
cd wb-runs-mcp
uv venv && uv pip install -e .2.设置API密钥
export WANDB_API_KEY=your_key_here
# Get one at https://wandb.ai/authorize3.添加到克劳德代码
添加到您的 .mcp.json (项目层面)或 ~/.mcp.json (全球):
{
"mcpServers": {
"wb": {
"command": "wb-runs-mcp",
"env": {
"WANDB_API_KEY": "your_key_here"
}
}
}
}或者,如果从源代码运行:
{
"mcpServers": {
"wb": {
"command": "uv",
"args": ["--directory", "/path/to/wb-runs-mcp", "run", "wb-runs-mcp"],
"env": {
"WANDB_API_KEY": "your_key_here"
}
}
}
}用法示例
一旦连接,您的LLM可以:
“我有什么项目?” → Calls list_projects()
“显示最新的训练运行” → Calls list_runs(project="my-project", limit=1)
“目前正在运行什么?” → Calls list_runs(project="my-project", state="running")
“m94p3szz的失利情况如何?” → Calls get_metrics(project="my-project", run_id="m94p3szz", metrics=["train/loss"])
“比较最近两次运行的损失和准确性” → Calls compare_runs(project="my-project", run_ids=["abc", "xyz"], metrics=["train/loss", "eval/accuracy"])
“放大损失曲线的1000-2000步” → Calls get_metrics(..., min_step=1000, max_step=2000)
设计
- 无GraphQL --直接使用W&B Python SDK
- 自动下采样 --从不返回超过200-500个数据点(可配置)
- 统计摘要 --服务器端计算的最小值/最大值/平均值/最终值
- 配置差异 —
compare_runs仅显示不同的配置键 - 清除错误 --结构化JSON错误,而不是Python回溯
- 约300条线路 --易于审计、分叉和扩展
工具参考
list_项目
list_projects(entity?: string)列出所有项目。如果 entity 省略,返回您的帐户和所有团队的项目。
list_run
list_runs(
project: string,
entity?: string,
name_contains?: string, # case-insensitive substring
name_regex?: string, # regex pattern
state?: string, # "finished" | "running" | "crashed" | "failed"
created_after?: string, # ISO date
created_before?: string, # ISO date
config_filters?: object, # e.g. {"lr": 0.001}
tags?: string[], # all must match
include_config?: boolean, # include full config per run
limit?: number, # default 10, max 50
offset?: number # for pagination
)get_run
get_run(project: string, run_id: string, entity?: string)返回配置、可用指标(按前缀分组)、摘要值、步数。
get_metrics
get_metrics(
project: string,
run_id: string,
metrics: string[], # e.g. ["train/loss", "eval/mae"]
entity?: string,
min_step?: number,
max_step?: number,
max_points?: number # default 200, max 500
)退货 {step, metric_name: value} 数据点+ {min, max, mean, final, count} 按指标统计。
compareruns
compare_runs(
project: string,
run_ids: string[], # 2-10 run IDs
metrics: string[],
entity?: string,
max_points?: number # default 100, max 200
)返回汇总表、配置差异(仅不同的键)和每次运行的数据。
许可证
麻省理工学院
