@onmartech/metabase-ai-assistant 4.0.0

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.
Files changed (40) hide show
  1. package/.env.example +38 -0
  2. package/LICENSE +201 -0
  3. package/README.md +364 -0
  4. package/README_MCP.md +279 -0
  5. package/package.json +99 -0
  6. package/src/ai/assistant.js +982 -0
  7. package/src/cli/interactive.js +500 -0
  8. package/src/database/connection-manager.js +350 -0
  9. package/src/database/direct-client.js +686 -0
  10. package/src/index.js +162 -0
  11. package/src/mcp/handlers/actions.js +213 -0
  12. package/src/mcp/handlers/ai.js +207 -0
  13. package/src/mcp/handlers/analytics.js +1647 -0
  14. package/src/mcp/handlers/cards.js +1544 -0
  15. package/src/mcp/handlers/collections.js +244 -0
  16. package/src/mcp/handlers/dashboard.js +207 -0
  17. package/src/mcp/handlers/dashboard_direct.js +292 -0
  18. package/src/mcp/handlers/database.js +322 -0
  19. package/src/mcp/handlers/docs.js +399 -0
  20. package/src/mcp/handlers/index.js +35 -0
  21. package/src/mcp/handlers/metadata.js +190 -0
  22. package/src/mcp/handlers/questions.js +134 -0
  23. package/src/mcp/handlers/schema.js +1699 -0
  24. package/src/mcp/handlers/sql.js +559 -0
  25. package/src/mcp/handlers/users.js +251 -0
  26. package/src/mcp/job-store.js +199 -0
  27. package/src/mcp/server.js +428 -0
  28. package/src/mcp/tool-registry.js +3244 -0
  29. package/src/mcp/tool-router.js +149 -0
  30. package/src/metabase/client.js +737 -0
  31. package/src/metabase/metadata-client.js +1852 -0
  32. package/src/utils/activity-logger.js +489 -0
  33. package/src/utils/cache.js +176 -0
  34. package/src/utils/config.js +131 -0
  35. package/src/utils/definition-tables.js +938 -0
  36. package/src/utils/file-operations.js +496 -0
  37. package/src/utils/logger.js +45 -0
  38. package/src/utils/parametric-questions.js +627 -0
  39. package/src/utils/response-optimizer.js +190 -0
  40. package/src/utils/sql-sanitizer.js +97 -0
