@dbx-app/mcp-server 0.4.34 → 0.4.37
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 +417 -176
- package/package.json +10 -16
- package/server.json +2 -2
package/README.md
CHANGED
|
@@ -1,65 +1,204 @@
|
|
|
1
1
|
# DBX MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Rust-powered Model Context Protocol server for [DBX](https://github.com/t8y2/dbx). It lets MCP-compatible AI agents inspect schemas and run safe database operations using connections configured in DBX.
|
|
4
4
|
|
|
5
|
-
[
|
|
5
|
+
[中文说明](#中文说明) | [npm](https://www.npmjs.com/package/@dbx-app/mcp-server) | [Native releases](https://github.com/t8y2/dbx/releases?q=packages-v)
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
@dbx-app/mcp-server
|
|
11
|
+
└── small Node.js launcher
|
|
12
|
+
└── platform-specific Rust dbx-mcp binary
|
|
13
|
+
└── dbx-core database and agent infrastructure
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The MCP protocol, connection loading, SQL safety, schema access, Redis support, MongoDB shell parsing, Web backend access, and database execution are implemented in Rust. Node.js is used only by the npm launcher so existing `npm`, `npx`, and MCP client configurations continue to work.
|
|
6
17
|
|
|
7
18
|
## Features
|
|
8
19
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
20
|
+
- **10 MCP tools** for connections, schemas, SQL, Redis, and DBX UI integration
|
|
21
|
+
- **Precompiled native binaries** with no local Rust, Cargo, Python, or C/C++ build requirement
|
|
22
|
+
- **No `better-sqlite3` runtime dependency** and no Node native-addon ABI coupling
|
|
23
|
+
- **Local, Web, and Docker modes** using the same tool interface
|
|
24
|
+
- **Direct native execution** for supported SQL, Redis, and MongoDB connections
|
|
25
|
+
- **Agent/JDBC database support** through DBX agent infrastructure when the required agent and JRE are installed
|
|
26
|
+
- **SQL safety controls** for writes, destructive SQL, Redis commands, and MongoDB mutations
|
|
27
|
+
- **Connection scoping** for limiting an MCP server to one connection or database
|
|
28
|
+
- **Offline execution** through downloadable native binaries
|
|
29
|
+
- **Optional desktop integration** for opening tables and displaying query results in DBX
|
|
15
30
|
|
|
16
|
-
##
|
|
31
|
+
## Installation
|
|
17
32
|
|
|
18
|
-
###
|
|
33
|
+
### npm global install
|
|
19
34
|
|
|
20
35
|
```bash
|
|
21
36
|
npm install -g @dbx-app/mcp-server
|
|
22
37
|
```
|
|
23
38
|
|
|
24
|
-
|
|
39
|
+
Then configure the MCP client to run:
|
|
25
40
|
|
|
26
|
-
```
|
|
27
|
-
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"mcpServers": {
|
|
44
|
+
"dbx": {
|
|
45
|
+
"command": "dbx-mcp-server"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
28
49
|
```
|
|
29
50
|
|
|
30
|
-
|
|
51
|
+
### npx
|
|
52
|
+
|
|
53
|
+
No global installation is required:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"mcpServers": {
|
|
58
|
+
"dbx": {
|
|
59
|
+
"command": "npx",
|
|
60
|
+
"args": ["-y", "@dbx-app/mcp-server"]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The npm package automatically installs the native package matching the current operating system and CPU. Do not install with `--no-optional`, because npm optional dependencies carry the platform binary.
|
|
67
|
+
|
|
68
|
+
### Native binary / offline install
|
|
31
69
|
|
|
32
|
-
|
|
70
|
+
Every package release publishes native archives and `SHA256SUMS` in [GitHub Releases](https://github.com/t8y2/dbx/releases?q=packages-v):
|
|
33
71
|
|
|
34
|
-
|
|
72
|
+
| Platform | Release asset | npm platform package |
|
|
73
|
+
| --- | --- | --- |
|
|
74
|
+
| macOS Apple Silicon | `dbx-mcp-darwin-arm64.tar.gz` | `@dbx-app/mcp-darwin-arm64` |
|
|
75
|
+
| macOS Intel | `dbx-mcp-darwin-x64.tar.gz` | `@dbx-app/mcp-darwin-x64` |
|
|
76
|
+
| Linux glibc ARM64 | `dbx-mcp-linux-arm64-gnu.tar.gz` | `@dbx-app/mcp-linux-arm64-gnu` |
|
|
77
|
+
| Linux glibc x64 | `dbx-mcp-linux-x64-gnu.tar.gz` | `@dbx-app/mcp-linux-x64-gnu` |
|
|
78
|
+
| Windows ARM64 | `dbx-mcp-win32-arm64.zip` | `@dbx-app/mcp-win32-arm64` |
|
|
79
|
+
| Windows x64 | `dbx-mcp-win32-x64.zip` | `@dbx-app/mcp-win32-x64` |
|
|
80
|
+
|
|
81
|
+
Verify a Unix archive before extracting it:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
sha256sum --check SHA256SUMS
|
|
85
|
+
tar -xzf dbx-mcp-linux-x64-gnu.tar.gz
|
|
86
|
+
chmod +x dbx-mcp
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
On macOS, use `shasum -a 256` if `sha256sum` is unavailable. On Windows, use `certutil -hashfile <archive> SHA256` and compare the value with `SHA256SUMS`.
|
|
90
|
+
|
|
91
|
+
Configure the MCP client to run the extracted file directly:
|
|
35
92
|
|
|
36
93
|
```json
|
|
37
94
|
{
|
|
38
95
|
"mcpServers": {
|
|
39
96
|
"dbx": {
|
|
40
|
-
"command": "/path/to/dbx-mcp"
|
|
97
|
+
"command": "/absolute/path/to/dbx-mcp"
|
|
41
98
|
}
|
|
42
99
|
}
|
|
43
100
|
}
|
|
44
101
|
```
|
|
45
102
|
|
|
46
|
-
|
|
103
|
+
Direct native execution does not require Node.js. GitHub package releases are intentionally not marked as the repository's latest release, so they do not replace the latest DBX desktop release.
|
|
104
|
+
|
|
105
|
+
## Requirements
|
|
106
|
+
|
|
107
|
+
### npm installation
|
|
108
|
+
|
|
109
|
+
- Node.js 18.18.0 or newer
|
|
110
|
+
- A supported operating system and CPU from the platform table
|
|
111
|
+
- npm optional dependencies enabled
|
|
112
|
+
|
|
113
|
+
### Native installation
|
|
114
|
+
|
|
115
|
+
- No Node.js or npm requirement
|
|
116
|
+
- Linux builds currently require glibc; Alpine/musl is not supported yet
|
|
117
|
+
|
|
118
|
+
### Database configuration
|
|
119
|
+
|
|
120
|
+
DBX MCP reads connection profiles from DBX storage. DBX does not need to remain open for native connections. However:
|
|
121
|
+
|
|
122
|
+
- the connection must already exist in DBX storage, unless it is added through `dbx_add_connection`;
|
|
123
|
+
- DBX Agent/JDBC databases require the matching agent, JDBC driver, and JRE to be installed;
|
|
124
|
+
- `dbx_open_table` and `dbx_execute_and_show` require a running DBX desktop application;
|
|
125
|
+
- DBX Web mode requires a reachable DBX Web server.
|
|
126
|
+
|
|
127
|
+
## Usage Examples
|
|
128
|
+
|
|
129
|
+
Ask the MCP client to:
|
|
130
|
+
|
|
131
|
+
- "List my DBX connections"
|
|
132
|
+
- "Show tables in the production PostgreSQL connection"
|
|
133
|
+
- "Describe the `orders` table"
|
|
134
|
+
- "Build schema context for the billing database"
|
|
135
|
+
- "Count orders created in the last seven days"
|
|
136
|
+
- "Run `INFO memory` on the Redis connection"
|
|
137
|
+
- "Find the latest MongoDB documents in the events collection"
|
|
138
|
+
- "Open the orders table in DBX"
|
|
139
|
+
|
|
140
|
+
## Tools
|
|
141
|
+
|
|
142
|
+
| Tool | Description |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| `dbx_list_connections` | List connections visible to the MCP session |
|
|
145
|
+
| `dbx_add_connection` | Add a connection to local DBX storage |
|
|
146
|
+
| `dbx_remove_connection` | Remove a connection from local DBX storage |
|
|
147
|
+
| `dbx_list_tables` | List tables, views, or collections |
|
|
148
|
+
| `dbx_describe_table` | Return columns and table metadata |
|
|
149
|
+
| `dbx_get_schema_context` | Return compact schema context suitable for an AI model |
|
|
150
|
+
| `dbx_execute_query` | Execute SQL or a supported MongoDB shell command, returning at most 100 rows |
|
|
151
|
+
| `dbx_execute_redis_command` | Execute a Redis command |
|
|
152
|
+
| `dbx_open_table` | Open a table in the running DBX desktop application |
|
|
153
|
+
| `dbx_execute_and_show` | Execute a query and display the result in the DBX desktop application |
|
|
154
|
+
|
|
155
|
+
When connection scoping is enabled, mutating connection tools and desktop UI tools are hidden.
|
|
156
|
+
|
|
157
|
+
## Execution Modes
|
|
158
|
+
|
|
159
|
+
### Local native mode
|
|
47
160
|
|
|
48
|
-
|
|
161
|
+
This is the default. MCP reads DBX connection storage and executes supported connections locally in the Rust process.
|
|
49
162
|
|
|
50
|
-
|
|
163
|
+
Common native paths include PostgreSQL, MySQL, SQLite, compatible SQL databases, Redis standalone, and MongoDB. SSH, cluster, vendor-specific, or Agent/JDBC connections may require additional DBX infrastructure.
|
|
164
|
+
|
|
165
|
+
DBX connection storage defaults to:
|
|
166
|
+
|
|
167
|
+
- macOS: `~/Library/Application Support/com.dbx.app/dbx.db`
|
|
168
|
+
- Linux: `~/.local/share/com.dbx.app/dbx.db`
|
|
169
|
+
- Windows: `%APPDATA%\com.dbx.app\dbx.db`
|
|
170
|
+
|
|
171
|
+
Override the directory with `DBX_DATA_DIR`.
|
|
172
|
+
|
|
173
|
+
### Agent/JDBC databases
|
|
174
|
+
|
|
175
|
+
Databases such as Dameng, Kingbase, Oracle, DB2, Hive, Trino, Snowflake, SAP HANA, and other DBX Agent profiles use DBX's Java agent infrastructure rather than a Node.js database driver.
|
|
176
|
+
|
|
177
|
+
The native npm/GitHub binary does not bundle every proprietary JDBC driver or JRE. Install the database agent through DBX first, or provide a compatible agent installation under the DBX agent directory. Availability depends on the installed driver and license terms of the database vendor.
|
|
178
|
+
|
|
179
|
+
### DBX Web / Docker mode
|
|
180
|
+
|
|
181
|
+
Set `DBX_WEB_URL` to use a deployed DBX Web backend instead of local desktop storage:
|
|
51
182
|
|
|
52
183
|
```json
|
|
53
184
|
{
|
|
54
185
|
"mcpServers": {
|
|
55
186
|
"dbx": {
|
|
56
|
-
"command": "dbx-mcp-server"
|
|
187
|
+
"command": "dbx-mcp-server",
|
|
188
|
+
"env": {
|
|
189
|
+
"DBX_WEB_URL": "https://dbx.example.com",
|
|
190
|
+
"DBX_WEB_PASSWORD": "your-web-login-password"
|
|
191
|
+
}
|
|
57
192
|
}
|
|
58
193
|
}
|
|
59
194
|
}
|
|
60
195
|
```
|
|
61
196
|
|
|
62
|
-
|
|
197
|
+
`DBX_WEB_PASSWORD` is the password used on the DBX Web login page. Desktop-local mode does not use it. Desktop UI tools are hidden in Web mode.
|
|
198
|
+
|
|
199
|
+
### Windows portable DBX
|
|
200
|
+
|
|
201
|
+
Point `DBX_DATA_DIR` at the portable `data` directory containing `dbx.db`:
|
|
63
202
|
|
|
64
203
|
```json
|
|
65
204
|
{
|
|
@@ -74,125 +213,135 @@ For Windows portable builds, set `DBX_DATA_DIR` to the portable data directory t
|
|
|
74
213
|
}
|
|
75
214
|
```
|
|
76
215
|
|
|
77
|
-
|
|
216
|
+
## Connection Scoping
|
|
217
|
+
|
|
218
|
+
Restrict one MCP server to a connection or database:
|
|
78
219
|
|
|
79
220
|
```json
|
|
80
221
|
{
|
|
81
222
|
"mcpServers": {
|
|
82
|
-
"dbx": {
|
|
83
|
-
"command": "
|
|
84
|
-
"
|
|
85
|
-
|
|
223
|
+
"dbx-production-readonly": {
|
|
224
|
+
"command": "dbx-mcp-server",
|
|
225
|
+
"env": {
|
|
226
|
+
"DBX_MCP_SCOPE_CONNECTION_NAME": "production-postgres",
|
|
227
|
+
"DBX_MCP_SCOPE_DATABASE": "analytics",
|
|
228
|
+
"DBX_MCP_ALLOW_WRITES": "0"
|
|
229
|
+
}
|
|
86
230
|
}
|
|
87
231
|
}
|
|
88
232
|
}
|
|
89
233
|
```
|
|
90
234
|
|
|
91
|
-
|
|
235
|
+
Use either `DBX_MCP_SCOPE_CONNECTION_ID` or `DBX_MCP_SCOPE_CONNECTION_NAME`. The scoped database is optional.
|
|
92
236
|
|
|
93
|
-
|
|
237
|
+
## Safety
|
|
94
238
|
|
|
95
|
-
|
|
96
|
-
- "Show the tables in my local-pg connection"
|
|
97
|
-
- "Describe the users table"
|
|
98
|
-
- "Query the average salary from employees"
|
|
99
|
-
- "Open the orders table in DBX"
|
|
239
|
+
Regular writes are enabled by default. Force a read-only session with:
|
|
100
240
|
|
|
101
|
-
|
|
241
|
+
```bash
|
|
242
|
+
DBX_MCP_ALLOW_WRITES=0
|
|
243
|
+
```
|
|
102
244
|
|
|
103
|
-
|
|
245
|
+
Dangerous operations such as `DROP`, `TRUNCATE`, `ALTER`, Redis `FLUSHALL`, or dangerous MongoDB mutations remain blocked unless explicitly enabled:
|
|
104
246
|
|
|
105
247
|
```bash
|
|
106
|
-
|
|
107
|
-
dbx connections list --json
|
|
108
|
-
dbx query local "select 1" --json
|
|
248
|
+
DBX_MCP_ALLOW_DANGEROUS_SQL=1
|
|
109
249
|
```
|
|
110
250
|
|
|
111
|
-
|
|
251
|
+
MongoDB update/delete operations require a non-empty filter unless dangerous operations are enabled. Aggregation stages such as `$out` and `$merge` are treated as writes.
|
|
112
252
|
|
|
113
|
-
|
|
253
|
+
SQL text is not included in normal MCP errors or logged by default. Enable temporary diagnostics with `DBX_MCP_DEBUG_SQL=1` and disable it after troubleshooting.
|
|
114
254
|
|
|
115
|
-
|
|
116
|
-
| --------------------------- | ---------------------------------------------------- |
|
|
117
|
-
| `dbx_list_connections` | List all database connections configured in DBX |
|
|
118
|
-
| `dbx_add_connection` | Add a new database connection |
|
|
119
|
-
| `dbx_remove_connection` | Remove a database connection |
|
|
120
|
-
| `dbx_list_tables` | List tables and views for a connection |
|
|
121
|
-
| `dbx_describe_table` | Get column definitions for a table |
|
|
122
|
-
| `dbx_get_schema_context` | Get compact table and column context for writing SQL |
|
|
123
|
-
| `dbx_execute_query` | Execute a SQL query (max 100 rows) |
|
|
124
|
-
| `dbx_execute_redis_command` | Execute a Redis command on a Redis connection |
|
|
125
|
-
| `dbx_open_table` | Open a table in DBX desktop app UI |
|
|
255
|
+
## Environment Variables
|
|
126
256
|
|
|
127
|
-
|
|
257
|
+
| Variable | Purpose |
|
|
258
|
+
| --- | --- |
|
|
259
|
+
| `DBX_DATA_DIR` | Override the local DBX data directory |
|
|
260
|
+
| `DBX_WEB_URL` | Use a DBX Web/Docker backend |
|
|
261
|
+
| `DBX_WEB_PASSWORD` | Authenticate to the DBX Web backend |
|
|
262
|
+
| `DBX_MCP_ALLOW_WRITES` | Set to `0` to force read-only execution |
|
|
263
|
+
| `DBX_MCP_ALLOW_DANGEROUS_SQL` | Set to `1` to allow dangerous SQL, Redis, and MongoDB operations |
|
|
264
|
+
| `DBX_MCP_SCOPE_CONNECTION_ID` | Restrict tools to one connection ID |
|
|
265
|
+
| `DBX_MCP_SCOPE_CONNECTION_NAME` | Restrict tools to one connection name |
|
|
266
|
+
| `DBX_MCP_SCOPE_DATABASE` | Restrict tools to one database |
|
|
267
|
+
| `DBX_MCP_DEBUG_SQL` | Include SQL in temporary diagnostics |
|
|
268
|
+
| `DBX_MCP_BINARY` | Override the native binary used by the npm launcher |
|
|
128
269
|
|
|
129
|
-
|
|
270
|
+
## Troubleshooting
|
|
130
271
|
|
|
131
|
-
|
|
272
|
+
### Optional platform package was not installed
|
|
273
|
+
|
|
274
|
+
Reinstall without `--no-optional`:
|
|
132
275
|
|
|
133
276
|
```bash
|
|
134
|
-
|
|
277
|
+
npm uninstall -g @dbx-app/mcp-server
|
|
278
|
+
npm install -g @dbx-app/mcp-server@latest
|
|
135
279
|
```
|
|
136
280
|
|
|
137
|
-
|
|
281
|
+
Verify the current Node platform:
|
|
138
282
|
|
|
139
283
|
```bash
|
|
140
|
-
|
|
284
|
+
node -p 'process.platform + "-" + process.arch'
|
|
141
285
|
```
|
|
142
286
|
|
|
143
|
-
|
|
287
|
+
### Unsupported Linux distribution
|
|
144
288
|
|
|
145
|
-
|
|
289
|
+
The published Linux packages target glibc. Alpine Linux uses musl by default and is not currently supported.
|
|
146
290
|
|
|
147
|
-
|
|
291
|
+
### `dbx.db` cannot be found
|
|
148
292
|
|
|
149
|
-
|
|
293
|
+
Set `DBX_DATA_DIR` to the directory containing `dbx.db`, not to the database file itself.
|
|
150
294
|
|
|
151
|
-
|
|
152
|
-
AI Agent → MCP Server → Database
|
|
153
|
-
↓
|
|
154
|
-
DBX SQLite database (dbx.db)
|
|
155
|
-
```
|
|
295
|
+
### Desktop action says DBX is not running
|
|
156
296
|
|
|
157
|
-
|
|
297
|
+
Database queries can run without the desktop application when the connection is supported locally. `dbx_open_table` and `dbx_execute_and_show` intentionally require DBX desktop to be running.
|
|
158
298
|
|
|
159
|
-
|
|
160
|
-
- **Linux**: `~/.local/share/com.dbx.app/dbx.db`
|
|
161
|
-
- **Windows**: `%APPDATA%\com.dbx.app\dbx.db`
|
|
299
|
+
### Agent/JDBC database cannot start
|
|
162
300
|
|
|
163
|
-
|
|
301
|
+
Open DBX Driver Manager and install/update the matching database agent and JRE. The standalone MCP binary does not redistribute every proprietary JDBC driver.
|
|
164
302
|
|
|
165
|
-
|
|
303
|
+
### `better-sqlite3` or Node ABI error
|
|
166
304
|
|
|
167
|
-
|
|
305
|
+
The Rust MCP runtime does not depend on `better-sqlite3`. This error normally indicates an older MCP version or the separate TypeScript-based `@dbx-app/cli` package. Upgrade MCP with:
|
|
168
306
|
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
"mcpServers": {
|
|
172
|
-
"dbx": {
|
|
173
|
-
"command": "dbx-mcp-server",
|
|
174
|
-
"env": {
|
|
175
|
-
"DBX_WEB_URL": "https://dbx.example.com",
|
|
176
|
-
"DBX_WEB_PASSWORD": "your-web-password"
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
307
|
+
```bash
|
|
308
|
+
npm install -g @dbx-app/mcp-server@latest
|
|
181
309
|
```
|
|
182
310
|
|
|
183
|
-
|
|
311
|
+
## Development
|
|
184
312
|
|
|
185
|
-
|
|
313
|
+
Run the Rust server from source:
|
|
186
314
|
|
|
187
|
-
|
|
315
|
+
```bash
|
|
316
|
+
cargo run -p dbx-mcp --no-default-features
|
|
317
|
+
```
|
|
188
318
|
|
|
189
|
-
|
|
319
|
+
Run tests:
|
|
190
320
|
|
|
191
|
-
|
|
321
|
+
```bash
|
|
322
|
+
cargo test -p dbx-mcp --no-default-features
|
|
323
|
+
pnpm --filter @dbx-app/mcp-server test
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Build a release binary:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
cargo build --release -p dbx-mcp --no-default-features
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
The previous TypeScript MCP implementation remains in `packages/mcp-server/src` for migration tests and compatibility reference; it is not the npm runtime entrypoint.
|
|
333
|
+
|
|
334
|
+
## DBX CLI
|
|
335
|
+
|
|
336
|
+
`@dbx-app/cli` is a separate terminal-oriented package and currently remains TypeScript/Node.js based:
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
npm install -g @dbx-app/cli
|
|
340
|
+
dbx connections list --json
|
|
341
|
+
dbx query local "select 1" --json
|
|
342
|
+
```
|
|
192
343
|
|
|
193
|
-
|
|
194
|
-
- Node.js 18.18.0 or newer (only used by the npm launcher)
|
|
195
|
-
- Rust, Cargo, Python, and native build tools are not required
|
|
344
|
+
See the [CLI README](../cli/README.md).
|
|
196
345
|
|
|
197
346
|
## License
|
|
198
347
|
|
|
@@ -202,34 +351,39 @@ Apache-2.0
|
|
|
202
351
|
|
|
203
352
|
## 中文说明
|
|
204
353
|
|
|
205
|
-
[DBX](https://github.com/t8y2/dbx) 的 MCP
|
|
354
|
+
DBX MCP Server 是 [DBX](https://github.com/t8y2/dbx) 的 Rust MCP 服务,让 Claude Code、Cursor、Windsurf 等兼容 MCP 的 AI 工具使用 DBX 中已有的连接查询数据库。
|
|
206
355
|
|
|
207
|
-
|
|
356
|
+
[npm](https://www.npmjs.com/package/@dbx-app/mcp-server) | [原生版本下载](https://github.com/t8y2/dbx/releases?q=packages-v)
|
|
208
357
|
|
|
209
|
-
|
|
210
|
-
- **9 个工具** — 列出/添加/删除连接、列出表、查看表结构、获取 Schema 上下文、执行 SQL、执行 Redis 命令、在 DBX 中打开表
|
|
211
|
-
- **连接池** — 跨查询复用数据库连接
|
|
212
|
-
- **直接执行** — PostgreSQL、MySQL、SQLite 及兼容数据库(Doris、StarRocks 等)无需打开 DBX 即可查询
|
|
213
|
-
- **默认允许常规写入** — `INSERT` / `UPDATE` / `DELETE` 可直接执行,危险语句仍需显式开启
|
|
214
|
-
- **DBX UI 联动** — 从 AI 助手直接在 DBX 桌面端打开表
|
|
358
|
+
### 架构
|
|
215
359
|
|
|
216
|
-
|
|
360
|
+
```text
|
|
361
|
+
@dbx-app/mcp-server
|
|
362
|
+
└── 轻量 Node.js 启动器
|
|
363
|
+
└── 当前平台的 Rust dbx-mcp 二进制
|
|
364
|
+
└── dbx-core 数据库和 Agent 基础设施
|
|
365
|
+
```
|
|
217
366
|
|
|
218
|
-
|
|
367
|
+
MCP 协议、连接读取、SQL 安全检查、Schema、Redis、MongoDB、Web 后端和数据库执行均由 Rust 实现。Node.js 只用于保持原有 npm/npx 安装入口不变。
|
|
219
368
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
369
|
+
### 主要能力
|
|
370
|
+
|
|
371
|
+
- 10 个 MCP 工具
|
|
372
|
+
- 不依赖 `better-sqlite3`,没有 Node 原生模块 ABI 问题
|
|
373
|
+
- 支持本地 DBX、DBX Web 和 Docker
|
|
374
|
+
- 支持预编译原生二进制和离线运行
|
|
375
|
+
- 支持常见 SQL、Redis、MongoDB 直连
|
|
376
|
+
- 支持达梦、金仓、Oracle、DB2、Hive 等 Agent/JDBC 数据库
|
|
377
|
+
- 支持只读、危险操作、连接和数据库作用域限制
|
|
378
|
+
- DBX 桌面端未启动时仍可执行支持本地运行的连接
|
|
223
379
|
|
|
224
|
-
|
|
380
|
+
### npm 安装
|
|
225
381
|
|
|
226
382
|
```bash
|
|
227
|
-
|
|
383
|
+
npm install -g @dbx-app/mcp-server
|
|
228
384
|
```
|
|
229
385
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
在项目的 `.mcp.json` 中添加:
|
|
386
|
+
MCP 配置:
|
|
233
387
|
|
|
234
388
|
```json
|
|
235
389
|
{
|
|
@@ -241,115 +395,202 @@ npx @dbx-app/mcp-server
|
|
|
241
395
|
}
|
|
242
396
|
```
|
|
243
397
|
|
|
244
|
-
|
|
398
|
+
也可以直接使用 npx:
|
|
245
399
|
|
|
246
400
|
```json
|
|
247
401
|
{
|
|
248
402
|
"mcpServers": {
|
|
249
403
|
"dbx": {
|
|
250
|
-
"command": "
|
|
251
|
-
"
|
|
252
|
-
"DBX_DATA_DIR": "D:\\DBX_x64-portable\\data"
|
|
253
|
-
}
|
|
404
|
+
"command": "npx",
|
|
405
|
+
"args": ["-y", "@dbx-app/mcp-server"]
|
|
254
406
|
}
|
|
255
407
|
}
|
|
256
408
|
}
|
|
257
409
|
```
|
|
258
410
|
|
|
259
|
-
|
|
411
|
+
不要使用 `--no-optional`,平台二进制通过 npm `optionalDependencies` 自动安装。
|
|
260
412
|
|
|
261
|
-
|
|
413
|
+
### 原生二进制和离线安装
|
|
262
414
|
|
|
263
|
-
-
|
|
264
|
-
- "查看 local-pg 上有哪些表"
|
|
265
|
-
- "查看 users 表的结构"
|
|
266
|
-
- "查询最近 7 天的订单数量"
|
|
267
|
-
- "打开 orders 表"
|
|
415
|
+
每个 packages 版本会在 [GitHub Releases](https://github.com/t8y2/dbx/releases?q=packages-v) 发布以下文件:
|
|
268
416
|
|
|
269
|
-
|
|
417
|
+
| 平台 | 文件 |
|
|
418
|
+
| --- | --- |
|
|
419
|
+
| macOS Apple Silicon | `dbx-mcp-darwin-arm64.tar.gz` |
|
|
420
|
+
| macOS Intel | `dbx-mcp-darwin-x64.tar.gz` |
|
|
421
|
+
| Linux glibc ARM64 | `dbx-mcp-linux-arm64-gnu.tar.gz` |
|
|
422
|
+
| Linux glibc x64 | `dbx-mcp-linux-x64-gnu.tar.gz` |
|
|
423
|
+
| Windows ARM64 | `dbx-mcp-win32-arm64.zip` |
|
|
424
|
+
| Windows x64 | `dbx-mcp-win32-x64.zip` |
|
|
270
425
|
|
|
271
|
-
|
|
426
|
+
下载后使用 `SHA256SUMS` 校验,并直接配置:
|
|
272
427
|
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
dbx
|
|
428
|
+
```json
|
|
429
|
+
{
|
|
430
|
+
"mcpServers": {
|
|
431
|
+
"dbx": {
|
|
432
|
+
"command": "/绝对路径/dbx-mcp"
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
277
436
|
```
|
|
278
437
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
### 工具列表
|
|
438
|
+
直接运行原生文件不需要 Node.js。Linux 当前只支持 glibc,暂不支持 Alpine/musl。
|
|
282
439
|
|
|
283
|
-
|
|
284
|
-
| --------------------------- | ------------------------------------- |
|
|
285
|
-
| `dbx_list_connections` | 列出 DBX 中所有已配置的数据库连接 |
|
|
286
|
-
| `dbx_add_connection` | 添加新的数据库连接 |
|
|
287
|
-
| `dbx_remove_connection` | 删除数据库连接 |
|
|
288
|
-
| `dbx_list_tables` | 列出指定连接的表和视图 |
|
|
289
|
-
| `dbx_describe_table` | 获取表的列定义 |
|
|
290
|
-
| `dbx_get_schema_context` | 获取适合 AI 写 SQL 的紧凑表结构上下文 |
|
|
291
|
-
| `dbx_execute_query` | 执行 SQL 查询(最多返回 100 行) |
|
|
292
|
-
| `dbx_execute_redis_command` | 在 Redis 连接上执行 Redis 命令 |
|
|
293
|
-
| `dbx_open_table` | 在 DBX 桌面端打开指定表 |
|
|
294
|
-
| `dbx_execute_and_show` | 执行查询并在 DBX 中展示结果 |
|
|
440
|
+
### 系统要求
|
|
295
441
|
|
|
296
|
-
|
|
442
|
+
- npm 安装需要 Node.js 18.18.0 或更高版本
|
|
443
|
+
- 原生二进制不需要 Node.js、Rust、Cargo、Python 或本地编译环境
|
|
444
|
+
- 连接配置需要存在于 DBX 存储中,或通过 `dbx_add_connection` 添加
|
|
445
|
+
- Agent/JDBC 数据库需要提前安装对应 Agent、JDBC Driver 和 JRE
|
|
446
|
+
- `dbx_open_table`、`dbx_execute_and_show` 需要 DBX 桌面端正在运行
|
|
297
447
|
|
|
298
|
-
|
|
448
|
+
### 工具列表
|
|
299
449
|
|
|
300
|
-
|
|
450
|
+
| 工具 | 说明 |
|
|
451
|
+
| --- | --- |
|
|
452
|
+
| `dbx_list_connections` | 列出当前 MCP 会话可见的连接 |
|
|
453
|
+
| `dbx_add_connection` | 添加本地连接配置 |
|
|
454
|
+
| `dbx_remove_connection` | 删除本地连接配置 |
|
|
455
|
+
| `dbx_list_tables` | 列出表、视图或集合 |
|
|
456
|
+
| `dbx_describe_table` | 获取字段和表结构 |
|
|
457
|
+
| `dbx_get_schema_context` | 获取适合 AI 使用的紧凑 Schema 上下文 |
|
|
458
|
+
| `dbx_execute_query` | 执行 SQL 或支持的 MongoDB Shell 命令,最多返回 100 行 |
|
|
459
|
+
| `dbx_execute_redis_command` | 执行 Redis 命令 |
|
|
460
|
+
| `dbx_open_table` | 在 DBX 桌面端打开表 |
|
|
461
|
+
| `dbx_execute_and_show` | 执行查询并在 DBX 桌面端展示结果 |
|
|
301
462
|
|
|
302
|
-
|
|
303
|
-
DBX_MCP_ALLOW_WRITES=0
|
|
304
|
-
```
|
|
463
|
+
### 本地数据目录
|
|
305
464
|
|
|
306
|
-
`
|
|
465
|
+
- macOS:`~/Library/Application Support/com.dbx.app/dbx.db`
|
|
466
|
+
- Linux:`~/.local/share/com.dbx.app/dbx.db`
|
|
467
|
+
- Windows:`%APPDATA%\com.dbx.app\dbx.db`
|
|
307
468
|
|
|
308
|
-
|
|
309
|
-
DBX_MCP_ALLOW_DANGEROUS_SQL=1
|
|
310
|
-
```
|
|
469
|
+
通过 `DBX_DATA_DIR` 覆盖默认目录。Windows 便携版应指向 `DBX.exe` 同级、包含 `dbx.db` 的 `data` 文件夹。
|
|
311
470
|
|
|
312
|
-
|
|
471
|
+
### DBX Web / Docker
|
|
313
472
|
|
|
314
|
-
|
|
473
|
+
```json
|
|
474
|
+
{
|
|
475
|
+
"mcpServers": {
|
|
476
|
+
"dbx": {
|
|
477
|
+
"command": "dbx-mcp-server",
|
|
478
|
+
"env": {
|
|
479
|
+
"DBX_WEB_URL": "https://dbx.example.com",
|
|
480
|
+
"DBX_WEB_PASSWORD": "Web 登录密码"
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
```
|
|
315
486
|
|
|
316
|
-
|
|
487
|
+
Web 模式不会读取本机 DBX 桌面存储,也不会暴露桌面 UI 工具。
|
|
317
488
|
|
|
318
|
-
|
|
319
|
-
- **Linux**: `~/.local/share/com.dbx.app/dbx.db`
|
|
320
|
-
- **Windows**: `%APPDATA%\com.dbx.app\dbx.db`
|
|
489
|
+
### Agent/JDBC 数据库
|
|
321
490
|
|
|
322
|
-
|
|
491
|
+
达梦、人大金仓、Oracle、DB2、Hive、Trino、Snowflake、SAP HANA 等数据库通过 DBX Java Agent/JDBC 基础设施运行,而不是通过 Node.js 数据库驱动运行。
|
|
323
492
|
|
|
324
|
-
|
|
493
|
+
npm 和 GitHub Release 中的原生 MCP 文件不会捆绑所有厂商的专有 JDBC Driver。请先通过 DBX Driver Manager 安装对应 Agent 和 JRE,或提供兼容的 DBX Agent 目录。
|
|
325
494
|
|
|
326
|
-
|
|
495
|
+
### 连接作用域和只读模式
|
|
327
496
|
|
|
328
497
|
```json
|
|
329
498
|
{
|
|
330
499
|
"mcpServers": {
|
|
331
|
-
"dbx": {
|
|
500
|
+
"dbx-production-readonly": {
|
|
332
501
|
"command": "dbx-mcp-server",
|
|
333
502
|
"env": {
|
|
334
|
-
"
|
|
335
|
-
"
|
|
503
|
+
"DBX_MCP_SCOPE_CONNECTION_NAME": "production-postgres",
|
|
504
|
+
"DBX_MCP_SCOPE_DATABASE": "analytics",
|
|
505
|
+
"DBX_MCP_ALLOW_WRITES": "0"
|
|
336
506
|
}
|
|
337
507
|
}
|
|
338
508
|
}
|
|
339
509
|
}
|
|
340
510
|
```
|
|
341
511
|
|
|
342
|
-
|
|
512
|
+
作用域模式会隐藏连接增删和桌面 UI 工具。
|
|
343
513
|
|
|
344
|
-
###
|
|
514
|
+
### SQL 和命令安全
|
|
345
515
|
|
|
346
|
-
`
|
|
516
|
+
默认允许常规 `INSERT`、`UPDATE`、`DELETE ... WHERE ...`。强制只读:
|
|
347
517
|
|
|
348
|
-
|
|
518
|
+
```bash
|
|
519
|
+
DBX_MCP_ALLOW_WRITES=0
|
|
520
|
+
```
|
|
349
521
|
|
|
350
|
-
|
|
522
|
+
允许 `DROP`、`TRUNCATE`、`ALTER`、Redis `FLUSHALL` 或危险 MongoDB 操作:
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
DBX_MCP_ALLOW_DANGEROUS_SQL=1
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
MongoDB 更新和删除默认要求非空 filter;`$out`、`$merge` 聚合阶段按写操作处理。
|
|
529
|
+
|
|
530
|
+
### 环境变量
|
|
531
|
+
|
|
532
|
+
| 变量 | 用途 |
|
|
533
|
+
| --- | --- |
|
|
534
|
+
| `DBX_DATA_DIR` | 覆盖本地 DBX 数据目录 |
|
|
535
|
+
| `DBX_WEB_URL` | 使用 DBX Web/Docker 后端 |
|
|
536
|
+
| `DBX_WEB_PASSWORD` | DBX Web 登录密码 |
|
|
537
|
+
| `DBX_MCP_ALLOW_WRITES` | 设置为 `0` 强制只读 |
|
|
538
|
+
| `DBX_MCP_ALLOW_DANGEROUS_SQL` | 设置为 `1` 允许危险操作 |
|
|
539
|
+
| `DBX_MCP_SCOPE_CONNECTION_ID` | 限制到指定连接 ID |
|
|
540
|
+
| `DBX_MCP_SCOPE_CONNECTION_NAME` | 限制到指定连接名称 |
|
|
541
|
+
| `DBX_MCP_SCOPE_DATABASE` | 限制到指定数据库 |
|
|
542
|
+
| `DBX_MCP_DEBUG_SQL` | 临时输出 SQL 诊断信息 |
|
|
543
|
+
| `DBX_MCP_BINARY` | 覆盖 npm 启动器使用的原生文件 |
|
|
544
|
+
|
|
545
|
+
### 常见问题
|
|
546
|
+
|
|
547
|
+
**提示平台 optional package 未安装**
|
|
548
|
+
|
|
549
|
+
重新安装并确保没有使用 `--no-optional`:
|
|
550
|
+
|
|
551
|
+
```bash
|
|
552
|
+
npm uninstall -g @dbx-app/mcp-server
|
|
553
|
+
npm install -g @dbx-app/mcp-server@latest
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
**提示找不到 `dbx.db`**
|
|
557
|
+
|
|
558
|
+
将 `DBX_DATA_DIR` 设置为包含 `dbx.db` 的目录,而不是数据库文件路径。
|
|
559
|
+
|
|
560
|
+
**提示 DBX 未运行**
|
|
561
|
+
|
|
562
|
+
普通数据库查询不一定需要启动 DBX;只有桌面 UI 工具和仍需 bridge 的连接需要 DBX 运行。
|
|
563
|
+
|
|
564
|
+
**Agent 数据库无法启动**
|
|
351
565
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
-
|
|
355
|
-
|
|
566
|
+
通过 DBX Driver Manager 安装或更新对应数据库 Agent、JDBC Driver 和 JRE。
|
|
567
|
+
|
|
568
|
+
**出现 `better-sqlite3` 或 Node ABI 错误**
|
|
569
|
+
|
|
570
|
+
Rust MCP 不依赖 `better-sqlite3`。请升级 MCP;如果错误来自 `@dbx-app/cli`,则属于当前仍为 TypeScript 的独立 CLI 包。
|
|
571
|
+
|
|
572
|
+
### 开发和测试
|
|
573
|
+
|
|
574
|
+
```bash
|
|
575
|
+
cargo run -p dbx-mcp --no-default-features
|
|
576
|
+
cargo test -p dbx-mcp --no-default-features
|
|
577
|
+
pnpm --filter @dbx-app/mcp-server test
|
|
578
|
+
cargo build --release -p dbx-mcp --no-default-features
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
旧 TypeScript MCP 源码仍保留在 `packages/mcp-server/src`,用于迁移测试和兼容参考,不再是 npm 的运行入口。
|
|
582
|
+
|
|
583
|
+
### DBX CLI
|
|
584
|
+
|
|
585
|
+
`@dbx-app/cli` 是独立的终端包,目前仍使用 TypeScript/Node.js:
|
|
586
|
+
|
|
587
|
+
```bash
|
|
588
|
+
npm install -g @dbx-app/cli
|
|
589
|
+
dbx connections list --json
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
详见 [CLI README](../cli/README.md)。
|
|
593
|
+
|
|
594
|
+
### License
|
|
595
|
+
|
|
596
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbx-app/mcp-server",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.37",
|
|
4
4
|
"description": "MCP server for DBX — query databases from Claude Code, Cursor, and other AI agents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-agent",
|
|
@@ -28,21 +28,16 @@
|
|
|
28
28
|
],
|
|
29
29
|
"type": "module",
|
|
30
30
|
"optionalDependencies": {
|
|
31
|
-
"@dbx-app/mcp-darwin-arm64": "0.4.
|
|
32
|
-
"@dbx-app/mcp-darwin-x64": "0.4.
|
|
33
|
-
"@dbx-app/mcp-linux-arm64-gnu": "0.4.
|
|
34
|
-
"@dbx-app/mcp-linux-x64-gnu": "0.4.
|
|
35
|
-
"@dbx-app/mcp-win32-arm64": "0.4.
|
|
36
|
-
"@dbx-app/mcp-win32-x64": "0.4.
|
|
31
|
+
"@dbx-app/mcp-darwin-arm64": "0.4.37",
|
|
32
|
+
"@dbx-app/mcp-darwin-x64": "0.4.37",
|
|
33
|
+
"@dbx-app/mcp-linux-arm64-gnu": "0.4.37",
|
|
34
|
+
"@dbx-app/mcp-linux-x64-gnu": "0.4.37",
|
|
35
|
+
"@dbx-app/mcp-win32-arm64": "0.4.37",
|
|
36
|
+
"@dbx-app/mcp-win32-x64": "0.4.37"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
40
39
|
"@types/node": "^22.15.21",
|
|
41
|
-
"
|
|
42
|
-
"typescript": "^5.8.3",
|
|
43
|
-
"vitest": "^4.1.8",
|
|
44
|
-
"zod": "^3.25.20",
|
|
45
|
-
"@dbx-app/node-core": "^0.4.34"
|
|
40
|
+
"vitest": "^4.1.8"
|
|
46
41
|
},
|
|
47
42
|
"engines": {
|
|
48
43
|
"node": ">=18.18.0"
|
|
@@ -50,8 +45,7 @@
|
|
|
50
45
|
"mcpName": "io.github.t8y2/dbx",
|
|
51
46
|
"scripts": {
|
|
52
47
|
"start": "cargo run -p dbx-mcp --",
|
|
53
|
-
"test": "cargo build -p dbx-mcp &&
|
|
54
|
-
"build": "
|
|
55
|
-
"build:legacy": "pnpm --filter @dbx-app/node-core build && tsc"
|
|
48
|
+
"test": "cargo build -p dbx-mcp && vitest run --config vitest.config.ts",
|
|
49
|
+
"build": "node --check bin/dbx-mcp-server.js"
|
|
56
50
|
}
|
|
57
51
|
}
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/t8y2/dbx",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.4.
|
|
9
|
+
"version": "0.4.37",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "@dbx-app/mcp-server",
|
|
14
|
-
"version": "0.4.
|
|
14
|
+
"version": "0.4.37",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
}
|