@databrainhq/mcp-server 0.1.1 → 0.2.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 CHANGED
@@ -1,71 +1,30 @@
1
1
  # @databrainhq/mcp-server
2
2
 
3
- MCP server for Databrain embedded analytics. Connect it to any AI assistant and say **"set up a Databrain embed"** — it walks you through the entire flow interactively.
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.
4
4
 
5
- ---
5
+ ```
6
+ "What was total revenue last month?"
7
+ "Embed my sales dashboard in my React app"
8
+ ```
6
9
 
7
- ## Quick Start
10
+ Works with Claude, Cursor, Windsurf, and any MCP-compatible client.
8
11
 
9
- ### Prerequisites
12
+ ---
10
13
 
11
- - Node.js 18+
12
- - Databrain Cloud account ([usedatabrain.com](https://usedatabrain.com))
13
- - Service token (Settings > Service Tokens in Databrain UI)
14
+ ## Setup (2 minutes)
14
15
 
15
- ### 1. Get Your Service Token
16
+ ### 1. Get your Service Token
16
17
 
17
18
  1. Log in to [Databrain](https://usedatabrain.com)
18
- 2. Go to **Settings > Service Tokens**
19
+ 2. Go to **Settings → Service Tokens**
19
20
  3. Create a new token and copy it
20
21
 
21
- ### 2. Connect to Your AI Assistant
22
-
23
- Pick your client below. All configs use the same MCP server — just different config file locations.
24
-
25
- ---
26
-
27
- #### Claude Desktop
28
-
29
- File: `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows)
30
-
31
- ```json
32
- {
33
- "mcpServers": {
34
- "databrain": {
35
- "command": "npx",
36
- "args": ["@databrainhq/mcp-server"],
37
- "env": {
38
- "DATABRAIN_SERVICE_TOKEN": "<your-service-token>",
39
- "DATABRAIN_API_URL": "https://api.usedatabrain.com"
40
- }
41
- }
42
- }
43
- }
44
- ```
45
-
46
- #### Claude Code (CLI)
47
-
48
- ```bash
49
- claude mcp add databrain -- npx @databrainhq/mcp-server
50
- ```
51
-
52
- Then set your token in the environment:
53
- ```bash
54
- export DATABRAIN_SERVICE_TOKEN="<your-service-token>"
55
- ```
56
-
57
- Or add to your project's `.claude/settings.json`:
58
- ```json
59
- {
60
- "env": {
61
- "DATABRAIN_SERVICE_TOKEN": "<your-service-token>"
62
- }
63
- }
64
- ```
22
+ ### 2. Add to your AI client
65
23
 
66
- #### Cursor
24
+ <details>
25
+ <summary><b>Cursor</b></summary>
67
26
 
68
- File: `.cursor/mcp.json` (project-level) or `~/.cursor/mcp.json` (global)
27
+ Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
69
28
 
70
29
  ```json
71
30
  {
@@ -80,10 +39,12 @@ File: `.cursor/mcp.json` (project-level) or `~/.cursor/mcp.json` (global)
80
39
  }
81
40
  }
82
41
  ```
42
+ </details>
83
43
 
84
- #### Windsurf
44
+ <details>
45
+ <summary><b>Claude Desktop</b></summary>
85
46
 
86
- File: `~/.codeium/windsurf/mcp_config.json`
47
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
87
48
 
88
49
  ```json
89
50
  {
@@ -98,17 +59,26 @@ File: `~/.codeium/windsurf/mcp_config.json`
98
59
  }
99
60
  }
100
61
  ```
62
+ </details>
101
63
 
102
- #### ChatGPT (via MCP bridge)
64
+ <details>
65
+ <summary><b>Claude Code (CLI)</b></summary>
103
66
 
104
- ChatGPT doesn't natively support MCP yet. Use an MCP-to-OpenAI bridge like [mcp-bridge](https://github.com/nicobailon/mcp-bridge) or [mcp-openai](https://github.com/AshDevFr/mcp-openai-proxy):
67
+ ```bash
68
+ claude mcp add databrain -- npx @databrainhq/mcp-server
69
+ ```
105
70
 
71
+ Set your token:
106
72
  ```bash
107
- # Example with mcp-bridge
108
- npx mcp-bridge --config mcp-config.json
73
+ export DATABRAIN_SERVICE_TOKEN="<your-service-token>"
109
74
  ```
75
+ </details>
76
+
77
+ <details>
78
+ <summary><b>Windsurf</b></summary>
79
+
80
+ Add to `~/.codeium/windsurf/mcp_config.json`:
110
81
 
111
- `mcp-config.json`:
112
82
  ```json
113
83
  {
114
84
  "mcpServers": {
@@ -122,173 +92,269 @@ npx mcp-bridge --config mcp-config.json
122
92
  }
123
93
  }
124
94
  ```
95
+ </details>
125
96
 
126
- #### Any MCP-Compatible Client
97
+ <details>
98
+ <summary><b>Any MCP-compatible client</b></summary>
127
99
 
128
- The server uses **stdio transport** by default. Any client that supports MCP stdio can connect:
100
+ The server uses stdio transport. Set environment variables and run:
129
101
 
130
102
  ```bash
103
+ export DATABRAIN_SERVICE_TOKEN="<your-service-token>"
131
104
  npx @databrainhq/mcp-server
132
105
  ```
106
+ </details>
133
107
 
134
- Set environment variables before running:
135
- ```bash
136
- export DATABRAIN_SERVICE_TOKEN="<your-service-token>"
137
- export DATABRAIN_API_URL="https://api.usedatabrain.com" # optional, this is the default
138
- ```
108
+ ### 3. Start talking
109
+
110
+ Open your AI assistant and try any of these:
111
+
112
+ > **"Set up a Databrain embed for my dashboard"**
113
+
114
+ > **"Brand my embed to match our company colors"**
115
+
116
+ > **"What was total revenue last month?"**
117
+
118
+ The assistant walks you through each step interactively — picking your data app, selecting a workspace and dashboard, creating the embed, and generating the frontend code.
139
119
 
140
120
  ---
141
121
 
142
- ### 3. Start Using It
122
+ ## What you can ask
123
+
124
+ ### Query your data
125
+
126
+ Ask questions in natural language — the AI converts them to SQL, runs the query, and returns results with a chart type suggestion.
127
+
128
+ > "What was total revenue last month?"
129
+
130
+ > "Show me the monthly revenue trend for the past year"
131
+
132
+ > "Compare sales by region — break it down by quarter"
133
+
134
+ No setup required beyond your service token. Use `list_datamarts` to see available data, and the AI handles the rest. Follow-up questions use conversation context for better accuracy.
135
+
136
+ > "Now show only the top 5 regions"
137
+
138
+ If results seem off, improve the **semantic layer** — the metadata that helps the AI understand your column names and relationships:
139
+
140
+ > "Check the semantic layer quality for my orders datamart"
141
+
142
+ > "Add descriptions and synonyms to improve query accuracy"
143
+
144
+ ### Embed a dashboard
143
145
 
144
- Once connected, just tell your AI assistant:
146
+ The most common flow. You have dashboards in the Databrain UI and want to embed them.
145
147
 
146
- > **"Set up a Databrain dashboard embed"**
148
+ > "Embed my sales dashboard in my React app"
147
149
 
148
- The assistant will use the `setup_embed_interactive` tool to walk you through:
149
- 1. Discovering your data apps (confirms your choice even if there's only one)
150
- 2. Checking/creating an API token
151
- 3. Listing embeds and confirming which one to use
152
- 4. Validating the pipeline with a test guest token
153
- 5. Returning a ready-to-use config block with all IDs and env vars
150
+ The assistant will: discover your data apps → ensure API token → select workspace → list dashboards → create embed → generate a guest token → give you framework-specific code.
154
151
 
155
- No need to memorize tool names or API details — the orchestrator handles it.
152
+ ### Brand and theme
153
+
154
+ Customize colors, fonts, chart styles, responsive breakpoints, and card styling.
155
+
156
+ > "Make my embed match our brand — primary color #4F46E5, dark mode, Inter font"
157
+
158
+ > "Apply the corporate theme preset and hide the dashboard name"
159
+
160
+ ### Multi-tenant embeds
161
+
162
+ Each of your customers gets their own dashboard with row-level security.
163
+
164
+ > "Create per-client dashboard embeds for my SaaS app"
165
+
166
+ ### Enable self-serve analytics
167
+
168
+ Let end-users build their own metrics with drag-and-drop or AI-powered chat.
169
+
170
+ > "Enable metric creation on my embed with the visual builder"
171
+
172
+ ### Filters, localization, permissions
173
+
174
+ > "Add a date range filter and a region dropdown to my dashboard"
175
+
176
+ > "Set up French translations for my embed"
177
+
178
+ > "Lock down the embed so users can only view, not edit"
156
179
 
157
180
  ---
158
181
 
159
182
  ## Environment Variables
160
183
 
161
- | Variable | Required | Description |
162
- |----------|----------|-------------|
163
- | `DATABRAIN_SERVICE_TOKEN` | Yes* | Organization-level token for datasources, data apps, datamarts |
164
- | `DATABRAIN_API_TOKEN` | No | Data-app-scoped token for embeds, queries, guest tokens. Can be created via `create_api_token` tool |
165
- | `DATABRAIN_API_URL` | No | API base URL (default: `https://api.usedatabrain.com`) |
166
-
167
- *At least one of `DATABRAIN_SERVICE_TOKEN` or `DATABRAIN_API_TOKEN` is required.
184
+ | Variable | Required | Default | Description |
185
+ |----------|----------|---------|-------------|
186
+ | `DATABRAIN_SERVICE_TOKEN` | **Yes** | — | Org-level token from Settings → Service Tokens. Powers all discovery and setup operations. |
187
+ | `DATABRAIN_API_TOKEN` | No | — | Per-data-app token. Created automatically during setup via `create_api_token`, or set manually if you already have one. |
188
+ | `DATABRAIN_API_URL` | No | `https://api.usedatabrain.com` | API base URL. Only change this for self-hosted Databrain. |
168
189
 
169
190
  ---
170
191
 
171
- ## What's Inside
192
+ ## Available Prompts
172
193
 
173
- ### Orchestration
174
- - `setup_embed_interactive` — Interactive step-by-step embed setup. Confirms choices with the user, validates the pipeline, and returns a deterministic config block.
194
+ Prompts are guided workflows your AI assistant can follow. Ask for them by name or describe what you want.
175
195
 
176
- ### Tools (37 total)
196
+ | Prompt | What it does |
197
+ |--------|-------------|
198
+ | `embed-existing-dashboard` | Embed a dashboard you've already built in the Databrain UI |
199
+ | `embed-blank-dashboard` | Multi-tenant setup — each client gets their own dashboard |
200
+ | `enable-metric-creation` | Let end-users build metrics (drag-and-drop or AI chat) |
201
+ | `brand-my-embed` | Customize colors, fonts, charts, card styling, responsive layout |
202
+ | `localize-embed` | Multi-language support, translations, calendar format |
203
+ | `secure-my-embed` | Permissions, access controls, role-based guest tokens |
204
+ | `setup-filters` | Dashboard filters — dropdowns, date ranges, server-side filters |
205
+ | `manage-embeds` | List, compare, and review existing embed configurations |
206
+ | `query-data` | Query your data with natural language, manage the semantic layer |
207
+ | `populate-semantic-layer` | Auto-generate table/column descriptions to enable natural language querying |
177
208
 
178
- <details>
179
- <summary>Infrastructure (3)</summary>
209
+ ---
180
210
 
181
- - `list_datasources` — List all connected datasources
182
- - `create_datasource` — Connect a new database (Postgres, Snowflake, BigQuery, MySQL, Redshift, and more)
183
- - `sync_datasource` — Trigger schema metadata sync after connecting a database
184
- </details>
211
+ ## Tools Reference
185
212
 
186
- <details>
187
- <summary>Data Apps & Tokens (5)</summary>
213
+ 24 tools organized by category. Your AI assistant picks the right tools automatically — you don't need to call them directly.
188
214
 
189
- - `create_data_app` — Create a logical container for embeds
190
- - `list_data_apps` — List data apps
191
- - `create_api_token` — Generate API token scoped to a data app
192
- - `list_api_tokens` — List API tokens for a data app
193
- - `rotate_api_token` — Rotate an API token (invalidates the old one)
194
- </details>
215
+ > **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.
195
216
 
196
217
  <details>
197
- <summary>Datamarts & Semantic Layer (4)</summary>
218
+ <summary><b>Infrastructure — Exploration & Linking</b> (5)</summary>
219
+
220
+ | Tool | Description |
221
+ |------|-------------|
222
+ | `list_datasources` | List connected datasources |
223
+ | `discover_datasource_schema` | Inspect a datasource to see available tables and columns |
224
+ | `list_datamarts` | List datamarts |
225
+ | `list_workspaces` | List all workspaces (shows datamart/datasource connections) |
226
+ | `link_datamart_to_workspace` | Link a datamart to an existing workspace |
227
+ </details>
198
228
 
199
- - `list_datamarts` — List datamarts
200
- - `create_datamart` — Create a curated subset of tables for analytics
201
- - `get_semantic_layer_status` — Check semantic layer generation progress
202
- - `generate_semantic_layer` — Auto-generate semantic layer for AI chat mode
229
+ <details>
230
+ <summary><b>Data Apps & Tokens</b> (5)</summary>
231
+
232
+ | Tool | Description |
233
+ |------|-------------|
234
+ | `list_data_apps` | List data apps |
235
+ | `create_data_app` | Create a new data app |
236
+ | `list_api_tokens` | List API tokens for a data app |
237
+ | `create_api_token` | Create and activate an API token |
238
+ | `rotate_api_token` | Rotate an existing API token |
203
239
  </details>
204
240
 
205
241
  <details>
206
- <summary>Embed Management (7)</summary>
207
-
208
- - `create_embed` — Create embed config for a dashboard/metric
209
- - `list_embeds` — List embed configurations
210
- - `get_embed_details` — Get full embed details
211
- - `update_embed` — Update embed access settings, permissions, or theme
212
- - `delete_embed` — Delete an embed configuration
213
- - `rename_embed` — Rename an embed
214
- - `apply_embed_preset` — Apply theme/access presets (light/dark/corporate/minimal + view-only/power-user/export-only/ai-enabled)
242
+ <summary><b>Embeds</b> (7) — Create, configure, and customize embedded dashboards</summary>
243
+
244
+ | Tool | Description |
245
+ |------|-------------|
246
+ | `create_embed` | Create an embed (standard or multi-tenant with `clientId`) |
247
+ | `list_embeds` | List embed configurations |
248
+ | `get_embed_details` | Get full embed details by ID |
249
+ | `update_embed` | Update embed config (raw patch) |
250
+ | `customize_embed_theme` | Presets, colors, fonts, cards, chart appearance, responsive layout |
251
+ | `configure_embed` | UI options, filters (string/date/number/SQL), i18n, translations |
252
+ | `diagnose_embed_health` | Diagnose malformed embeds + validate runtime readiness |
215
253
  </details>
216
254
 
217
255
  <details>
218
- <summary>Customization (5)</summary>
256
+ <summary><b>Frontend</b> (2) — Guest tokens and code generation</summary>
219
257
 
220
- - `customize_embed_theme` — Set colors, typography, card styling, dashboard layout, chart fonts, buttons, checkboxes, and more
221
- - `configure_chart_appearance` — Configure chart tooltip, legend, axes, labels, margins, and color palettes
222
- - `configure_embed_options` — Toggle ~30 display/permission flags (metric ops, layout, downloads, loaders, UI, custom messages)
223
- - `configure_filters` — Set up dashboard filters with defaults, date presets, SQL-based options, and visibility
224
- - `configure_internationalization` — Set language (12 supported), translations, calendar type, and custom messages
258
+ | Tool | Description |
259
+ |------|-------------|
260
+ | `generate_guest_token` | Generate a frontend guest token (server-side) |
261
+ | `generate_embed_code` | Generate integration code (React, Next.js, Vue, Angular, Svelte, vanilla JS) |
225
262
  </details>
226
263
 
227
264
  <details>
228
- <summary>Frontend Embedding (2)</summary>
265
+ <summary><b>Query & Semantic Layer</b> (3) — Ask questions and manage data documentation</summary>
229
266
 
230
- - `generate_guest_token` — Generate frontend auth token with filters, theme overrides, permissions, and multi-datasource support
231
- - `generate_embed_code` — Generate framework-specific code (React, Next.js, Vue, Angular, Svelte, SolidJS, vanilla JS)
267
+ | Tool | Description |
268
+ |------|-------------|
269
+ | `ask_question` | Ask a natural language question — gets converted to SQL, returns data + chart suggestion |
270
+ | `get_semantic_layer` | Inspect semantic layer metadata (table/column descriptions, synonyms, completion score) |
271
+ | `update_semantic_layer` | Improve semantic layer quality (add descriptions, synonyms, example questions) |
232
272
  </details>
233
273
 
234
274
  <details>
235
- <summary>Data & Analytics (9)</summary>
236
-
237
- - `list_dashboards` — List dashboards
238
- - `list_metrics` — List metrics
239
- - `query_metric_data` — Fetch metric data
240
- - `get_dashboard_data` — Fetch all metrics in a dashboard
241
- - `ask_ai_pilot` — Natural language data questions
242
- - `download_metric_csv` — Export metric data as CSV
243
- - `list_scheduled_reports` — List scheduled email reports
244
- - `export_dashboard` — Export a dashboard as JSON
245
- - `import_dashboard` — Import a dashboard from JSON
275
+ <summary><b>Discovery & Orchestration</b> (2)</summary>
276
+
277
+ | Tool | Description |
278
+ |------|-------------|
279
+ | `list_dashboards` | List dashboards (by data app, workspace, or globally) |
280
+ | `setup_embed_interactive` | Guided step-by-step flow for the full embed setup |
246
281
  </details>
247
282
 
248
- ### Resources (9)
283
+ ---
249
284
 
250
- - `databrain://getting-started` — Entity model and onboarding guide
251
- - `databrain://api-reference` — API endpoint reference
252
- - `databrain://embedding-guide` — Framework-specific embedding instructions
253
- - `databrain://filter-reference` — Filter types and operators
254
- - `databrain://theme-reference` — Theme customization
255
- - `databrain://web-component-reference` — Web component props
256
- - `databrain://self-serve-reference` — Self-serve analytics settings
257
- - `databrain://semantic-layer-guide` — Semantic layer for AI chat
258
- - `databrain://multi-tenancy-guide` — Multi-tenant row-level security
285
+ ## Built-in Knowledge
259
286
 
260
- ### Prompts (1)
287
+ The server includes 11 reference guides that your AI assistant can consult automatically:
261
288
 
262
- - `explore-data` — Discover available data and dashboards in your workspace
289
+ | Resource | Content |
290
+ |----------|---------|
291
+ | Getting Started | Entity model, onboarding checklist, token types |
292
+ | API Reference | All Databrain API endpoints |
293
+ | Embedding Guide | Framework-specific code (React, Next.js, Vue, Angular, Svelte, vanilla JS) |
294
+ | Theme Reference | Full theme schema — admin theme, component theme, chart appearance |
295
+ | Web Component Reference | All `<dbn-dashboard>` and `<dbn-metric>` attributes |
296
+ | Filter Reference | Filter types, operators, server-side filters |
297
+ | Self-Serve Reference | Permission flags, metric creation modes |
298
+ | Semantic Layer Guide | AI-powered metric creation setup |
299
+ | Multi-Tenancy Guide | Row-level security, clientId patterns, tenant isolation |
300
+ | Use Case Guides | Decision guide for choosing the right setup path |
301
+ | Permission Schema | Embed accessSettings, guest token permissions, precedence rules |
263
302
 
264
303
  ---
265
304
 
266
- ## For AI/LLM Developers
305
+ ## Troubleshooting
267
306
 
268
- See [`docs/LLM_INSTRUCTIONS.md`](docs/LLM_INSTRUCTIONS.md) for detailed guidance on:
269
- - Tool chaining and dependency graph
270
- - Common workflows (embed, explore, theme, filters, i18n, AI chat, roles, export/import)
271
- - Error recovery patterns
272
- - Expected output formats
273
- - Security guardrails
307
+ ### "MISSING_SERVICE_TOKEN" error
274
308
 
275
- ---
309
+ Your service token isn't set. Check that `DATABRAIN_SERVICE_TOKEN` is in your MCP config's `env` block and restart your AI client.
310
+
311
+ ### "MISSING_API_TOKEN" error
312
+
313
+ This is normal during first-time setup. The assistant will automatically create one via `create_api_token`. If it persists, ask: *"Create an API token for my data app"*.
314
+
315
+ ### No dashboards found
316
+
317
+ This usually means no workspace was selected. Ask the assistant: *"List my workspaces and then show dashboards"*. Dashboards are scoped to workspaces.
276
318
 
277
- ## Development
319
+ ### Embed not rendering in frontend
278
320
 
321
+ 1. Check that the guest token is generated **server-side** (never expose API tokens in frontend code)
322
+ 2. Verify the embed ID and dashboard ID match
323
+ 3. Ask: *"Run a health check on my embed"* — this runs `diagnose_embed_health`
324
+
325
+ ### Theme changes not showing
326
+
327
+ After updating theme or options, existing guest tokens still carry the old config. Regenerate your guest token or reload your app.
328
+
329
+ ### Server won't start
330
+
331
+ Make sure you have Node.js 18+ installed:
279
332
  ```bash
280
- npm install
281
- npm run build # Build with tsup
282
- npm test # Run tests with vitest
283
- npm run dev # Run with tsx (development)
284
- npm run lint # Type check
333
+ node --version # Should be v18.0.0 or higher
285
334
  ```
286
335
 
287
- ### Testing with MCP Inspector
336
+ ---
337
+
338
+ ## How it works
288
339
 
289
- ```bash
290
- npx @modelcontextprotocol/inspector -- npx tsx src/index.ts
291
340
  ```
341
+ Your AI Client ←→ MCP Server ←→ Databrain API
342
+ (Claude, (this (your data,
343
+ Cursor, package) dashboards,
344
+ etc.) embeds)
345
+ ```
346
+
347
+ 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.
348
+
349
+ 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.
350
+
351
+ ---
352
+
353
+ ## Links
354
+
355
+ - [Databrain](https://usedatabrain.com) — Sign up and create dashboards
356
+ - [Databrain Docs](https://docs.usedatabrain.com) — Full platform documentation
357
+ - [MCP Protocol](https://modelcontextprotocol.io) — Learn about Model Context Protocol
292
358
 
293
359
  ---
294
360