@databrainhq/mcp-server 0.2.11 → 0.2.13

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 CHANGED
@@ -1,13 +1,13 @@
1
1
  # @databrainhq/mcp-server
2
2
 
3
- Add embedded analytics to your app using natural language. Connect this MCP server to any AI assistant and describe what you want — it handles the Databrain API for you.
3
+ Add embedded analytics to your app using natural language. Connect this MCP server to any AI assistant and describe what you want — it handles the setup steps for you.
4
4
 
5
5
  ```
6
6
  "What was total revenue last month?"
7
7
  "Embed my sales dashboard in my React app"
8
8
  ```
9
9
 
10
- Works with Claude, Cursor, Windsurf, and any MCP-compatible client.
10
+ Works with Codex, Claude, Cursor, Windsurf, and any MCP-compatible client.
11
11
 
12
12
  ---
13
13
 
@@ -23,6 +23,24 @@ Works with Claude, Cursor, Windsurf, and any MCP-compatible client.
23
23
 
24
24
  > **Self-hosted?** Also set `DATABRAIN_API_URL` in the `env` block — see [Self-hosted Databrain](#self-hosted-databrain) below.
25
25
 
26
+ <details>
27
+ <summary><b>Codex</b></summary>
28
+
29
+ Add the MCP server with your service token:
30
+
31
+ ```bash
32
+ codex mcp add databrain --env DATABRAIN_SERVICE_TOKEN=YOUR_SERVICE_TOKEN -- npx @databrainhq/mcp-server
33
+ ```
34
+
35
+ Verify the server is configured:
36
+
37
+ ```bash
38
+ codex mcp list
39
+ ```
40
+
41
+ Start a new Codex session after adding the server.
42
+ </details>
43
+
26
44
  <details>
27
45
  <summary><b>Cursor</b></summary>
28
46
 
@@ -118,8 +136,9 @@ Running Databrain on your own infrastructure? Point the MCP server at your insta
118
136
  "command": "npx",
119
137
  "args": ["@databrainhq/mcp-server"],
120
138
  "env": {
121
- "DATABRAIN_PAT": "<your-personal-access-token>",
122
- "DATABRAIN_API_URL": "https://api.your-databrain.example.com"
139
+ "DATABRAIN_SERVICE_TOKEN": "<your-service-token>",
140
+ "DATABRAIN_API_URL": "https://api.your-databrain.example.com",
141
+ "DATABRAIN_DEMO_DOMAIN": "https://demo.your-databrain.example.com"
123
142
  }
124
143
  }
125
144
  }
@@ -129,7 +148,7 @@ Running Databrain on your own infrastructure? Point the MCP server at your insta
129
148
  Checklist:
130
149
  - `DATABRAIN_API_URL` must be the **API origin** for your self-hosted instance (not the dashboard URL). Typically `https://api.<your-domain>`.
131
150
  - The token must be minted from that same self-hosted instance — tokens are not portable across instances.
132
- - Use `DATABRAIN_PAT` (Settings → Personal Access Tokens) for per-user role checks and audit. Use `DATABRAIN_SERVICE_TOKEN` if you want the MCP server to act with full org-level privileges (no per-user audit).
151
+ - Use `DATABRAIN_SERVICE_TOKEN` (Settings → Service Tokens) for org-level access.
133
152
  - The MCP client process must be able to reach the URL (VPN, firewall, self-signed certs all apply here).
134
153
  - Scaffolded frontend code (React, Next.js, Vue, etc.) reads the same `DATABRAIN_API_URL` for server-side guest-token generation, so the variable flows through to your app.
135
154
 
@@ -139,7 +158,7 @@ Open your AI assistant and try any of these:
139
158
 
140
159
  > **"Set up a Databrain embed for my dashboard"**
141
160
 
142
- > **"Brand my embed to match our company colors"**
161
+ > **"Brand my embed to match our colors"**
143
162
 
144
163
  > **"What was total revenue last month?"**
145
164
 
@@ -195,13 +214,21 @@ Each of your customers gets their own dashboard with row-level security.
195
214
 
