@bytebase/dbhub 0.9.0 → 0.11.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.
package/README.md CHANGED
@@ -22,12 +22,15 @@ DBHub is a universal database gateway implementing the Model Context Protocol (M
22
22
  | | | | | |
23
23
  | Claude Desktop +--->+ +--->+ PostgreSQL |
24
24
  | | | | | |
25
- | Cursor +--->+ DBHub +--->+ SQL Server |
25
+ | Claude Code +--->+ +--->+ SQL Server |
26
26
  | | | | | |
27
- | | | +--->+ MySQL |
27
+ | Cursor +--->+ DBHub +--->+ SQLite |
28
+ | | | | | |
29
+ | Other Clients +--->+ +--->+ MySQL |
28
30
  | | | | | |
29
31
  | | | +--->+ MariaDB |
30
32
  | | | | | |
33
+ | | | | | |
31
34
  +------------------+ +--------------+ +------------------+
32
35
  MCP Clients MCP Server Databases
33
36
  ```
@@ -42,27 +45,27 @@ https://demo.dbhub.ai/message connects a [sample employee database](https://gith
42
45
 
43
46
  ### Database Resources
44
47
 
45
- | Resource Name | URI Format | PostgreSQL | MySQL | MariaDB | SQL Server |
46
- | --------------------------- | ------------------------------------------------------ | :--------: | :---: | :-----: | :--------: |
47
- | schemas | `db://schemas` | ✅ | ✅ | ✅ | ✅ |
48
- | tables_in_schema | `db://schemas/{schemaName}/tables` | ✅ | ✅ | ✅ | ✅ |
49
- | table_structure_in_schema | `db://schemas/{schemaName}/tables/{tableName}` | ✅ | ✅ | ✅ | ✅ |
50
- | indexes_in_table | `db://schemas/{schemaName}/tables/{tableName}/indexes` | ✅ | ✅ | ✅ | ✅ |
51
- | procedures_in_schema | `db://schemas/{schemaName}/procedures` | ✅ | ✅ | ✅ | ✅ |
52
- | procedure_details_in_schema | `db://schemas/{schemaName}/procedures/{procedureName}` | ✅ | ✅ | ✅ | ✅ |
48
+ | Resource Name | URI Format | PostgreSQL | MySQL | MariaDB | SQL Server | SQLite |
49
+ | --------------------------- | ------------------------------------------------------ | :--------: | :---: | :-----: | :--------: | :----: |
50
+ | schemas | `db://schemas` | ✅ | ✅ | ✅ | ✅ | ✅ |
51
+ | tables_in_schema | `db://schemas/{schemaName}/tables` | ✅ | ✅ | ✅ | ✅ | ✅ |
52
+ | table_structure_in_schema | `db://schemas/{schemaName}/tables/{tableName}` | ✅ | ✅ | ✅ | ✅ | ✅ |
53
+ | indexes_in_table | `db://schemas/{schemaName}/tables/{tableName}/indexes` | ✅ | ✅ | ✅ | ✅ | ✅ |
54
+ | procedures_in_schema | `db://schemas/{schemaName}/procedures` | ✅ | ✅ | ✅ | ✅ | ❌ |
55
+ | procedure_details_in_schema | `db://schemas/{schemaName}/procedures/{procedureName}` | ✅ | ✅ | ✅ | ✅ | ❌ |
53
56
 
54
57
  ### Database Tools
55
58
 
56
- | Tool | Command Name | Description | PostgreSQL | MySQL | MariaDB | SQL Server |
57
- | ----------- | ------------- | ------------------------------------------------------------------- | :--------: | :---: | :-----: | :--------: |
58
- | Execute SQL | `execute_sql` | Execute single or multiple SQL statements (separated by semicolons) | ✅ | ✅ | ✅ | ✅ |
59
+ | Tool | Command Name | Description | PostgreSQL | MySQL | MariaDB | SQL Server | SQLite |
60
+ | ----------- | ------------- | ------------------------------------------------------------------- | :--------: | :---: | :-----: | :--------: | ------ |
61
+ | Execute SQL | `execute_sql` | Execute single or multiple SQL statements (separated by semicolons) | ✅ | ✅ | ✅ | ✅ | ✅ |
59
62
 
60
63
  ### Prompt Capabilities
61
64
 
62
- | Prompt | Command Name | PostgreSQL | MySQL | MariaDB | SQL Server |
63
- | ------------------- | -------------- | :--------: | :---: | :-----: | :--------: |
64
- | Generate SQL | `generate_sql` | ✅ | ✅ | ✅ | ✅ |
65
- | Explain DB Elements | `explain_db` | ✅ | ✅ | ✅ | ✅ |
65
+ | Prompt | Command Name | PostgreSQL | MySQL | MariaDB | SQL Server | SQLite |
66
+ | ------------------- | -------------- | :--------: | :---: | :-----: | :--------: | ------ |
67
+ | Generate SQL | `generate_sql` | ✅ | ✅ | ✅ | ✅ | ✅ |
68
+ | Explain DB Elements | `explain_db` | ✅ | ✅ | ✅ | ✅ | ✅ |
66
69
 
67
70
  ## Installation
68
71
 
@@ -79,15 +82,33 @@ docker run --rm --init \
79
82
  --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
80
83
  ```
81
84
 
82
-
85
+ ```bash
86
+ # Demo mode with sqlite sample employee database
87
+ docker run --rm --init \
88
+ --name dbhub \
89
+ --publish 8080:8080 \
90
+ bytebase/dbhub \
91
+ --transport http \
92
+ --port 8080 \
93
+ --demo
94
+ ```
83
95
 
84
96
  ### NPM
85
97
 
86
98
  ```bash
87
99
  # PostgreSQL example
88
100
  npx @bytebase/dbhub --transport http --port 8080 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
101
+
102
+ # Demo mode with sqlite sample employee database
103
+ npx @bytebase/dbhub --transport http --port 8080 --demo
104
+ ```
105
+
106
+ ```bash
107
+ # Demo mode with sample employee database
108
+ npx @bytebase/dbhub --transport http --port 8080 --demo
89
109
  ```
90
110
 
111
+ > Note: The demo mode includes a bundled SQLite sample "employee" database with tables for employees, departments, salaries, and more.
91
112
 
92
113
  ### Claude Desktop
93
114
 
@@ -124,10 +145,18 @@ npx @bytebase/dbhub --transport http --port 8080 --dsn "postgres://user:password
124
145
  "postgres://user:password@localhost:5432/dbname?sslmode=disable"
125
146
  ]
126
147
  },
148
+ "dbhub-demo": {
149
+ "command": "npx",
150
+ "args": ["-y", "@bytebase/dbhub", "--transport", "stdio", "--demo"]
151
+ }
127
152
  }
128
153
  }
129
154
  ```
130
155
 
156
+ ### Claude Code
157
+
158
+ Check https://docs.anthropic.com/en/docs/claude-code/mcp
159
+
131
160
  ### Cursor
132
161
 
133
162
  [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/install-mcp?name=dbhub&config=eyJjb21tYW5kIjoibnB4IEBieXRlYmFzZS9kYmh1YiIsImVudiI6eyJUUkFOU1BPUlQiOiJzdGRpbyIsIkRTTiI6InBvc3RncmVzOi8vdXNlcjpwYXNzd29yZEBsb2NhbGhvc3Q6NTQzMi9kYm5hbWU%2Fc3NsbW9kZT1kaXNhYmxlIiwiUkVBRE9OTFkiOiJ0cnVlIn19)
@@ -139,16 +168,30 @@ npx @bytebase/dbhub --transport http --port 8080 --dsn "postgres://user:password
139
168
 
140
169
  ## Usage
141
170
 
171
+ ### Read-only Mode
172
+
173
+ You can run DBHub in read-only mode, which restricts SQL query execution to read-only operations:
174
+
175
+ ```bash
176
+ # Enable read-only mode
177
+ npx @bytebase/dbhub --readonly --dsn "postgres://user:password@localhost:5432/dbname"
178
+ ```
179
+
180
+ In read-only mode, only [readonly SQL operations](https://github.com/bytebase/dbhub/blob/main/src/utils/allowed-keywords.ts) are allowed.
181
+
182
+ This provides an additional layer of security when connecting to production databases.
183
+
142
184
  ### SSL Connections
143
185
 
144
186
  You can specify the SSL mode using the `sslmode` parameter in your DSN string:
145
187
 
146
- | Database | `sslmode=disable` | `sslmode=require` | Default SSL Behavior |
147
- | ---------- | :---------------: | :---------------: | :----------------------------: |
148
- | PostgreSQL | ✅ | ✅ | Certificate verification |
149
- | MySQL | ✅ | ✅ | Certificate verification |
150
- | MariaDB | ✅ | ✅ | Certificate verification |
151
- | SQL Server | ✅ | ✅ | Certificate verification |
188
+ | Database | `sslmode=disable` | `sslmode=require` | Default SSL Behavior |
189
+ | ---------- | :---------------: | :---------------: | :----------------------: |
190
+ | PostgreSQL | ✅ | ✅ | Certificate verification |
191
+ | MySQL | ✅ | ✅ | Certificate verification |
192
+ | MariaDB | ✅ | ✅ | Certificate verification |
193
+ | SQL Server | ✅ | ✅ | Certificate verification |
194
+ | SQLite | ❌ | ❌ | N/A (file-based) |
152
195
 
153
196
  **SSL Mode Options:**
154
197
 
@@ -170,21 +213,61 @@ postgres://user:password@localhost:5432/dbname?sslmode=require
170
213
  postgres://user:password@localhost:5432/dbname
171
214
  ```
172
215
 
173
- ### Read-only Mode
216
+ ### SSH Tunnel Support
174
217
 
175
- You can run DBHub in read-only mode, which restricts SQL query execution to read-only operations:
218
+ DBHub supports connecting to databases through SSH tunnels, enabling secure access to databases in private networks or behind firewalls.
219
+
220
+ #### SSH with Password Authentication
176
221
 
177
222
  ```bash
178
- # Enable read-only mode
179
- npx @bytebase/dbhub --readonly --dsn "postgres://user:password@localhost:5432/dbname"
223
+ npx @bytebase/dbhub \
224
+ --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb" \
225
+ --ssh-host bastion.example.com \
226
+ --ssh-user ubuntu \
227
+ --ssh-password mypassword
180
228
  ```
181
229
 
182
- In read-only mode, only [readonly SQL operations](https://github.com/bytebase/dbhub/blob/main/src/utils/allowed-keywords.ts) are allowed.
230
+ #### SSH with Private Key Authentication
183
231
 
184
- This provides an additional layer of security when connecting to production databases.
232
+ ```bash
233
+ npx @bytebase/dbhub \
234
+ --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb" \
235
+ --ssh-host bastion.example.com \
236
+ --ssh-user ubuntu \
237
+ --ssh-key ~/.ssh/id_rsa
238
+ ```
239
+
240
+ #### SSH with Private Key and Passphrase
241
+
242
+ ```bash
243
+ npx @bytebase/dbhub \
244
+ --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb" \
245
+ --ssh-host bastion.example.com \
246
+ --ssh-port 2222 \
247
+ --ssh-user ubuntu \
248
+ --ssh-key ~/.ssh/id_rsa \
249
+ --ssh-passphrase mykeypassphrase
250
+ ```
251
+
252
+ #### Using Environment Variables
253
+
254
+ ```bash
255
+ export SSH_HOST=bastion.example.com
256
+ export SSH_USER=ubuntu
257
+ export SSH_KEY=~/.ssh/id_rsa
258
+ npx @bytebase/dbhub --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb"
259
+ ```
260
+
261
+ **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.
185
262
 
186
263
  ### Configure your database connection
187
264
 
265
+ You can use DBHub in demo mode with a sample employee database for testing:
266
+
267
+ ```bash
268
+ npx @bytebase/dbhub --demo
269
+ ```
270
+
188
271
  > [!WARNING]
189
272
  > If your user/password contains special characters, you need to escape them first. (e.g. `pass#word` should be escaped as `pass%23word`)
190
273
 
@@ -215,13 +298,13 @@ For real databases, a Database Source Name (DSN) is required. You can provide th
215
298
 
216
299
  DBHub supports the following database connection string formats:
217
300
 
218
- | Database | DSN Format | Example |
219
- | ---------- | --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
220
- | MySQL | `mysql://[user]:[password]@[host]:[port]/[database]` | `mysql://user:password@localhost:3306/dbname?sslmode=disable` |
221
- | MariaDB | `mariadb://[user]:[password]@[host]:[port]/[database]` | `mariadb://user:password@localhost:3306/dbname?sslmode=disable` |
222
- | PostgreSQL | `postgres://[user]:[password]@[host]:[port]/[database]` | `postgres://user:password@localhost:5432/dbname?sslmode=disable` |
223
- | SQL Server | `sqlserver://[user]:[password]@[host]:[port]/[database]` | `sqlserver://user:password@localhost:1433/dbname?sslmode=disable` |
224
-
301
+ | Database | DSN Format | Example |
302
+ | ---------- | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
303
+ | MySQL | `mysql://[user]:[password]@[host]:[port]/[database]` | `mysql://user:password@localhost:3306/dbname?sslmode=disable` |
304
+ | MariaDB | `mariadb://[user]:[password]@[host]:[port]/[database]` | `mariadb://user:password@localhost:3306/dbname?sslmode=disable` |
305
+ | PostgreSQL | `postgres://[user]:[password]@[host]:[port]/[database]` | `postgres://user:password@localhost:5432/dbname?sslmode=disable` |
306
+ | SQL Server | `sqlserver://[user]:[password]@[host]:[port]/[database]` | `sqlserver://user:password@localhost:1433/dbname?sslmode=disable` |
307
+ | SQLite | `sqlite:///[path/to/file]` or `sqlite:///:memory:` | `sqlite:///path/to/database.db`, `sqlite:C:/Users/YourName/data/database.db (windows)` or `sqlite:///:memory:` |
225
308
 
226
309
  #### SQL Server
227
310
 
@@ -246,13 +329,21 @@ Extra query parameters:
246
329
 
247
330
  ### Command line options
248
331
 
249
- | Option | Environment Variable | Description | Default |
250
- | --------- | -------------------- | ---------------------------------------------------------------- | -------- |
251
- | dsn | `DSN` | Database connection string | Required |
252
- | transport | `TRANSPORT` | Transport mode: `stdio` or `http` | `stdio` |
253
- | port | `PORT` | HTTP server port (only applicable when using `--transport=http`) | `8080` |
254
- | readonly | `READONLY` | Restrict SQL execution to read-only operations | `false` |
255
-
332
+ | Option | Environment Variable | Description | Default |
333
+ | -------------- | -------------------- | ---------------------------------------------------------------- | ---------------------------- |
334
+ | dsn | `DSN` | Database connection string | Required if not in demo mode |
335
+ | transport | `TRANSPORT` | Transport mode: `stdio` or `http` | `stdio` |
336
+ | port | `PORT` | HTTP server port (only applicable when using `--transport=http`) | `8080` |
337
+ | readonly | `READONLY` | Restrict SQL execution to read-only operations | `false` |
338
+ | demo | N/A | Run in demo mode with sample employee database | `false` |
339
+ | ssh-host | `SSH_HOST` | SSH server hostname for tunnel connection | N/A |
340
+ | ssh-port | `SSH_PORT` | SSH server port | `22` |
341
+ | ssh-user | `SSH_USER` | SSH username | N/A |
342
+ | ssh-password | `SSH_PASSWORD` | SSH password (for password authentication) | N/A |
343
+ | ssh-key | `SSH_KEY` | Path to SSH private key file | N/A |
344
+ | ssh-passphrase | `SSH_PASSPHRASE` | Passphrase for SSH private key | N/A |
345
+
346
+ 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.
256
347
 
257
348
  ## Development
258
349
 
@@ -310,6 +401,8 @@ pnpm test src/connectors/__tests__/mysql.integration.test.ts
310
401
  pnpm test src/connectors/__tests__/mariadb.integration.test.ts
311
402
  # Run only SQL Server integration tests
312
403
  pnpm test src/connectors/__tests__/sqlserver.integration.test.ts
404
+ # Run only SQLite integration tests
405
+ pnpm test src/connectors/__tests__/sqlite.integration.test.ts
313
406
  # Run JSON RPC integration tests
314
407
  pnpm test src/__tests__/json-rpc-integration.test.ts
315
408
  ```
@@ -345,7 +438,6 @@ docker pull mcr.microsoft.com/mssql/server:2019-latest
345
438
  - Ensure Docker has sufficient memory allocated (4GB+ recommended)
346
439
  - Consider running SQL Server tests separately if experiencing timeouts
347
440
 
348
-
349
441
  **Network/Resource Issues:**
350
442
 
351
443
  ```bash