Opik MCP Server
Model Context Protocol (MCP) server for Opik, with both local stdio and remote streamable-http transports.
Website • Slack community • Twitter • Documentation
[!重要] 此存储库仅提供MCP服务器实现。我们目前不为Opik提供托管远程MCP服务。 如果你跑
streamable-http远程,默认情况下身份验证会失败关闭。
为什么选择此服务器
Opik MCP服务器为MCP兼容客户端提供了一个接口,用于:
- 快速的生命周期管理
- 工作空间、项目和跟踪探索
- 度量和数据集操作
- 用于元数据感知流的MCP资源和资源模板
快速入门
1.使用npx运行
BASH``` 1 2# Opik Cloud npx -y opik-mcp —apiKey YOUR_API_KEY
对于自托管的Opik,请通过 `--apiUrl` (例如 `http://localhost:5173/api`)并使用您的本地身份验证策略。
### 2.添加到您的MCP客户端
光标(`.cursor/mcp.json`):
JSON```
1
2
3
4
5
6
7
8{
"mcpServers": {
"opik": {
"command": "npx",
"args": ["-y", "opik-mcp", "--apiKey", "YOUR_API_KEY"]
}
}
}
VS代码/GitHub副本(.vscode/mcp.json):
JSON``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17{ “inputs”: [ { “type”: “promptString”, “id”: “opik-api-key”, “description”: “Opik API Key”, “password”: true } ], “servers”: { “opik-mcp”: { “type”: “stdio”, “command”: “npx”, “args”: [“-y”, “opik-mcp”, “—apiKey”, ”${input:opik-api-key}”] } } }
风帆(原始配置):
JSON```
1
2
3
4
5
6
7
8{
"mcpServers": {
"opik": {
"command": "npx",
"args": ["-y", "opik-mcp", "--apiKey", "YOUR_API_KEY"]
}
}
}
更多客户特定示例: docs/ide-integration.md
从源代码运行
BASH``` 1 2 3 4git clone https://github.com/comet-ml/opik-mcp.git cd opik-mcp npm install npm run build
可选本地配置:
BASH```
1cp .env.example .env
启动服务器:
BASH``` 1 2npm run start:stdio npm run start:http
## 运输方式
| 运输 | 用例 | 命令 |
| --- | --- | --- |
| `stdio` | 本地MCP集成(与客户端同一台机器) | `npm run start:stdio` |
| `streamable-http` | 远程/自托管MCP端点(`/mcp`) | `npm run start:http` |
### 远程身份验证默认值(`streamable-http`)
- `Authorization: Bearer <OPIK_API_KEY>` 或 `x-api-key` 默认情况下是必需的。
- 工作区在服务器端解析(建议使用令牌映射);默认情况下,工作区标头不受信任。
- 在远程模式下,请求上下文工作区优先于工具 `workspaceName`.
- 缺少或无效的身份验证返回HTTP `401`.
关键环境标志:
- `STREAMABLE_HTTP_REQUIRE_AUTH` (默认值 `true`)
- `STREAMABLE_HTTP_VALIDATE_REMOTE_AUTH` (默认值 `true`,测试环境除外)
- `REMOTE_TOKEN_WORKSPACE_MAP` (JSON令牌到工作区映射)
- `STREAMABLE_HTTP_TRUST_WORKSPACE_HEADERS` (默认值 `false`)
深潜: docs/streamable-http-transport.md
## 工具集
工具集允许您缩小启用的功能范围:
- `core`
- `integration`
- `expert-prompts`
- `expert-datasets`
- `expert-trace-actions`
- `expert-project-actions`
- `metrics`
- `all` (启用所有现代工具集)
配置方式:
- CLI: `--toolsets all`
- 环境: `OPIK_TOOLSETS=core,expert-prompts,metrics`
细节: docs/configuration.md
## MCP资源和提示
- `resources/list` 公开静态URI(例如 `opik://workspace-info`)
- `resources/templates/list` 公开动态URI模板(例如 `opik://projects/{page}/{size}`)
- `resources/read` 支持静态和模板化URI
- `prompts/list` 和 `prompts/get` 公开工作流提示
## 发展
BASH```
1
2
3
4
5
6
7
8# Lint
npm run lint
# Test
npm test
# Build
npm run build
# Run precommit checks
make precommit
文档
- API 参考
- 配置
- IDE 集成
- 可流式HTTP传输
贡献
请阅读 贡献.md 在打开PR之前。
引用
如果你在研究中使用这个项目,请引用:
1Comet ML, Inc, Koc, V., & Boiko, Y. (2025). Opik MCP Server. Github. https://doi.org/10.5281/zenodo.15411156
BibTeX:
BIBTEX``` 1 2 3 4 5 6 7 8@software{CometML_Opik_MCP_Server_2025, author = {{Comet ML, Inc} and Koc, V. and Boiko, Y.}, title = {{Opik MCP Server}}, year = {2025}, publisher = {GitHub}, url = {https://doi.org/10.5281/zenodo.15411156}, doi = {10.5281/zenodo.15411156} }
引文元数据也可在 引文.cff.
## 许可证
Apache 2.0