196
215
  Add, remove, or modify widgets (metrics) on a specific customer's embed without opening the Databrain UI. Clone from a template widget, write a fresh SQL spec, or generate one from a prompt. End with a demo link to verify exactly what that customer will see — same URL the UI's "Share Demo Link" generates.
197
216
 
198
- > "Add the 'Calls per day' widget from the standard template to Acme's dashboard"
217
+ > "Add the 'Calls per day' widget from the standard template to a client's dashboard"
218
+
219
+ > "Generate a widget showing disqualification reasons and add it to a client's embed"
220
+
221
+ > "Remove the billing widget from one client's dashboard but keep it for other clients"
199
222
 
200
- > "Generate a widget showing disqualification reasons for Acme and add it to their embed"
223
+ > "Give me a demo link for a client's dashboard so I can see what they'll see"
201
224
 
202
- > "Remove the billing widget from Acme's dashboard but keep it for other customers"
225
+ ### Migrate validated SQL into metrics
203
226
 
204
- > "Give me a demo link for Acme's dashboard so I can see what they'll see"
227
+ Turn warehouse-validated SQL into Databrain metrics with a production-safe flow: validate the target dashboard/datasource, produce a dry-run plan, then apply only after explicit confirmation.
228
+
229
+ > "Validate this SQL as a new metric on my operations dashboard"
230
+
231
+ > "Dry-run creating this converted query as a metric, then show me the exact apply plan"
205
232
 
206
233
  ### Enable self-serve analytics
207
234
 
@@ -221,17 +248,16 @@ Let end-users build their own metrics with drag-and-drop or AI-powered chat.
221
248
 
222
249
  ## Environment Variables
223
250
 
224
- At least one of `DATABRAIN_PAT`, `DATABRAIN_SERVICE_TOKEN`, or `DATABRAIN_API_TOKEN` must be set. PAT is preferred — it binds the MCP session to a specific user so role checks and audit logs work correctly.
251
+ At least one of `DATABRAIN_SERVICE_TOKEN` or `DATABRAIN_API_TOKEN` must be set. Use a service token for full setup and management flows; use an API token only when you are operating inside one data app.
225
252
 
226
253
  | Variable | Required | Default | Description |
227
254
  |----------|----------|---------|-------------|
228
- | `DATABRAIN_PAT` | One of three† | — | Personal Access Token from Settings → Personal Access Tokens. Binds the MCP session to your Databrain user — actions are role-checked and audited under your account. **Preferred for sandboxed hosts** (Claude Desktop, ChatGPT Desktop) and headless/CI environments where local credential caching isn't reliable. |
229
- | `DATABRAIN_SERVICE_TOKEN` | One of three† | — | Org-level token from Settings → Service Tokens. Powers all discovery and setup operations. The `connect` tool can mint a PAT on top of this for per-user audit. |
230
- | `DATABRAIN_API_TOKEN` | One of three† | — | Per-data-app token. Created automatically during setup via `create_api_token`, or set manually if you already have one. |
255
+ | `DATABRAIN_SERVICE_TOKEN` | One of two† | — | Org-level token from Settings → Service Tokens. Powers discovery, setup, data app management, semantic layer, and production-safe datamart operations. |
256
+ | `DATABRAIN_API_TOKEN` | One of two† | — | Per-data-app token. Created automatically during setup via `create_api_token`, or set manually if you already have one. Sufficient for embedding operations on a single data app. |
231
257
  | `DATABRAIN_API_URL` | **Required for self-hosted** | `https://api.usedatabrain.com` | API base URL. Set to your instance's API origin (e.g. `https://api.your-databrain.example.com`). |
232
258
  | `DATABRAIN_DEMO_DOMAIN` | Optional | `https://demo.usedatabrain.com` | Base host for `get_demo_link` URLs. Override for self-hosted instances or custom preview domains (e.g. `https://demo.your-databrain.example.com`). |
233
259
 
