@bytebase/dbhub 0.11.6 → 0.11.7

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
@@ -4,25 +4,18 @@
4
4
  <p align="center">
5
5
  <a href="https://dbhub.ai/" target="_blank">
6
6
  <picture>
7
- <img src="https://raw.githubusercontent.com/bytebase/dbhub/main/resources/images/logo-full.webp" width="50%">
7
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/bytebase/dbhub/main/docs/images/logo/full-dark.svg" width="75%">
8
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/bytebase/dbhub/main/docs/images/logo/full-light.svg" width="75%">
9
+ <img src="https://raw.githubusercontent.com/bytebase/dbhub/main/docs/images/logo/full-light.svg" width="75%" alt="DBHub Logo">
8
10
  </picture>
9
11
  </a>
10
12
  </p>
11
13
 
12
- <p align="center">
13
- <a href="https://discord.gg/BjEkZpsJzn"><img src="https://img.shields.io/badge/%20-Hang%20out%20on%20Discord-5865F2?style=for-the-badge&logo=discord&labelColor=EEEEEE" alt="Join our Discord" height="32" /></a>
14
- </p>
15
-
16
- <p>
17
- Add to Cursor by copying the below link to browser
18
-
19
- ```text
20
- cursor://anysphere.cursor-deeplink/mcp/install?name=dbhub&config=eyJjb21tYW5kIjoibnB4IEBieXRlYmFzZS9kYmh1YiIsImVudiI6eyJUUkFOU1BPUlQiOiJzdGRpbyIsIkRTTiI6InBvc3RncmVzOi8vdXNlcjpwYXNzd29yZEBsb2NhbGhvc3Q6NTQzMi9kYm5hbWU%2Fc3NsbW9kZT1kaXNhYmxlIiwiUkVBRE9OTFkiOiJ0cnVlIn19
21
- ```
14
+ ![Star History Chart](https://api.star-history.com/svg?repos=bytebase/dbhub&type=Date)
22
15
 
23
16
  </p>
24
17
 
25
- DBHub is a universal database gateway implementing the Model Context Protocol (MCP) server interface. This gateway allows MCP-compatible clients to connect to and explore different databases.
18
+ DBHub is a Universal Database MCP Server implementing the Model Context Protocol (MCP) server interface. This gateway allows MCP-compatible clients to connect to and explore different databases.
26
19
 
27
20
  ```bash
28
21
  +------------------+ +--------------+ +------------------+
@@ -34,532 +27,61 @@ DBHub is a universal database gateway implementing the Model Context Protocol (M
34
27
  | | | | | |
35
28
  | Cursor +--->+ DBHub +--->+ SQLite |
36
29
  | | | | | |
37
- | Other Clients +--->+ +--->+ MySQL |
30
+ | VS Code +--->+ +--->+ MySQL |
38
31
  | | | | | |
39
- | | | +--->+ MariaDB |
32
+ | Other Clients +--->+ +--->+ MariaDB |
40
33
  | | | | | |
41
34
  | | | | | |
42
35
  +------------------+ +--------------+ +------------------+
43
36
  MCP Clients MCP Server Databases
44
37
  ```
45
38
 
46
- ## Supported Matrix
47
-
48
- ### Database Resources
39
+ ## Supported Databases
49
40
 
50
- | Resource Name | URI Format | PostgreSQL | MySQL | MariaDB | SQL Server | SQLite |
51
- | --------------------------- | ------------------------------------------------------ | :--------: | :---: | :-----: | :--------: | :----: |
52
- | schemas | `db://schemas` | ✅ | ✅ | ✅ | ✅ | ✅ |
53
- | tables_in_schema | `db://schemas/{schemaName}/tables` | ✅ | ✅ | ✅ | ✅ | ✅ |
54
- | table_structure_in_schema | `db://schemas/{schemaName}/tables/{tableName}` | ✅ | ✅ | ✅ | ✅ | ✅ |
55
- | indexes_in_table | `db://schemas/{schemaName}/tables/{tableName}/indexes` | ✅ | ✅ | ✅ | ✅ | ✅ |
56
- | procedures_in_schema | `db://schemas/{schemaName}/procedures` | ✅ | ✅ | ✅ | ✅ | ❌ |
57
- | procedure_details_in_schema | `db://schemas/{schemaName}/procedures/{procedureName}` | ✅ | ✅ | ✅ | ✅ | ❌ |
41
+ PostgreSQL, MySQL, SQL Server, MariaDB, and SQLite.
58
42
 
59
- ### Database Tools
43
+ ## MCP Components
60
44
 
61
- | Tool | Command Name | Description | PostgreSQL | MySQL | MariaDB | SQL Server | SQLite |
62
- | ----------- | ------------- | ------------------------------------------------------------------- | :--------: | :---: | :-----: | :--------: | ------ |
63
- | Execute SQL | `execute_sql` | Execute single or multiple SQL statements (separated by semicolons) | ✅ | ✅ | ✅ | ✅ | ✅ |
45
+ DBHub implements MCP Resources, Tools, and Prompts for database operations:
64
46
 
65
- ### Prompt Capabilities
66
-
67
- | Prompt | Command Name | PostgreSQL | MySQL | MariaDB | SQL Server | SQLite |
68
- | ------------------- | -------------- | :--------: | :---: | :-----: | :--------: | ------ |
69
- | Generate SQL | `generate_sql` | ✅ | ✅ | ✅ | ✅ | ✅ |
70
- | Explain DB Elements | `explain_db` | ✅ | ✅ | ✅ | ✅ | ✅ |
47
+ - **[Resources](https://dbhub.ai/components/resources)**: Database schema exploration (schemas, tables, indexes, procedures)
48
+ - **[Tools](https://dbhub.ai/components/tools)**: SQL execution with transaction support
49
+ - **[Prompts](https://dbhub.ai/components/prompts)**: AI-assisted SQL generation and database explanation
71
50
 
72
51
  ## Installation
73
52
 
74
- ### Docker
53
+ See the full [Installation Guide](https://dbhub.ai/installation) for detailed instructions.
75
54
 
76
- ```bash
77
- # PostgreSQL example
78
- docker run --rm --init \
79
- --name dbhub \
80
- --publish 8080:8080 \
81
- bytebase/dbhub \
82
- --transport http \
83
- --port 8080 \
84
- --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
85
- ```
55
+ ### Quick Start
86
56
 
57
+ **Docker:**
87
58
  ```bash
88
- # Demo mode with sqlite sample employee database
89
59
  docker run --rm --init \
90
60
  --name dbhub \
91
61
  --publish 8080:8080 \
92
62
  bytebase/dbhub \
93
63
  --transport http \
94
64
  --port 8080 \
95
- --demo
96
- ```
97
-
98
- **Docker Compose Setup:**
99
-
100
- If you're using Docker Compose for development, add DBHub to your `docker-compose.yml`:
101
-
102
- ```yaml
103
- dbhub:
104
- image: bytebase/dbhub:latest
105
- container_name: dbhub
106
- ports:
107
- - "8080:8080"
108
- environment:
109
- - DBHUB_LOG_LEVEL=info
110
- command:
111
- - --transport
112
- - http
113
- - --port
114
- - "8080"
115
- - --dsn
116
- - "postgres://user:password@database:5432/dbname"
117
- depends_on:
118
- - database
65
+ --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
119
66
  ```
120
67
 
121
- ### NPM
122
-
68
+ **NPM:**
123
69
  ```bash
124
- # PostgreSQL example
125
70
  npx @bytebase/dbhub --transport http --port 8080 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
126
-
127
- # Demo mode with sqlite sample employee database
128
- npx @bytebase/dbhub --transport http --port 8080 --demo
129
- ```
130
-
131
- ```bash
132
- # Demo mode with sample employee database
133
- npx @bytebase/dbhub --transport http --port 8080 --demo
134
- ```
135
-
136
- > Note: The demo mode includes a bundled SQLite sample "employee" database with tables for employees, departments, salaries, and more.
137
-
138
- ### Claude Desktop
139
-
140
- ![claude-desktop](https://raw.githubusercontent.com/bytebase/dbhub/main/resources/images/claude-desktop.webp)
141
-
142
- - Claude Desktop only supports `stdio` transport https://github.com/orgs/modelcontextprotocol/discussions/16
143
-
144
- ```json
145
- // claude_desktop_config.json
146
- {
147
- "mcpServers": {
148
- "dbhub-postgres-docker": {
149
- "command": "docker",
150
- "args": [
151
- "run",
152
- "-i",
153
- "--rm",
154
- "bytebase/dbhub",
155
- "--transport",
156
- "stdio",
157
- "--dsn",
158
- // Use host.docker.internal as the host if connecting to the local db
159
- "postgres://user:password@host.docker.internal:5432/dbname?sslmode=disable"
160
- ]
161
- },
162
- "dbhub-postgres-npx": {
163
- "command": "npx",
164
- "args": [
165
- "-y",
166
- "@bytebase/dbhub",
167
- "--transport",
168
- "stdio",
169
- "--dsn",
170
- "postgres://user:password@localhost:5432/dbname?sslmode=disable"
171
- ]
172
- },
173
- "dbhub-demo": {
174
- "command": "npx",
175
- "args": ["-y", "@bytebase/dbhub", "--transport", "stdio", "--demo"]
176
- }
177
- }
178
- }
179
- ```
180
-
181
- ### Claude Code
182
-
183
- Check https://docs.anthropic.com/en/docs/claude-code/mcp
184
-
185
- ### Cursor
186
-
187
- <p>
188
- Add to Cursor by copying the below link to browser
189
-
190
- ```text
191
- cursor://anysphere.cursor-deeplink/mcp/install?name=dbhub&config=eyJjb21tYW5kIjoibnB4IEBieXRlYmFzZS9kYmh1YiIsImVudiI6eyJUUkFOU1BPUlQiOiJzdGRpbyIsIkRTTiI6InBvc3RncmVzOi8vdXNlcjpwYXNzd29yZEBsb2NhbGhvc3Q6NTQzMi9kYm5hbWU%2Fc3NsbW9kZT1kaXNhYmxlIiwiUkVBRE9OTFkiOiJ0cnVlIn19
192
- ```
193
-
194
- </p>
195
-
196
- ![cursor](https://raw.githubusercontent.com/bytebase/dbhub/main/resources/images/cursor.webp)
197
-
198
- - Cursor supports both `stdio` and `http`.
199
- - Follow [Cursor MCP guide](https://docs.cursor.com/context/model-context-protocol) and make sure to use [Agent](https://docs.cursor.com/chat/agent) mode.
200
-
201
- ### VSCode + Copilot
202
-
203
- Check https://code.visualstudio.com/docs/copilot/customization/mcp-servers
204
-
205
- VSCode with GitHub Copilot can connect to DBHub via both `stdio` and `http` transports. This enables AI agents to interact with your development database through a secure interface.
206
-
207
- - VSCode supports both `stdio` and `http` transports
208
- - Configure MCP server in `.vscode/mcp.json`:
209
-
210
- **Stdio Transport:**
211
-
212
- ```json
213
- {
214
- "servers": {
215
- "dbhub": {
216
- "command": "npx",
217
- "args": [
218
- "-y",
219
- "@bytebase/dbhub",
220
- "--transport",
221
- "stdio",
222
- "--dsn",
223
- "postgres://user:password@localhost:5432/dbname"
224
- ]
225
- }
226
- },
227
- "inputs": []
228
- }
229
- ```
230
-
231
- **HTTP Transport:**
232
-
233
- ```json
234
- {
235
- "servers": {
236
- "dbhub": {
237
- "url": "http://localhost:8080/message",
238
- "type": "http"
239
- }
240
- },
241
- "inputs": []
242
- }
243
- ```
244
-
245
- **Copilot Instructions:**
246
-
247
- You can provide Copilot with context by creating `.github/copilot-instructions.md`:
248
-
249
- ```markdown
250
- ## Database Access
251
-
252
- This project provides an MCP server (DBHub) for secure SQL access to the development database.
253
-
254
- AI agents can execute SQL queries. In read-only mode (recommended for production):
255
-
256
- - `SELECT * FROM users LIMIT 5;`
257
- - `SHOW TABLES;`
258
- - `DESCRIBE table_name;`
259
-
260
- In read-write mode (development/testing):
261
-
262
- - `INSERT INTO users (name, email) VALUES ('John', 'john@example.com');`
263
- - `UPDATE users SET status = 'active' WHERE id = 1;`
264
- - `CREATE TABLE test_table (id INT PRIMARY KEY);`
265
-
266
- Use `--readonly` flag to restrict to read-only operations for safety.
267
- ```
268
-
269
- ## Usage
270
-
271
- ### Read-only Mode
272
-
273
- You can run DBHub in read-only mode, which restricts SQL query execution to read-only operations:
274
-
275
- ```bash
276
- # Enable read-only mode
277
- npx @bytebase/dbhub --readonly --dsn "postgres://user:password@localhost:5432/dbname"
278
- ```
279
-
280
- In read-only mode, only [readonly SQL operations](https://github.com/bytebase/dbhub/blob/main/src/utils/allowed-keywords.ts) are allowed.
281
-
282
- This provides an additional layer of security when connecting to production databases.
283
-
284
- ### Suffix Tool Names with ID
285
-
286
- You can suffix tool names with a custom ID using the `--id` flag or `ID` environment variable. This is useful when running multiple DBHub instances (e.g., in Cursor) to allow the client to route queries to the correct database.
287
-
288
- **Example configuration for multiple databases in Cursor:**
289
-
290
- ```json
291
- {
292
- "mcpServers": {
293
- "dbhub-prod": {
294
- "command": "npx",
295
- "args": ["-y", "@bytebase/dbhub"],
296
- "env": {
297
- "ID": "prod",
298
- "DSN": "postgres://user:password@prod-host:5432/dbname"
299
- }
300
- },
301
- "dbhub-staging": {
302
- "command": "npx",
303
- "args": ["-y", "@bytebase/dbhub"],
304
- "env": {
305
- "ID": "staging",
306
- "DSN": "mysql://user:password@staging-host:3306/dbname"
307
- }
308
- }
309
- }
310
- }
311
71
  ```
312
72
 
313
- With this configuration:
314
-
315
- - Production database tools: `execute_sql_prod`
316
- - Staging database tools: `execute_sql_staging`
317
-
318
- ### Row Limiting
319
-
320
- You can limit the number of rows returned from SELECT queries using the `--max-rows` parameter. This helps prevent accidentally retrieving too much data from large tables:
321
-
73
+ **Demo Mode:**
322
74
  ```bash
323
- # Limit SELECT queries to return at most 1000 rows
324
- npx @bytebase/dbhub --dsn "postgres://user:password@localhost:5432/dbname" --max-rows 1000
75
+ npx @bytebase/dbhub --transport http --port 8080 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable" --demo
325
76
  ```
326
77
 
327
- - Row limiting is only applied to SELECT statements, not INSERT/UPDATE/DELETE
328
- - If your query already has a `LIMIT` or `TOP` clause, DBHub uses the smaller value
329
-
330
- ### SSL Connections
331
-
332
- You can specify the SSL mode using the `sslmode` parameter in your DSN string:
333
-
334
- | Database | `sslmode=disable` | `sslmode=require` | Default SSL Behavior |
335
- | ---------- | :---------------: | :---------------: | :----------------------: |
336
- | PostgreSQL | ✅ | ✅ | Certificate verification |
337
- | MySQL | ✅ | ✅ | Certificate verification |
338
- | MariaDB | ✅ | ✅ | Certificate verification |
339
- | SQL Server | ✅ | ✅ | Certificate verification |
340
- | SQLite | ❌ | ❌ | N/A (file-based) |
341
-
342
- **SSL Mode Options:**
78
+ See [Server Options](https://dbhub.ai/config/server-options) for all available parameters.
343
79
 
344
- - `sslmode=disable`: All SSL/TLS encryption is turned off. Data is transmitted in plaintext.
345
- - `sslmode=require`: Connection is encrypted, but the server's certificate is not verified. This provides protection against packet sniffing but not against man-in-the-middle attacks. You may use this for trusted self-signed CA.
80
+ ### Multi-Database Setup
346
81
 
347
- Without specifying `sslmode`, most databases default to certificate verification, which provides the highest level of security.
82
+ Connect to multiple databases simultaneously using TOML configuration files. Perfect for managing production, staging, and development databases from a single DBHub instance.
348
83
 
349
- Example usage:
350
-
351
- ```bash
352
- # Disable SSL
353
- postgres://user:password@localhost:5432/dbname?sslmode=disable
354
-
355
- # Require SSL without certificate verification
356
- postgres://user:password@localhost:5432/dbname?sslmode=require
357
-
358
- # Standard SSL with certificate verification (default)
359
- postgres://user:password@localhost:5432/dbname
360
- ```
361
-
362
- ### SSH Tunnel Support
363
-
364
- DBHub supports connecting to databases through SSH tunnels, enabling secure access to databases in private networks or behind firewalls.
365
-
366
- #### Using SSH Config File (Recommended)
367
-
368
- DBHub can read SSH connection settings from your `~/.ssh/config` file. Simply use the host alias from your SSH config:
369
-
370
- ```bash
371
- # If you have this in ~/.ssh/config:
372
- # Host mybastion
373
- # HostName bastion.example.com
374
- # User ubuntu
375
- # IdentityFile ~/.ssh/id_rsa
376
-
377
- npx @bytebase/dbhub \
378
- --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb" \
379
- --ssh-host mybastion
380
- ```
381
-
382
- DBHub will automatically use the settings from your SSH config, including hostname, user, port, and identity file. If no identity file is specified in the config, DBHub will try common default locations (`~/.ssh/id_rsa`, `~/.ssh/id_ed25519`, etc.).
383
-
384
- #### SSH with Password Authentication
385
-
386
- ```bash
387
- npx @bytebase/dbhub \
388
- --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb" \
389
- --ssh-host bastion.example.com \
390
- --ssh-user ubuntu \
391
- --ssh-password mypassword
392
- ```
393
-
394
- #### SSH with Private Key Authentication
395
-
396
- ```bash
397
- npx @bytebase/dbhub \
398
- --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb" \
399
- --ssh-host bastion.example.com \
400
- --ssh-user ubuntu \
401
- --ssh-key ~/.ssh/id_rsa
402
- ```
403
-
404
- #### SSH with Private Key and Passphrase
405
-
406
- ```bash
407
- npx @bytebase/dbhub \
408
- --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb" \
409
- --ssh-host bastion.example.com \
410
- --ssh-port 2222 \
411
- --ssh-user ubuntu \
412
- --ssh-key ~/.ssh/id_rsa \
413
- --ssh-passphrase mykeypassphrase
414
- ```
415
-
416
- #### Using Environment Variables
417
-
418
- ```bash
419
- export SSH_HOST=bastion.example.com
420
- export SSH_USER=ubuntu
421
- export SSH_KEY=~/.ssh/id_rsa
422
- npx @bytebase/dbhub --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb"
423
- ```
424
-
425
- **Note**: When using SSH tunnels, the database host in your DSN should be the hostname/IP as seen from the SSH server (bastion host), not from your local machine.
426
-
427
- ### Configure your database connection
428
-
429
- You can use DBHub in demo mode with a sample employee database for testing:
430
-
431
- ```bash
432
- npx @bytebase/dbhub --demo
433
- ```
434
-
435
- > [!WARNING]
436
- > If your user/password contains special characters, you have two options:
437
- >
438
- > 1. Escape them in the DSN (e.g. `pass#word` should be escaped as `pass%23word`)
439
- > 2. Use the individual database parameters method below (recommended)
440
-
441
- For real databases, you can configure the database connection in two ways:
442
-
443
- #### Method 1: Database Source Name (DSN)
444
-
445
- - **Command line argument** (highest priority):
446
-
447
- ```bash
448
- npx @bytebase/dbhub --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
449
- ```
450
-
451
- - **Environment variable** (second priority):
452
-
453
- ```bash
454
- export DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable"
455
- npx @bytebase/dbhub
456
- ```
457
-
458
- - **Environment file** (third priority):
459
- - For development: Create `.env.local` with your DSN
460
- - For production: Create `.env` with your DSN
461
- ```
462
- DSN=postgres://user:password@localhost:5432/dbname?sslmode=disable
463
- ```
464
-
465
- #### Method 2: Individual Database Parameters
466
-
467
- If your password contains special characters that would break URL parsing, use individual environment variables instead:
468
-
469
- - **Environment variables**:
470
-
471
- ```bash
472
- export DB_TYPE=postgres
473
- export DB_HOST=localhost
474
- export DB_PORT=5432
475
- export DB_USER=myuser
476
- export DB_PASSWORD='my@complex:password/with#special&chars'
477
- export DB_NAME=mydatabase
478
- npx @bytebase/dbhub
479
- ```
480
-
481
- - **Environment file**:
482
- ```
483
- DB_TYPE=postgres
484
- DB_HOST=localhost
485
- DB_PORT=5432
486
- DB_USER=myuser
487
- DB_PASSWORD=my@complex:password/with#special&chars
488
- DB_NAME=mydatabase
489
- ```
490
-
491
- **Supported DB_TYPE values**: `postgres`, `mysql`, `mariadb`, `sqlserver`, `sqlite`
492
-
493
- **Default ports** (when DB_PORT is omitted):
494
-
495
- - PostgreSQL: `5432`
496
- - MySQL/MariaDB: `3306`
497
- - SQL Server: `1433`
498
-
499
- **For SQLite**: Only `DB_TYPE=sqlite` and `DB_NAME=/path/to/database.db` are required.
500
-
501
- > [!TIP]
502
- > Use the individual parameter method when your password contains special characters like `@`, `:`, `/`, `#`, `&`, `=` that would break DSN parsing.
503
-
504
- > [!WARNING]
505
- > When running in Docker, use `host.docker.internal` instead of `localhost` to connect to databases running on your host machine. For example: `mysql://user:password@host.docker.internal:3306/dbname`
506
-
507
- DBHub supports the following database connection string formats:
508
-
509
- | Database | DSN Format | Example |
510
- | ---------- | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
511
- | MySQL | `mysql://[user]:[password]@[host]:[port]/[database]` | `mysql://user:password@localhost:3306/dbname?sslmode=disable` |
512
- | MariaDB | `mariadb://[user]:[password]@[host]:[port]/[database]` | `mariadb://user:password@localhost:3306/dbname?sslmode=disable` |
513
- | PostgreSQL | `postgres://[user]:[password]@[host]:[port]/[database]` | `postgres://user:password@localhost:5432/dbname?sslmode=disable` |
514
- | SQL Server | `sqlserver://[user]:[password]@[host]:[port]/[database]` | `sqlserver://user:password@localhost:1433/dbname?sslmode=disable` |
515
- | SQLite | `sqlite:///[path/to/file]` or `sqlite:///:memory:` | `sqlite:///path/to/database.db`, `sqlite:C:/Users/YourName/data/database.db (windows)` or `sqlite:///:memory:` |
516
-
517
- #### SQL Server
518
-
519
- Extra query parameters:
520
-
521
- #### authentication
522
-
523
- - `authentication=azure-active-directory-access-token`. Only applicable when running from Azure. See [DefaultAzureCredential](https://learn.microsoft.com/en-us/azure/developer/javascript/sdk/authentication/credential-chains#use-defaultazurecredential-for-flexibility).
524
-
525
- ### Transport
526
-
527
- - **stdio** (default) - for direct integration with tools like Claude Desktop:
528
-
529
- ```bash
530
- npx @bytebase/dbhub --transport stdio --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
531
- ```
532
-
533
- - **http** - for browser and network clients:
534
- ```bash
535
- npx @bytebase/dbhub --transport http --port 5678 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
536
- ```
537
-
538
- ### Command line options
539
-
540
- | Option | Environment Variable | Description | Default |
541
- | -------------- | -------------------- | --------------------------------------------------------------------- | ---------------------------- |
542
- | dsn | `DSN` | Database connection string | Required if not in demo mode |
543
- | N/A | `DB_TYPE` | Database type: `postgres`, `mysql`, `mariadb`, `sqlserver`, `sqlite` | N/A |
544
- | N/A | `DB_HOST` | Database server hostname (not needed for SQLite) | N/A |
545
- | N/A | `DB_PORT` | Database server port (uses default if omitted, not needed for SQLite) | N/A |
546
- | N/A | `DB_USER` | Database username (not needed for SQLite) | N/A |
547
- | N/A | `DB_PASSWORD` | Database password (not needed for SQLite) | N/A |
548
- | N/A | `DB_NAME` | Database name or SQLite file path | N/A |
549
- | transport | `TRANSPORT` | Transport mode: `stdio` or `http` | `stdio` |
550
- | port | `PORT` | HTTP server port (only applicable when using `--transport=http`) | `8080` |
551
- | readonly | `READONLY` | Restrict SQL execution to read-only operations | `false` |
552
- | max-rows | N/A | Limit the number of rows returned from SELECT queries | No limit |
553
- | demo | N/A | Run in demo mode with sample employee database | `false` |
554
- | id | `ID` | Instance identifier to suffix tool names (for multi-instance) | N/A |
555
- | ssh-host | `SSH_HOST` | SSH server hostname for tunnel connection | N/A |
556
- | ssh-port | `SSH_PORT` | SSH server port | `22` |
557
- | ssh-user | `SSH_USER` | SSH username | N/A |
558
- | ssh-password | `SSH_PASSWORD` | SSH password (for password authentication) | N/A |
559
- | ssh-key | `SSH_KEY` | Path to SSH private key file | N/A |
560
- | ssh-passphrase | `SSH_PASSPHRASE` | Passphrase for SSH private key | N/A |
561
-
562
- The demo mode uses an in-memory SQLite database loaded with the [sample employee database](https://github.com/bytebase/dbhub/tree/main/resources/employee-sqlite) that includes tables for employees, departments, titles, salaries, department employees, and department managers. The sample database includes SQL scripts for table creation, data loading, and testing.
84
+ See [Multi-Database Configuration](https://dbhub.ai/config/multi-database) for complete setup instructions.
563
85
 
564
86
  ## Development
565
87
 
@@ -583,131 +105,14 @@ The demo mode uses an in-memory SQLite database loaded with the [sample employee
583
105
 
584
106
  ### Testing
585
107
 
586
- The project uses Vitest for comprehensive unit and integration testing:
587
-
588
- - **Run all tests**: `pnpm test`
589
- - **Run tests in watch mode**: `pnpm test:watch`
590
- - **Run integration tests**: `pnpm test:integration`
591
-
592
- #### Integration Tests
593
-
594
- DBHub includes comprehensive integration tests for all supported database connectors using [Testcontainers](https://testcontainers.com/). These tests run against real database instances in Docker containers, ensuring full compatibility and feature coverage.
108
+ See [TESTING.md](.claude/skills/testing/SKILL.md).
595
109
 
596
- ##### Prerequisites
110
+ ### Debug
597
111
 
598
- - **Docker**: Ensure Docker is installed and running on your machine
599
- - **Docker Resources**: Allocate sufficient memory (recommended: 4GB+) for multiple database containers
600
- - **Network Access**: Ability to pull Docker images from registries
601
-
602
- ##### Running Integration Tests
603
-
604
- **Note**: This command runs all integration tests in parallel, which may take 5-15 minutes depending on your system resources and network speed.
605
-
606
- ```bash
607
- # Run all database integration tests
608
- pnpm test:integration
609
- ```
610
-
611
- ```bash
612
- # Run only PostgreSQL integration tests
613
- pnpm test src/connectors/__tests__/postgres.integration.test.ts
614
- # Run only MySQL integration tests
615
- pnpm test src/connectors/__tests__/mysql.integration.test.ts
616
- # Run only MariaDB integration tests
617
- pnpm test src/connectors/__tests__/mariadb.integration.test.ts
618
- # Run only SQL Server integration tests
619
- pnpm test src/connectors/__tests__/sqlserver.integration.test.ts
620
- # Run only SQLite integration tests
621
- pnpm test src/connectors/__tests__/sqlite.integration.test.ts
622
- # Run JSON RPC integration tests
623
- pnpm test src/__tests__/json-rpc-integration.test.ts
624
- ```
625
-
626
- All integration tests follow these patterns:
627
-
628
- 1. **Container Lifecycle**: Start database container → Connect → Setup test data → Run tests → Cleanup
629
- 2. **Shared Test Utilities**: Common test patterns implemented in `IntegrationTestBase` class
630
- 3. **Database-Specific Features**: Each database includes tests for unique features and capabilities
631
- 4. **Error Handling**: Comprehensive testing of connection errors, invalid SQL, and edge cases
632
-
633
- ##### Troubleshooting Integration Tests
634
-
635
- **Container Startup Issues:**
636
-
637
- ```bash
638
- # Check Docker is running
639
- docker ps
640
-
641
- # Check available memory
642
- docker system df
643
-
644
- # Pull images manually if needed
645
- docker pull postgres:15-alpine
646
- docker pull mysql:8.0
647
- docker pull mariadb:10.11
648
- docker pull mcr.microsoft.com/mssql/server:2019-latest
649
- ```
650
-
651
- **SQL Server Timeout Issues:**
652
-
653
- - SQL Server containers require significant startup time (3-5 minutes)
654
- - Ensure Docker has sufficient memory allocated (4GB+ recommended)
655
- - Consider running SQL Server tests separately if experiencing timeouts
656
-
657
- **Network/Resource Issues:**
658
-
659
- ```bash
660
- # Run tests with verbose output
661
- pnpm test:integration --reporter=verbose
662
-
663
- # Run single database test to isolate issues
664
- pnpm test:integration -- --testNamePattern="PostgreSQL"
665
-
666
- # Check Docker container logs if tests fail
667
- docker logs <container_id>
668
- ```
669
-
670
- #### Pre-commit Hooks (for Developers)
671
-
672
- The project includes pre-commit hooks to run tests automatically before each commit:
673
-
674
- 1. After cloning the repository, set up the pre-commit hooks:
675
-
676
- ```bash
677
- ./scripts/setup-husky.sh
678
- ```
679
-
680
- 2. This ensures the test suite runs automatically whenever you create a commit, preventing commits that would break tests.
681
-
682
- ### Debug with [MCP Inspector](https://github.com/modelcontextprotocol/inspector)
683
-
684
- ![mcp-inspector](https://raw.githubusercontent.com/bytebase/dbhub/main/resources/images/mcp-inspector.webp)
685
-
686
- #### stdio
687
-
688
- ```bash
689
- # PostgreSQL example
690
- TRANSPORT=stdio DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable" npx @modelcontextprotocol/inspector node /path/to/dbhub/dist/index.js
691
- ```
692
-
693
- #### HTTP
694
-
695
- ```bash
696
- # Start DBHub with HTTP transport
697
- pnpm dev --transport=http --port=8080
698
-
699
- # Start the MCP Inspector in another terminal
700
- npx @modelcontextprotocol/inspector
701
- ```
702
-
703
- Connect to the DBHub server `/message` endpoint
112
+ See [Debug](https://dbhub.ai/config/debug).
704
113
 
705
114
  ## Contributors
706
115
 
707
116
  <a href="https://github.com/bytebase/dbhub/graphs/contributors">
708
117
  <img src="https://contrib.rocks/image?repo=bytebase/dbhub" />
709
118
  </a>
710
-
711
- ## Star History
712
-
713
- [![Star History Chart](https://api.star-history.com/svg?repos=bytebase/dbhub&type=Date)](https://www.star-history.com/#bytebase/dbhub&Date)