package/.env.example ADDED
@@ -0,0 +1,38 @@
1
+ # Metabase Configuration
2
+ METABASE_URL=http://localhost:3000
3
+ METABASE_USERNAME=your_username
4
+ METABASE_PASSWORD=your_password
5
+ METABASE_API_KEY=
6
+
7
+ # Database Configuration (for direct SQL execution)
8
+ DATABASE_TYPE=postgres
9
+ DATABASE_HOST=localhost
10
+ DATABASE_PORT=5432
11
+ DATABASE_NAME=your_database
12
+ DATABASE_USER=your_user
13
+ DATABASE_PASSWORD=your_password
14
+
15
+ # Metabase Metadata Database Configuration (for analytics and insights)
16
+ # This is Metabase's own application database, not your business data
17
+ MB_METADATA_ENABLED=false
18
+ MB_METADATA_ENGINE=postgres
19
+ MB_METADATA_HOST=localhost
20
+ MB_METADATA_PORT=5432
21
+ MB_METADATA_DATABASE=metabase
22
+ MB_METADATA_USER=metabase_user
23
+ MB_METADATA_PASSWORD=metabase_password
24
+ MB_METADATA_SSL=false
25
+
26
+ # AI Configuration
27
+ OPENAI_API_KEY=your_openai_key
28
+ ANTHROPIC_API_KEY=your_anthropic_key
29
+
30
+ # Security Settings
31
+ # Read-only mode blocks write operations (INSERT, UPDATE, DELETE, DROP, etc.)
32
+ # Set to 'false' to allow write operations (use with caution)
33
+ METABASE_READ_ONLY_MODE=true
34
+
35
+ # Application Settings
36
+ PORT=3001
37
+ LOG_LEVEL=info
38
+ ENVIRONMENT=development
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2024-2026 ONMARTECH LLC
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,364 @@
1
+ <div align="center">
2
+
3
+ # 🚀 Metabase AI Assistant
4
+
5
+ ### **The Most Powerful MCP Server for Metabase**
6
+
7
+ **111+ Tools** • **AI-Powered SQL** • **Enterprise Security** • **Zero Config**
8
+
9
+ [![npm version](https://img.shields.io/npm/v/metabase-ai-assistant.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/metabase-ai-assistant)
10
+ [![npm downloads](https://img.shields.io/npm/dm/metabase-ai-assistant.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/metabase-ai-assistant)
11
+ [![GitHub stars](https://img.shields.io/github/stars/enessari/metabase-ai-assistant?style=for-the-badge&logo=github)](https://github.com/enessari/metabase-ai-assistant/stargazers)
12
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge)](https://opensource.org/licenses/Apache-2.0)
13
+
14
+ [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-blueviolet.svg?style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0xMiAyTDIgN2wxMCA1IDEwLTV6Ii8+PC9zdmc+)](https://modelcontextprotocol.io/)
15
+ [![Claude](https://img.shields.io/badge/Claude-Ready-orange.svg?style=flat-square)](https://claude.ai)
16
+ [![Cursor](https://img.shields.io/badge/Cursor-Ready-green.svg?style=flat-square)](https://cursor.sh)
17
+ [![Node.js](https://img.shields.io/badge/Node.js-18+-brightgreen.svg?style=flat-square&logo=node.js)](https://nodejs.org/)
18
+
19
+ ---
20
+
21
+ **Turn your AI assistant into a Metabase power user.**
22
+ Generate SQL from natural language, create dashboards, manage users, and automate BI workflows.
23
+
24
+ [**📦 Install Now**](#-quick-start) • [**📖 Documentation**](#-available-tools) • [**🎯 Features**](#-why-this-project) • [**⭐ Star Us**](https://github.com/enessari/metabase-ai-assistant)
25
+
26
+ </div>
27
+
28
+ ---
29
+
30
+ ## ⭐ Why This Project?
31
+
32
+ > **"I analyzed every Metabase MCP server on the market. This one has 4x more tools and features than any competitor."**
33
+
34
+ | Feature | **This Project** | Other MCP Servers |
35
+ |---------|:----------------:|:-----------------:|
36
+ | **Total Tools** | **111+** ✅ | 6-30 |
37
+ | **AI SQL Generation** | ✅ | ❌ |
38
+ | **AI SQL Optimization** | ✅ | ❌ |
39
+ | **Dashboard Templates** | ✅ | ❌ |
40
+ | **User Management** | ✅ | ❌ |
41
+ | **Workspace Export/Import** | ✅ | ❌ |
42
+ | **Read-Only Security Mode** | ✅ | ✅ |
43
+ | **Response Caching** | ✅ | ✅ |
44
+ | **Activity Logging** | ✅ | ❌ |
45
+ | **Metadata Analytics** | ✅ | ❌ |
46
+ | **Parametric Questions** | ✅ | ❌ |
47
+ | **Environment Comparison** | ✅ | ❌ |
48
+
49
+ ---
50
+
51
+ ## 🚀 Quick Start
52
+
53
+ ### One-Line Install
54
+
55
+ ```bash
56
+ npx metabase-ai-assistant
57
+ ```
58
+
59
+ ### Add to Claude Desktop / Cursor
60
+
61
+ ```json
62
+ {
63
+ "mcpServers": {
64
+ "metabase": {
65
+ "command": "npx",
66
+ "args": ["-y", "metabase-ai-assistant"],
67
+ "env": {
68
+ "METABASE_URL": "https://your-metabase.com",
69
+ "METABASE_API_KEY": "mb_your_api_key"
70
+ }
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ That's it! Your AI assistant now has full Metabase superpowers. 🦸
77
+
78
+ ---
79
+
80
+ ## 🎯 What Can You Do?
81
+
82
+ ### 💬 Natural Language → SQL
83
+
84
+ ```
85
+ You: "Show me total revenue by product category for the last 30 days"
86
+ AI: Uses ai_sql_generate → Runs query → Returns formatted results
87
+ ```
88
+
89
+ ### 📊 Instant Dashboard Creation
90
+
91
+ ```
92
+ You: "Create an executive dashboard for our e-commerce sales"
93
+ AI: Uses mb_dashboard_template_executive → Creates fully configured dashboard
94
+ ```
95
+
96
+ ### 🔍 Deep Database Exploration
97
+
98
+ ```
99
+ You: "What tables are related to 'orders' and show their relationships"
100
+ AI: Uses db_relationships_detect → Returns complete ER diagram info
101
+ ```
102
+
103
+ ### 🛡️ Enterprise-Grade Security
104
+
105
+ ```
106
+ You: "DROP TABLE users"
107
+ AI: 🔒 Blocked - Read-only mode active
108
+ ```
109
+
110
+ ---
111
+
112
+ ## 🔧 Complete Tool List (111+)
113
+
114
+ <details>
115
+ <summary><b>📊 Database Operations (25 tools)</b></summary>
116
+
117
+ | Tool | Description |
118
+ |------|-------------|
119
+ | `db_list` | List all databases |
120
+ | `db_schemas` | Get schemas in a database |
121
+ | `db_tables` | Get tables with fields |
122
+ | `sql_execute` | Execute SQL queries |
123
+ | `db_table_create` | Create tables (AI-prefixed) |
124
+ | `db_view_create` | Create views |
125
+ | `db_matview_create` | Create materialized views |
126
+ | `db_index_create` | Create indexes |
127
+ | `db_vacuum_analyze` | VACUUM and ANALYZE |
128
+ | `db_query_explain` | EXPLAIN query plans |
129
+ | `db_table_stats` | Table statistics |
130
+ | `db_index_usage` | Index usage analysis |
131
+ | `db_schema_explore` | Fast schema exploration |
132
+ | `db_schema_analyze` | Deep schema analysis |
133
+ | `db_relationships_detect` | Detect foreign keys |
134
+ | ...and more |
135
+
136
+ </details>
137
+
138
+ <details>
139
+ <summary><b>🤖 AI-Powered Features (5 tools)</b></summary>
140
+
141
+ | Tool | Description |
142
+ |------|-------------|
143
+ | `ai_sql_generate` | Natural language → SQL |
144
+ | `ai_sql_optimize` | Query optimization suggestions |
145
+ | `ai_sql_explain` | Explain SQL in plain English |
146
+ | `ai_relationships_suggest` | Suggest table relationships |
147
+ | `mb_auto_describe` | Auto-generate descriptions |
148
+
149
+ </details>
150
+
151
+ <details>
152
+ <summary><b>📋 Question/Card Management (12 tools)</b></summary>
153
+
154
+ | Tool | Description |
155
+ |------|-------------|
156
+ | `mb_question_create` | Create new questions |
157
+ | `mb_questions` | List all questions |
158
+ | `mb_question_create_parametric` | Parametric questions |
159
+ | `mb_card_get` | Get card details |
160
+ | `mb_card_update` | Update cards |
161
+ | `mb_card_delete` | Delete cards |
162
+ | `mb_card_archive` | Archive cards |
163
+ | `mb_card_data` | Get card data as JSON |
164
+ | `mb_card_copy` | Copy cards |
165
+ | `mb_card_clone` | Clone cards |
166
+ | ...and more |
167
+
168
+ </details>
169
+
170
+ <details>
171
+ <summary><b>📈 Dashboard Management (14 tools)</b></summary>
172
+
173
+ | Tool | Description |
174
+ |------|-------------|
175
+ | `mb_dashboard_create` | Create dashboards |
176
+ | `mb_dashboards` | List all dashboards |
177
+ | `mb_dashboard_get` | Get dashboard details |
178
+ | `mb_dashboard_update` | Update dashboards |
179
+ | `mb_dashboard_delete` | Delete dashboards |
180
+ | `mb_dashboard_add_card` | Add cards to dashboard |
181
+ | `mb_dashboard_add_filter` | Add filters |
182
+ | `mb_dashboard_layout_optimize` | Optimize layout |
183
+ | `mb_dashboard_template_executive` | Executive templates |
184
+ | ...and more |
185
+
186
+ </details>
187
+
188
+ <details>
189
+ <summary><b>👥 User & Permission Management (10 tools)</b></summary>
190
+
191
+ | Tool | Description |
192
+ |------|-------------|
193
+ | `mb_user_list` | List users |
194
+ | `mb_user_get` | Get user details |
195
+ | `mb_user_create` | Create users |
196
+ | `mb_user_update` | Update users |
197
+ | `mb_user_disable` | Disable users |
198
+ | `mb_permission_group_list` | List groups |
199
+ | `mb_permission_group_create` | Create groups |
200
+ | ...and more |
201
+
202
+ </details>
203
+
204
+ <details>
205
+ <summary><b>📊 Metadata Analytics (14 tools)</b></summary>
206
+
207
+ | Tool | Description |
208
+ |------|-------------|
209
+ | `mb_meta_overview` | Instance health check |
210
+ | `mb_meta_query_performance` | Query analytics |
211
+ | `mb_meta_content_usage` | Content usage stats |
212
+ | `mb_meta_user_activity` | User activity |
213
+ | `mb_meta_table_dependencies` | Table dependencies |
214
+ | `mb_meta_impact_analysis` | Breaking change analysis |
215
+ | `mb_meta_optimization_recommendations` | Index suggestions |
216
+ | `mb_meta_export_workspace` | Backup to JSON |
217
+ | `mb_meta_import_preview` | Import dry-run |
218
+ | `mb_meta_compare_environments` | Dev vs Prod diff |
219
+ | `mb_meta_auto_cleanup` | Safe cleanup |
220
+ | ...and more |
221
+
222
+ </details>
223
+
224
+ ---
225
+
226
+ ## 🛡️ Security Features
227
+
228
+ | Feature | Description |
229
+ |---------|-------------|
230
+ | **🔒 Read-Only Mode** | Blocks INSERT, UPDATE, DELETE, DROP (default: enabled) |
231
+ | **🏷️ AI Prefix** | All AI-created objects use `claude_ai_` prefix |
232
+ | **✅ Explicit Approval** | Destructive operations require confirmation |
233
+ | **📝 Activity Logging** | Full audit trail of all operations |
234
+ | **🔐 Env Validation** | Zod-validated environment variables |
235
+ | **💾 Auto-Backup** | Prompts for backup before destructive ops |
236
+
237
+ ```bash
238
+ # Enable/disable read-only mode
239
+ METABASE_READ_ONLY_MODE=true # Default: blocks write ops
240
+ METABASE_READ_ONLY_MODE=false # Allow write operations
241
+ ```
242
+
243
+ ---
244
+
245
+ ## ⚙️ Configuration
246
+
247
+ Create a `.env` file:
248
+
249
+ ```bash
250
+ # Required
251
+ METABASE_URL=https://your-metabase.com
252
+ METABASE_API_KEY=mb_your_api_key
253
+
254
+ # Or use username/password
255
+ # METABASE_USERNAME=admin@example.com
256
+ # METABASE_PASSWORD=your_password
257
+
258
+ # Security (defaults to true)
259
+ METABASE_READ_ONLY_MODE=true
260
+
261
+ # AI Features (optional)
262
+ ANTHROPIC_API_KEY=sk-ant-...
263
+ OPENAI_API_KEY=sk-...
264
+
265
+ # Performance (optional)
266
+ CACHE_TTL_MS=600000 # 10 minutes
267
+ ```
268
+
269
+ ---
270
+
271
+ ## 📦 Installation Options
272
+
273
+ ### npm (Recommended)
274
+
275
+ ```bash
276
+ npm install -g metabase-ai-assistant
277
+ ```
278
+
279
+ ### Docker
280
+
281
+ ```bash
282
+ docker run -e METABASE_URL=... -e METABASE_API_KEY=... ghcr.io/enessari/metabase-ai-assistant
283
+ ```
284
+
285
+ ### From Source
286
+
287
+ ```bash
288
+ git clone https://github.com/enessari/metabase-ai-assistant.git
289
+ cd metabase-ai-assistant
290
+ npm install
291
+ npm run mcp
292
+ ```
293
+
294
+ ---
295
+
296
+ ## 🏗️ Architecture
297
+
298
+ ```
299
+ metabase-ai-assistant/
300
+ ├── src/
301
+ │ ├── mcp/
302
+ │ │ ├── server.js # Main MCP server (111+ tools)
303
+ │ │ └── handlers/ # Modular handlers
304
+ │ │ ├── database.js # DB operations
305
+ │ │ ├── dashboard.js # Dashboard ops
306
+ │ │ ├── questions.js # Question ops
307
+ │ │ └── ai.js # AI features
308
+ │ ├── utils/
309
+ │ │ ├── cache.js # TTL-based caching
310
+ │ │ ├── config.js # Zod validation
311
+ │ │ └── response-optimizer.js
312
+ │ └── metabase/
313
+ │ └── client.js # Metabase API client
314
+ ```
315
+
316
+ ---
317
+
318
+ ## 🤝 Contributing
319
+
320
+ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
321
+
322
+ ```bash
323
+ # Fork, clone, install
324
+ git clone https://github.com/YOUR_USERNAME/metabase-ai-assistant.git
325
+ npm install
326
+
327
+ # Create feature branch
328
+ git checkout -b feature/amazing-feature
329
+
330
+ # Test and submit PR
331
+ npm test
332
+ git push origin feature/amazing-feature
333
+ ```
334
+
335
+ ---
336
+
337
+ ## 📚 Resources
338
+
339
+ - [📖 Full Documentation](https://github.com/enessari/metabase-ai-assistant/wiki)
340
+ - [🐛 Report Issues](https://github.com/enessari/metabase-ai-assistant/issues)
341
+ - [💬 Discussions](https://github.com/enessari/metabase-ai-assistant/discussions)
342
+ - [📦 npm Package](https://www.npmjs.com/package/metabase-ai-assistant)
343
+
344
+ ---
345
+
346
+ ## 📄 License
347
+
348
+ Apache License 2.0 - see [LICENSE](LICENSE)
349
+
350
+ ---
351
+
352
+ <div align="center">
353
+
354
+ ### ⭐ Star this repo if it helps you!
355
+
356
+ **Built with ❤️ by [Abdullah Enes SARI](https://github.com/enessari) @ [ONMARTECH LLC](https://onmartech.com)**
357
+
358
+ [![Star History](https://img.shields.io/github/stars/enessari/metabase-ai-assistant?style=social)](https://github.com/enessari/metabase-ai-assistant/stargazers)
359
+
360
+ ---
361
+
362
+ **Keywords:** Metabase MCP Server, Model Context Protocol, AI SQL Generation, Business Intelligence, Claude AI, Cursor AI, Natural Language SQL, Dashboard Automation, PostgreSQL, Data Analytics, LLM Tools
363
+
364
+ </div>