234
- † At least one of these three credentials must be set. Token resolution priority: `DATABRAIN_PAT` > cached PAT (from `connect`) > `DATABRAIN_SERVICE_TOKEN` > `DATABRAIN_API_TOKEN`.
260
+ † At least one of these two credentials must be set. Token resolution priority: `DATABRAIN_SERVICE_TOKEN` > `DATABRAIN_API_TOKEN`.
235
261
 
236
262
  ---
237
263
 
@@ -247,17 +273,18 @@ Prompts are guided workflows your AI assistant can follow. Ask for them by name
247
273
  | `brand-my-embed` | Customize colors, fonts, charts, card styling, responsive layout |
248
274
  | `query-data` | Query your data with natural language, manage the semantic layer |
249
275
  | `populate-semantic-layer` | Auto-generate table/column descriptions to enable natural language querying |
276
+ | `sql-to-metric-migration` | Production-safe SQL-to-metric workflow: validate, dry-run, then apply with explicit confirmation |
250
277
 
251
278
  ---
252
279
 
253
280
  ## Tools Reference
254
281
 
255
- 29 tools organized by category. Your AI assistant picks the right tools automatically — you don't need to call them directly.
282
+ 34 tools organized by category. Your AI assistant picks the right tools automatically — you don't need to call them directly.
256
283
 
257
- > **Note:** Infrastructure creation (datasources, datamarts, workspaces) is done in the **Databrain UI**. However, the **semantic layer** is populated via MCP tools (`get_semantic_layer`, `update_semantic_layer`) — the AI auto-generates descriptions from column names.
284
+ > **Note:** Datasource and workspace creation happen outside MCP. Datamarts can be planned with `create_datamart` in `dry_run` mode and created only with `confirm: "APPLY_TO_PRODUCTION"`. The semantic layer is managed via MCP tools (`get_semantic_layer`, `update_semantic_layer`, `start_semantic_layer_generation`, `get_semantic_layer_generation_status`).
258
285
 
259
286
  <details>
260
- <summary><b>Infrastructure — Exploration</b> (4)</summary>
287
+ <summary><b>Infrastructure — Exploration and setup</b> (6)</summary>
261
288
 
262
289
  | Tool | Description |
263
290
  |------|-------------|
@@ -265,6 +292,8 @@ Prompts are guided workflows your AI assistant can follow. Ask for them by name
265
292
  | `discover_datasource_schema` | Inspect a datasource to see available tables and columns |
266
293
  | `list_datamarts` | List datamarts |
267
294
  | `list_workspaces` | List all workspaces (shows datamart/datasource connections) |
295
+ | `sync_datasource` | Trigger datasource schema sync |
296
+ | `create_datamart` | Dry-run or create a datamart from selected tables and relationships |
268
297
  </details>
269
298
 
270
299
  <details>
@@ -287,9 +316,9 @@ Prompts are guided workflows your AI assistant can follow. Ask for them by name
287
316
  | `create_embed` | Create an embed (standard or multi-tenant with `clientId`) |
288
317
  | `list_embeds` | List embed configurations (includes `distinctClientIds` for multi-tenant client discovery) |
289
318
  | `get_embed_details` | Get full embed details by ID |
290
- | `update_embed` | Update embed config — access settings, options, filters, i18n (via `body` passthrough) |
319
+ | `update_embed` | Update embed config — access settings, options, filters, i18n, and advanced embed options |
291
320
  | `customize_embed_theme` | Presets, colors, fonts, cards, chart appearance, responsive layout |
292
- | `get_demo_link` | Get a shareable demo URL for a `clientId` — same link the UI's "Share Demo Link" generates. Use to preview ops-built widgets without a test app |
321
+ | `get_demo_link` | Get a shareable demo URL for a `clientId` — same link the UI's "Share Demo Link" generates |
293
322
  </details>
294
323
 
295
324
  <details>
@@ -302,28 +331,41 @@ Prompts are guided workflows your AI assistant can follow. Ask for them by name
302
331
  </details>
303
332
 
304
333
  <details>
