opik-mcp 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -196
- package/build/cli.js +20 -2
- package/build/config.js +25 -9
- package/build/debug-log.js +5 -5
- package/build/index.js +51 -20
- package/build/prompts/core-prompts.js +1 -1
- package/build/resources/opik-resources.js +55 -10
- package/build/test-client.js +8 -5
- package/build/tools/capabilities.js +2 -2
- package/build/tools/dataset.js +60 -13
- package/build/tools/metrics.js +4 -2
- package/build/tools/project.js +10 -2
- package/build/tools/prompt.js +49 -13
- package/build/tools/registration.js +37 -8
- package/build/tools/schema.js +13 -2
- package/build/tools/trace.js +69 -18
- package/build/transports/streamable-http-transport.js +26 -9
- package/build/utils/capabilities.js +10 -3
- package/build/utils/deprecation.js +66 -0
- package/build/utils/examples.js +2 -2
- package/build/utils/opik-sdk.js +7 -2
- package/build/utils/remote-auth.js +8 -2
- package/build/utils/tracing-info.js +7 -1
- package/package.json +8 -4
- package/LICENSE +0 -203
package/README.md
CHANGED
|
@@ -1,20 +1,34 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
This README is preserved from the v2.0.1 release for historical reference.
|
|
3
|
+
The authoritative deprecation notice lives in DEPRECATED.md next to this file.
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
> ## ⚠️ Deprecated — migrate to the Python server
|
|
7
|
+
>
|
|
8
|
+
> This TypeScript MCP server (npm `opik-mcp`) is **deprecated** and will stop
|
|
9
|
+
> serving MCP requests on **2026-11-15**.
|
|
10
|
+
>
|
|
11
|
+
> In your MCP client config, replace `npx -y opik-mcp` with
|
|
12
|
+
> **`uvx opik-mcp@latest`**.
|
|
13
|
+
> Full migration guide: [`MIGRATION.md`](./MIGRATION.md)
|
|
14
|
+
> · Deprecation policy: [`DEPRECATED.md`](./DEPRECATED.md)
|
|
15
|
+
|
|
1
16
|
<h1 align="center" style="border-bottom: none">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
(Model Context Protocol)<br>
|
|
17
|
+
<div>
|
|
18
|
+
<a href="https://www.comet.com/site/products/opik/?from=llm&utm_source=opik&utm_medium=github&utm_content=header_img&utm_campaign=opik-mcp">
|
|
19
|
+
<picture>
|
|
20
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/comet-ml/opik-mcp/refs/heads/main/legacy/typescript/docs/assets/logo-dark-mode.svg">
|
|
21
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/comet-ml/opik-mcp/refs/heads/main/legacy/typescript/docs/assets/logo-light-mode.svg">
|
|
22
|
+
<img alt="Comet Opik logo" src="docs/assets/logo-light-mode.svg" width="200" />
|
|
23
|
+
</picture>
|
|
24
|
+
</a>
|
|
25
|
+
<br />
|
|
26
|
+
Opik MCP Server
|
|
27
|
+
</div>
|
|
14
28
|
</h1>
|
|
15
29
|
|
|
16
30
|
<p align="center">
|
|
17
|
-
|
|
31
|
+
Model Context Protocol (MCP) server for <a href="https://github.com/comet-ml/opik/">Opik</a>, with both local stdio and remote streamable-http transports.
|
|
18
32
|
</p>
|
|
19
33
|
|
|
20
34
|
<div align="center">
|
|
@@ -22,278 +36,202 @@ A Model Context Protocol (MCP) implementation for the <a href="https://github.co
|
|
|
22
36
|
[](https://github.com/comet-ml/opik-mcp/blob/main/LICENSE)
|
|
23
37
|
[](https://nodejs.org/)
|
|
24
38
|
[](https://www.typescriptlang.org/)
|
|
25
|
-
<img src="https://badge.mcpx.dev?status=on" title="MCP Enabled"
|
|
26
|
-
|
|
39
|
+
<a href="https://www.comet.com/docs/opik/prompt_engineering/mcp_server"><img src="https://badge.mcpx.dev?status=on" title="MCP Enabled" alt="MCP Enabled" /></a>
|
|
40
|
+
<a href="https://doi.org/10.5281/zenodo.15411156"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.15411156.svg" alt="DOI" /></a>
|
|
27
41
|
|
|
28
42
|
</div>
|
|
29
43
|
|
|
30
44
|
<p align="center">
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
<a href="https://www.comet.com/site/products/opik/?from=llm&utm_source=opik&utm_medium=github&utm_content=website_button&utm_campaign=opik"><b>Website</b></a> •
|
|
46
|
+
<a href="https://chat.comet.com"><b>Slack community</b></a> •
|
|
47
|
+
<a href="https://x.com/Cometml"><b>Twitter</b></a> •
|
|
48
|
+
<a href="https://www.comet.com/docs/opik/?from=llm&utm_source=opik&utm_medium=github&utm_content=docs_button&utm_campaign=opik"><b>Documentation</b></a>
|
|
35
49
|
</p>
|
|
36
50
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
</a>
|
|
41
|
-
</p>
|
|
42
|
-
|
|
43
|
-
> **Note:** This repository provides the MCP server implementation. We do not currently provide a hosted remote MCP service for Opik.
|
|
44
|
-
> If you run streamable-http remotely, authentication is fail-closed by default.
|
|
45
|
-
|
|
46
|
-
## 🚀 What is Opik MCP Server?
|
|
51
|
+
> [!IMPORTANT]
|
|
52
|
+
> This repository ships the MCP server implementation only. We do not currently provide a hosted remote MCP service for Opik.
|
|
53
|
+
> If you run `streamable-http` remotely, authentication is fail-closed by default.
|
|
47
54
|
|
|
48
|
-
|
|
55
|
+
## Why this server
|
|
49
56
|
|
|
50
|
-
|
|
57
|
+
Opik MCP Server gives MCP-compatible clients one interface for:
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
- Prompt lifecycle management
|
|
60
|
+
- Workspace, project, and trace exploration
|
|
61
|
+
- Metrics and dataset operations
|
|
62
|
+
- MCP resources and resource templates for metadata-aware flows
|
|
56
63
|
|
|
57
|
-
|
|
58
|
-
* Access all Opik features through a standardized protocol
|
|
59
|
-
* Leverage multiple transport options (stdio, streamable-http) for different integration scenarios
|
|
64
|
+
## Quickstart
|
|
60
65
|
|
|
61
|
-
|
|
62
|
-
* Manage prompts, projects, traces, and metrics through a consistent interface
|
|
63
|
-
* Organize and monitor your LLM applications efficiently
|
|
66
|
+
### 1. Run with npx
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
|
|
69
|
-
- **Traces**: Track and analyze trace data
|
|
70
|
-
- **Metrics**: Gather and query metrics data
|
|
71
|
-
- **MCP Resources**: Read-only resources for workspace/project metadata plus resource templates for prompts, datasets, and traces
|
|
72
|
-
|
|
73
|
-
## Quick Start
|
|
74
|
-
|
|
75
|
-
### Installation
|
|
76
|
-
|
|
77
|
-
#### Cursor Integration
|
|
68
|
+
```bash
|
|
69
|
+
# Opik Cloud
|
|
70
|
+
npx -y opik-mcp --apiKey YOUR_API_KEY
|
|
71
|
+
```
|
|
78
72
|
|
|
79
|
-
|
|
80
|
-
to the Features tab. If you scroll down to the MCP section you will see the
|
|
81
|
-
button `+ Add new MCP server` that will allow you to add the Opik MCP server.
|
|
73
|
+
For self-hosted Opik, pass `--apiUrl` (for example `http://localhost:5173/api`) and use your local auth strategy.
|
|
82
74
|
|
|
83
|
-
|
|
84
|
-
enter the command: `npx -y opik-mcp --apiKey YOUR_API_KEY`.
|
|
75
|
+
### 2. Add to your MCP client
|
|
85
76
|
|
|
86
|
-
|
|
77
|
+
Cursor (`.cursor/mcp.json`):
|
|
87
78
|
|
|
88
79
|
```json
|
|
89
80
|
{
|
|
90
81
|
"mcpServers": {
|
|
91
82
|
"opik": {
|
|
92
83
|
"command": "npx",
|
|
93
|
-
"args": [
|
|
94
|
-
"-y",
|
|
95
|
-
"opik-mcp",
|
|
96
|
-
"--apiKey",
|
|
97
|
-
"YOUR_API_KEY"
|
|
98
|
-
]
|
|
84
|
+
"args": ["-y", "opik-mcp", "--apiKey", "YOUR_API_KEY"]
|
|
99
85
|
}
|
|
100
86
|
}
|
|
101
87
|
}
|
|
102
88
|
```
|
|
103
89
|
|
|
104
|
-
|
|
105
|
-
the `apiBaseUrl` parameter as `http://localhost:5173/api`.
|
|
106
|
-
|
|
107
|
-
#### VS Code Integration (GitHub Copilot)
|
|
108
|
-
|
|
109
|
-
To integrate Opik with VS Code (GitHub Copilot), you need to add the MCP server
|
|
110
|
-
configuration to your workspace or user settings.
|
|
111
|
-
|
|
112
|
-
1. Create or open the `.vscode/mcp.json` file in your workspace (or run the
|
|
113
|
-
**MCP: Open User Configuration** command to add it globally).
|
|
114
|
-
|
|
115
|
-
2. Add the Opik MCP server configuration:
|
|
90
|
+
VS Code / GitHub Copilot (`.vscode/mcp.json`):
|
|
116
91
|
|
|
117
92
|
```json
|
|
118
93
|
{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
],
|
|
127
|
-
"servers": {
|
|
128
|
-
"opik-mcp": {
|
|
129
|
-
"type": "stdio",
|
|
130
|
-
"command": "npx",
|
|
131
|
-
"args": [
|
|
132
|
-
"-y",
|
|
133
|
-
"opik-mcp",
|
|
134
|
-
"--apiKey",
|
|
135
|
-
"${input:opik-api-key}"
|
|
136
|
-
]
|
|
137
|
-
}
|
|
94
|
+
"inputs": [
|
|
95
|
+
{
|
|
96
|
+
"type": "promptString",
|
|
97
|
+
"id": "opik-api-key",
|
|
98
|
+
"description": "Opik API Key",
|
|
99
|
+
"password": true
|
|
138
100
|
}
|
|
101
|
+
],
|
|
102
|
+
"servers": {
|
|
103
|
+
"opik-mcp": {
|
|
104
|
+
"type": "stdio",
|
|
105
|
+
"command": "npx",
|
|
106
|
+
"args": ["-y", "opik-mcp", "--apiKey", "${input:opik-api-key}"]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
139
109
|
}
|
|
140
110
|
```
|
|
141
111
|
|
|
142
|
-
|
|
143
|
-
to enter your Opik API key. The value is securely stored for subsequent use.
|
|
144
|
-
|
|
145
|
-
Note: If you are using the Open-Source version of Opik, add the `--apiBaseUrl`
|
|
146
|
-
argument and remove the `--apiKey` argument:
|
|
147
|
-
|
|
148
|
-
```json
|
|
149
|
-
{
|
|
150
|
-
"servers": {
|
|
151
|
-
"opik-mcp": {
|
|
152
|
-
"type": "stdio",
|
|
153
|
-
"command": "npx",
|
|
154
|
-
"args": [
|
|
155
|
-
"-y",
|
|
156
|
-
"opik-mcp",
|
|
157
|
-
"--apiBaseUrl",
|
|
158
|
-
"http://localhost:5173/api"
|
|
159
|
-
]
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
"inputs": []
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
#### Windsurf Installation
|
|
167
|
-
|
|
168
|
-
To install the MCP server in Windsurf, you will need to open the Windsurf settings
|
|
169
|
-
and navigate to the MCP section. From there, click on `View raw config` and update
|
|
170
|
-
the configuration object to be:
|
|
112
|
+
Windsurf (raw config):
|
|
171
113
|
|
|
172
114
|
```json
|
|
173
115
|
{
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
"-y",
|
|
179
|
-
"opik-mcp",
|
|
180
|
-
"--apiKey",
|
|
181
|
-
"YOUR_API_KEY"
|
|
182
|
-
]
|
|
183
|
-
}
|
|
116
|
+
"mcpServers": {
|
|
117
|
+
"opik": {
|
|
118
|
+
"command": "npx",
|
|
119
|
+
"args": ["-y", "opik-mcp", "--apiKey", "YOUR_API_KEY"]
|
|
184
120
|
}
|
|
185
121
|
}
|
|
122
|
+
}
|
|
186
123
|
```
|
|
187
124
|
|
|
188
|
-
|
|
189
|
-
|
|
125
|
+
More client-specific examples: [docs/ide-integration.md](docs/ide-integration.md)
|
|
126
|
+
|
|
127
|
+
## Run from source
|
|
190
128
|
|
|
191
|
-
#### Manual Installation
|
|
192
129
|
```bash
|
|
193
|
-
# Clone the repository
|
|
194
130
|
git clone https://github.com/comet-ml/opik-mcp.git
|
|
195
131
|
cd opik-mcp
|
|
196
|
-
|
|
197
|
-
# Install dependencies and build
|
|
198
132
|
npm install
|
|
199
133
|
npm run build
|
|
200
134
|
```
|
|
201
135
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
Create a `.env` file based on the example:
|
|
136
|
+
Optional local config:
|
|
205
137
|
|
|
206
138
|
```bash
|
|
207
139
|
cp .env.example .env
|
|
208
|
-
# Edit .env with your specific configuration
|
|
209
140
|
```
|
|
210
141
|
|
|
211
|
-
|
|
142
|
+
Start the server:
|
|
212
143
|
|
|
213
144
|
```bash
|
|
214
|
-
# Start with stdio transport (default)
|
|
215
145
|
npm run start:stdio
|
|
216
|
-
|
|
217
|
-
# Start with streamable-http transport for remote/self-hosted access
|
|
218
146
|
npm run start:http
|
|
219
147
|
```
|
|
220
148
|
|
|
221
|
-
## Transport
|
|
149
|
+
## Transport modes
|
|
222
150
|
|
|
223
|
-
|
|
151
|
+
| Transport | Use case | Command |
|
|
152
|
+
| --- | --- | --- |
|
|
153
|
+
| `stdio` | Local MCP integration (same machine as client) | `npm run start:stdio` |
|
|
154
|
+
| `streamable-http` | Remote/self-hosted MCP endpoint (`/mcp`) | `npm run start:http` |
|
|
224
155
|
|
|
225
|
-
|
|
156
|
+
### Remote auth defaults (`streamable-http`)
|
|
226
157
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
158
|
+
- `Authorization: Bearer <OPIK_API_KEY>` or `x-api-key` is required by default.
|
|
159
|
+
- Workspace is resolved server-side (token map recommended); workspace headers are not trusted by default.
|
|
160
|
+
- In remote mode, request-context workspace takes precedence over tool `workspaceName`.
|
|
161
|
+
- Missing or invalid auth returns HTTP `401`.
|
|
230
162
|
|
|
231
|
-
|
|
163
|
+
Key environment flags:
|
|
232
164
|
|
|
233
|
-
|
|
165
|
+
- `STREAMABLE_HTTP_REQUIRE_AUTH` (default `true`)
|
|
166
|
+
- `STREAMABLE_HTTP_VALIDATE_REMOTE_AUTH` (default `true`, except test env)
|
|
167
|
+
- `REMOTE_TOKEN_WORKSPACE_MAP` (JSON token-to-workspace map)
|
|
168
|
+
- `STREAMABLE_HTTP_TRUST_WORKSPACE_HEADERS` (default `false`)
|
|
234
169
|
|
|
235
|
-
|
|
236
|
-
- `Authorization: Bearer <OPIK_API_KEY>` or `x-api-key` is required by default.
|
|
237
|
-
- Workspace is resolved server-side (recommended via token mapping). Header workspaces are not trusted by default.
|
|
238
|
-
- In remote mode, request-context workspace takes precedence over tool `workspaceName` args.
|
|
239
|
-
- Missing/invalid auth returns HTTP `401`.
|
|
170
|
+
Deep dive: [docs/streamable-http-transport.md](docs/streamable-http-transport.md)
|
|
240
171
|
|
|
241
|
-
|
|
242
|
-
- `STREAMABLE_HTTP_REQUIRE_AUTH` (default `true`): require auth headers on `/mcp`.
|
|
243
|
-
- `STREAMABLE_HTTP_VALIDATE_REMOTE_AUTH` (default `true`, except test env): validate bearer/API key against Opik before accepting requests.
|
|
244
|
-
- `REMOTE_TOKEN_WORKSPACE_MAP`: JSON map of token -> workspace for server-side tenant routing.
|
|
245
|
-
- `STREAMABLE_HTTP_TRUST_WORKSPACE_HEADERS` (default `false`): allow workspace headers when token map is not configured.
|
|
172
|
+
## Toolsets
|
|
246
173
|
|
|
247
|
-
|
|
248
|
-
npm run start:http
|
|
249
|
-
```
|
|
174
|
+
Toolsets let you narrow which capabilities are enabled:
|
|
250
175
|
|
|
251
|
-
|
|
176
|
+
- `core`
|
|
177
|
+
- `integration`
|
|
178
|
+
- `expert-prompts`
|
|
179
|
+
- `expert-datasets`
|
|
180
|
+
- `expert-trace-actions`
|
|
181
|
+
- `expert-project-actions`
|
|
182
|
+
- `metrics`
|
|
183
|
+
- `all` (enables all modern toolsets)
|
|
252
184
|
|
|
253
|
-
|
|
185
|
+
Configure via:
|
|
254
186
|
|
|
255
|
-
-
|
|
256
|
-
- `
|
|
257
|
-
- `resources/read` supports both static URIs and filled template URIs.
|
|
258
|
-
- `prompts/list` and `prompts/get` expose workflow prompts (for example, `opik-triage-workflow`).
|
|
187
|
+
- CLI: `--toolsets all`
|
|
188
|
+
- Env: `OPIK_TOOLSETS=core,expert-prompts,metrics`
|
|
259
189
|
|
|
260
|
-
|
|
190
|
+
Details: [docs/configuration.md](docs/configuration.md)
|
|
261
191
|
|
|
262
|
-
|
|
192
|
+
## MCP resources and prompts
|
|
263
193
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
194
|
+
- `resources/list` exposes static URIs (for example `opik://workspace-info`)
|
|
195
|
+
- `resources/templates/list` exposes dynamic URI templates (for example `opik://projects/{page}/{size}`)
|
|
196
|
+
- `resources/read` supports static and templated URIs
|
|
197
|
+
- `prompts/list` and `prompts/get` expose workflow prompts
|
|
267
198
|
|
|
268
|
-
|
|
269
|
-
npm test -- tests/transports/streamable-http-transport.test.ts
|
|
270
|
-
```
|
|
199
|
+
## Development
|
|
271
200
|
|
|
272
|
-
|
|
201
|
+
```bash
|
|
202
|
+
# Lint
|
|
203
|
+
npm run lint
|
|
273
204
|
|
|
274
|
-
|
|
205
|
+
# Test
|
|
206
|
+
npm test
|
|
275
207
|
|
|
276
|
-
|
|
277
|
-
|
|
208
|
+
# Build
|
|
209
|
+
npm run build
|
|
210
|
+
|
|
211
|
+
# Run precommit checks
|
|
278
212
|
make precommit
|
|
279
213
|
```
|
|
280
214
|
|
|
281
215
|
## Documentation
|
|
282
216
|
|
|
283
|
-
- [
|
|
284
|
-
- [
|
|
285
|
-
- [
|
|
286
|
-
- [
|
|
217
|
+
- [API Reference](docs/api-reference.md)
|
|
218
|
+
- [Configuration](docs/configuration.md)
|
|
219
|
+
- [IDE Integration](docs/ide-integration.md)
|
|
220
|
+
- [Streamable HTTP Transport](docs/streamable-http-transport.md)
|
|
221
|
+
|
|
222
|
+
## Contributing
|
|
223
|
+
|
|
224
|
+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a PR.
|
|
287
225
|
|
|
288
226
|
## Citation
|
|
289
227
|
|
|
290
|
-
If you use this project in
|
|
228
|
+
If you use this project in research, cite:
|
|
291
229
|
|
|
292
230
|
```
|
|
293
231
|
Comet ML, Inc, Koc, V., & Boiko, Y. (2025). Opik MCP Server. Github. https://doi.org/10.5281/zenodo.15411156
|
|
294
232
|
```
|
|
295
233
|
|
|
296
|
-
|
|
234
|
+
BibTeX:
|
|
297
235
|
|
|
298
236
|
```bibtex
|
|
299
237
|
@software{CometML_Opik_MCP_Server_2025,
|
|
@@ -306,7 +244,7 @@ Or use the following BibTeX entry:
|
|
|
306
244
|
}
|
|
307
245
|
```
|
|
308
246
|
|
|
309
|
-
|
|
247
|
+
Citation metadata is also available in [CITATION.cff](CITATION.cff).
|
|
310
248
|
|
|
311
249
|
## License
|
|
312
250
|
|
package/build/cli.js
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
import yargs from 'yargs';
|
|
3
3
|
import { hideBin } from 'yargs/helpers';
|
|
4
4
|
import configImport from './config.js';
|
|
5
|
+
import { main } from './index.js';
|
|
6
|
+
import { DEPRECATION_NOTICE } from './utils/deprecation.js';
|
|
7
|
+
// Deprecation banner — stderr only, so stdio transport framing stays
|
|
8
|
+
// clean. Note: this does NOT appear on ``--help`` because ``config.ts``
|
|
9
|
+
// runs ``loadConfig()`` at module-load (ESM import ordering) and yargs
|
|
10
|
+
// inside it calls ``process.exit(0)`` on --help before this line ever
|
|
11
|
+
// executes. Accepted limitation — see commit message and OPIK-6713.
|
|
12
|
+
process.stderr.write(`${DEPRECATION_NOTICE.full}\n`);
|
|
5
13
|
// Parse command line arguments
|
|
6
14
|
const argv = yargs(hideBin(process.argv))
|
|
7
15
|
.scriptName('opik-mcp')
|
|
@@ -30,5 +38,15 @@ if (argv.transport === 'streamable-http' && typeof argv.port === 'number') {
|
|
|
30
38
|
configImport.streamableHttpPort = argv.port;
|
|
31
39
|
process.env.STREAMABLE_HTTP_PORT = String(argv.port);
|
|
32
40
|
}
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
function toErrorMessage(error) {
|
|
42
|
+
if (error instanceof Error) {
|
|
43
|
+
return error.message;
|
|
44
|
+
}
|
|
45
|
+
return String(error);
|
|
46
|
+
}
|
|
47
|
+
// Start the server after applying CLI overrides.
|
|
48
|
+
main().catch((error) => {
|
|
49
|
+
const message = toErrorMessage(error);
|
|
50
|
+
console.error(`Failed to start Opik MCP server: ${message}`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
});
|
package/build/config.js
CHANGED
|
@@ -58,7 +58,9 @@ const ALL_TOOLSET_CHOICES = [
|
|
|
58
58
|
];
|
|
59
59
|
export function normalizeToolsets(values) {
|
|
60
60
|
const normalized = new Set();
|
|
61
|
-
for (const value of values
|
|
61
|
+
for (const value of values
|
|
62
|
+
.flatMap((v) => v.split(','))
|
|
63
|
+
.map((v) => v.trim())) {
|
|
62
64
|
const toolset = value;
|
|
63
65
|
switch (toolset) {
|
|
64
66
|
case 'all':
|
|
@@ -116,7 +118,9 @@ function loadOpikConfigFile() {
|
|
|
116
118
|
for (const line of lines) {
|
|
117
119
|
const trimmedLine = line.trim();
|
|
118
120
|
// Skip empty lines and comments
|
|
119
|
-
if (!trimmedLine ||
|
|
121
|
+
if (!trimmedLine ||
|
|
122
|
+
trimmedLine.startsWith('#') ||
|
|
123
|
+
trimmedLine.startsWith(';')) {
|
|
120
124
|
continue;
|
|
121
125
|
}
|
|
122
126
|
// Check for section headers
|
|
@@ -253,20 +257,32 @@ export function loadConfig() {
|
|
|
253
257
|
isSelfHosted: args.selfHosted !== undefined
|
|
254
258
|
? args.selfHosted
|
|
255
259
|
: process.env.OPIK_SELF_HOSTED === 'true' || false,
|
|
256
|
-
debugMode: args.debug !== undefined
|
|
260
|
+
debugMode: args.debug !== undefined
|
|
261
|
+
? args.debug
|
|
262
|
+
: process.env.DEBUG_MODE === 'true' || false,
|
|
257
263
|
// Transport configuration
|
|
258
264
|
transport: (args.transport ?? process.env.TRANSPORT ?? 'stdio'),
|
|
259
265
|
streamableHttpPort: args.streamableHttpPort ??
|
|
260
|
-
(process.env.STREAMABLE_HTTP_PORT
|
|
261
|
-
|
|
266
|
+
(process.env.STREAMABLE_HTTP_PORT
|
|
267
|
+
? parseInt(process.env.STREAMABLE_HTTP_PORT, 10)
|
|
268
|
+
: 3001),
|
|
269
|
+
streamableHttpHost: args.streamableHttpHost ??
|
|
270
|
+
process.env.STREAMABLE_HTTP_HOST ??
|
|
271
|
+
'127.0.0.1',
|
|
262
272
|
streamableHttpLogPath: args.streamableHttpLogPath ??
|
|
263
|
-
(process.env.STREAMABLE_HTTP_LOG_PATH ||
|
|
273
|
+
(process.env.STREAMABLE_HTTP_LOG_PATH ||
|
|
274
|
+
'/tmp/opik-mcp-streamable-http.log'),
|
|
264
275
|
// MCP configuration with fallbacks
|
|
265
276
|
mcpName: args.mcpName || process.env.MCP_NAME || 'opik-manager',
|
|
266
277
|
mcpVersion: args.mcpVersion || process.env.MCP_VERSION || '2.0.0',
|
|
267
|
-
mcpPort: args.mcpPort ||
|
|
268
|
-
|
|
269
|
-
|
|
278
|
+
mcpPort: args.mcpPort ||
|
|
279
|
+
(process.env.MCP_PORT ? parseInt(process.env.MCP_PORT, 10) : undefined),
|
|
280
|
+
mcpLogging: args.mcpLogging !== undefined
|
|
281
|
+
? args.mcpLogging
|
|
282
|
+
: process.env.MCP_LOGGING === 'true' || false,
|
|
283
|
+
mcpDefaultWorkspace: args.mcpDefaultWorkspace ||
|
|
284
|
+
process.env.MCP_DEFAULT_WORKSPACE ||
|
|
285
|
+
'default',
|
|
270
286
|
// Toolset configuration with fallbacks
|
|
271
287
|
enabledToolsets: (() => {
|
|
272
288
|
// Command line takes precedence
|
package/build/debug-log.js
CHANGED
|
@@ -21,8 +21,8 @@ export function initDebugLog() {
|
|
|
21
21
|
// Log environment variables
|
|
22
22
|
logDebug('Environment Variables:');
|
|
23
23
|
Object.keys(process.env)
|
|
24
|
-
.filter(key => key.startsWith('OPIK_'))
|
|
25
|
-
.forEach(key => {
|
|
24
|
+
.filter((key) => key.startsWith('OPIK_'))
|
|
25
|
+
.forEach((key) => {
|
|
26
26
|
let value = process.env[key];
|
|
27
27
|
// Mask sensitive information
|
|
28
28
|
if (key === 'OPIK_API_KEY')
|
|
@@ -35,7 +35,7 @@ export function initDebugLog() {
|
|
|
35
35
|
logDebug(` ${index}: ${arg}`);
|
|
36
36
|
});
|
|
37
37
|
// Set up uncaught exception handler
|
|
38
|
-
process.on('uncaughtException', error => {
|
|
38
|
+
process.on('uncaughtException', (error) => {
|
|
39
39
|
logDebug(`UNCAUGHT EXCEPTION: ${error.message}`);
|
|
40
40
|
logDebug(error.stack || 'No stack trace available');
|
|
41
41
|
});
|
|
@@ -44,7 +44,7 @@ export function initDebugLog() {
|
|
|
44
44
|
logDebug(`UNHANDLED REJECTION: ${reason}`);
|
|
45
45
|
});
|
|
46
46
|
// Set up exit handler
|
|
47
|
-
process.on('exit', code => {
|
|
47
|
+
process.on('exit', (code) => {
|
|
48
48
|
logDebug(`Process exiting with code: ${code}`);
|
|
49
49
|
});
|
|
50
50
|
}
|
|
@@ -52,7 +52,7 @@ export function logDebug(message) {
|
|
|
52
52
|
const logPath = '/tmp/opik-mcp-debug.log';
|
|
53
53
|
const timestamp = new Date().toISOString();
|
|
54
54
|
const logMessage = `[${timestamp}] ${message}\n`;
|
|
55
|
-
return new Promise(resolve => {
|
|
55
|
+
return new Promise((resolve) => {
|
|
56
56
|
try {
|
|
57
57
|
fs.appendFileSync(logPath, logMessage);
|
|
58
58
|
}
|