305
- <summary><b>Query & Semantic Layer</b> (3) — Ask questions and manage data documentation</summary>
334
+ <summary><b>Query & Semantic Layer</b> (5) — Ask questions and manage data documentation</summary>
306
335
 
307
336
  | Tool | Description |
308
337
  |------|-------------|
309
338
  | `ask_question` | Ask a natural language question — gets converted to SQL, returns data + chart suggestion |
310
339
  | `get_semantic_layer` | Inspect semantic layer metadata (table/column descriptions, synonyms, completion score) |
311
340
  | `update_semantic_layer` | Improve semantic layer quality (add descriptions, synonyms, example questions) |
341
+ | `start_semantic_layer_generation` | Start semantic-layer generation for a datamart |
342
+ | `get_semantic_layer_generation_status` | Check semantic-layer generation progress |
312
343
  </details>
313
344
 
314
345
  <details>
315
- <summary><b>Dashboards & Widgets</b> (6) — Discover dashboards and CRUD widgets on customer embeds</summary>
346
+ <summary><b>Dashboards & Widgets</b> (8) — Discover dashboards and CRUD widgets on customer embeds</summary>
316
347
 
317
348
  | Tool | Description |
318
349
  |------|-------------|
319
350
  | `list_dashboards` | List dashboards (by data app, workspace, or globally) |
320
351
  | `list_widgets` | List widgets on an embed for a specific client |
321
- | `add_widget` | Add a widget — clone from a template (`templateMetricId`), supply a full spec, or pass a raw body from `generate_widget` |
352
+ | `validate_metric_spec` | Validate a SQL-backed metric target without saving |
353
+ | `create_or_update_metric_from_query` | Dry-run or apply a SQL-backed metric create/update |
354
+ | `add_widget` | Add a widget — clone from a template (`templateMetricId`), supply a metric configuration, or use a generated draft |
322
355
  | `update_widget` | Patch a widget's fields (name, query, chartOptions, isPublished, etc.) |
323
356
  | `remove_widget` | Per-client soft delete — hides the widget for one client only |
324
357
  | `generate_widget` | AI-generate a widget draft from a natural-language prompt. Returns a draft; pass to `add_widget` to persist |
325
358
 
326
- Widget mutation tools mint a guest token internally for `(clientId, dataAppName)`. Provide `embedId` + `clientId` — the tools resolve the rest.
359
+ Provide `clientId` and `dashboardName`; include `workspaceName` only if dashboard names are ambiguous. The tools resolve the required resources automatically.
360
+ Production writes through `create_or_update_metric_from_query` default to `dry_run`; `apply` requires `confirm: "APPLY_TO_PRODUCTION"`.
361
+ </details>
362
+
363
+ <details>
364
+ <summary><b>Scheduled Reports</b> (1)</summary>
365
+
366
+ | Tool | Description |
367
+ |------|-------------|
368
+ | `list_scheduled_reports` | List configured scheduled reports for a dashboard/client scope |
327
369
  </details>
328
370
 
329
371
  ---
@@ -384,13 +426,11 @@ node --version # Should be v18.0.0 or higher
384
426
  ## How it works
385
427
 
386
428
  ```
387
- Your AI Client ←→ MCP Server ←→ Databrain API
388
- (Claude, (this (your data,
389
- Cursor, package) dashboards,
390
- etc.) embeds)
429
+ Your AI Client MCP Server Databrain API
430
+ (Codex, Claude, Cursor, etc.) ←→ (this package) ←→ (your data, dashboards, embeds)
391
431
  ```
392
432
 
393
- The MCP server translates natural language requests into Databrain API calls. It manages authentication (service tokens, API tokens, guest tokens), validates inputs, and provides guided workflows so you don't need to learn the Databrain API directly.
433
+ The MCP server translates natural language requests into Databrain actions. It manages authentication (service tokens, API tokens, guest tokens), validates inputs, and provides guided workflows so you don't need to learn the Databrain API directly.
394
434
 
395
435
  All tokens are managed automatically. You provide your service token once in the config — everything else is created and handled by the server during setup.
396
436