Skip to content

Commit 042459c

Browse files
committed
fix: Enforce read-only mode, add connection whitelist, improve unsupported driver errors
- Fix read-only mode bypass: execute_query now enforces SELECT-only, transaction tools blocked in read-only mode (fixes #19) - Add DBEAVER_ALLOWED_CONNECTIONS env var for connection whitelisting (fixes #20) - Improve error messages for unsupported database drivers with clear guidance on supported drivers and workarounds (fixes #17) - Fix UPDATE validation regex that incorrectly blocked UPDATE with WHERE - Fix infinite recursion in connection wrapper methods - Bump version to 1.2.5 - Update README, CHANGELOG, example config with new features
1 parent eaab237 commit 042459c

5 files changed

Lines changed: 64 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.2.5] - 2026-02-15
9+
10+
### Added
11+
- Connection whitelist via `DBEAVER_ALLOWED_CONNECTIONS` environment variable — restrict which DBeaver connections are visible by ID or name
12+
- `enforceReadOnly()` query-level enforcement — `execute_query` now strictly allows only read-only statements (SELECT, EXPLAIN, SHOW, DESCRIBE, PRAGMA)
13+
- Test queries for SAP HANA (`SELECT * FROM DUMMY`) and DB2 (`SYSIBM.SYSDUMMY1`)
14+
15+
### Fixed
16+
- **Read-only mode bypass (Issue #19)**: `execute_query` no longer allows write operations (INSERT/UPDATE/DELETE/CREATE/ALTER/DROP). Transaction tools (`begin_transaction`, `commit_transaction`, `rollback_transaction`, `execute_in_transaction`) are now blocked in read-only mode.
17+
- **Unsupported driver errors (Issue #17)**: DBeaver CLI fallback now provides clear, actionable error messages listing natively supported drivers and workarounds. DBeaver availability is checked before attempting CLI fallback.
18+
- **UPDATE validation regex**: `UPDATE ... SET ... WHERE ...` was incorrectly blocked by the dangerous query filter. The regex now correctly allows UPDATE with WHERE clause.
19+
20+
### Changed
21+
- DBeaver CLI fallback uses connection name-based spec for better compatibility
22+
823
## [1.2.4] - 2026-01-15
924

1025
### Added

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_
5757
| `DBEAVER_TIMEOUT` | Query timeout (ms) | `30000` |
5858
| `DBEAVER_DEBUG` | Enable debug logging | `false` |
5959
| `DBEAVER_READ_ONLY` | Disable write operations | `false` |
60+
| `DBEAVER_ALLOWED_CONNECTIONS` | Comma-separated whitelist of connection IDs or names | All |
6061
| `DBEAVER_DISABLED_TOOLS` | Comma-separated tools to disable | None |
6162
| `DBEAVER_POOL_MIN` | Minimum connections per pool | `2` |
6263
| `DBEAVER_POOL_MAX` | Maximum connections per pool | `10` |
@@ -78,6 +79,23 @@ Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_
7879
}
7980
```
8081

82+
### Connection Whitelist
83+
84+
Restrict which DBeaver connections are visible to the AI assistant. Accepts connection IDs or display names, comma-separated:
85+
86+
```json
87+
{
88+
"mcpServers": {
89+
"dbeaver": {
90+
"command": "dbeaver-mcp-server",
91+
"env": {
92+
"DBEAVER_ALLOWED_CONNECTIONS": "dev-postgres,staging-mysql"
93+
}
94+
}
95+
}
96+
}
97+
```
98+
8199
### Disable Specific Tools
82100

83101
```json

examples/claude-desktop-config.json

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
}
1010
},
1111
"explanation": {
12-
"purpose": "Enhanced DBeaver MCP Server configuration for Claude Desktop",
12+
"purpose": "DBeaver MCP Server configuration for Claude Desktop",
1313
"features": [
14-
"Universal database support (200+ databases)",
15-
"Resource-based schema browsing",
16-
"Business insights tracking",
17-
"Complete DDL operations",
18-
"Multiple export formats",
19-
"Advanced safety features"
14+
"Native query execution for PostgreSQL, MySQL/MariaDB, SQLite, SQL Server",
15+
"DBeaver CLI fallback for other database types",
16+
"Connection pooling and transaction support",
17+
"Query execution plan analysis (EXPLAIN)",
18+
"Schema comparison between connections",
19+
"Connection whitelisting for access control",
20+
"Read-only mode and tool filtering",
21+
"Data export to CSV/JSON"
2022
],
2123
"tools_available": [
2224
"list_connections",
23-
"get_connection_info",
25+
"get_connection_info",
2426
"execute_query",
2527
"write_query",
2628
"create_table",
@@ -31,19 +33,31 @@
3133
"export_data",
3234
"test_connection",
3335
"get_database_stats",
36+
"begin_transaction",
37+
"commit_transaction",
38+
"rollback_transaction",
39+
"execute_in_transaction",
40+
"explain_query",
41+
"compare_schemas",
42+
"get_pool_stats",
3443
"append_insight",
3544
"list_insights"
3645
],
3746
"environment_variables": {
3847
"DBEAVER_PATH": "Custom path to DBeaver executable (auto-detected if not set)",
48+
"DBEAVER_WORKSPACE": "Custom DBeaver workspace path (OS default if not set)",
3949
"DBEAVER_TIMEOUT": "Query timeout in milliseconds (default: 30000)",
40-
"DBEAVER_DEBUG": "Enable debug logging (true/false)"
50+
"DBEAVER_DEBUG": "Enable debug logging (true/false)",
51+
"DBEAVER_READ_ONLY": "Disable all write operations (true/false)",
52+
"DBEAVER_ALLOWED_CONNECTIONS": "Comma-separated whitelist of connection IDs or names",
53+
"DBEAVER_DISABLED_TOOLS": "Comma-separated list of tools to disable"
4154
},
4255
"configuration_examples": {
4356
"production": {
4457
"command": "dbeaver-mcp-server",
4558
"env": {
46-
"DBEAVER_DEBUG": "false",
59+
"DBEAVER_READ_ONLY": "true",
60+
"DBEAVER_ALLOWED_CONNECTIONS": "prod-readonly",
4761
"DBEAVER_TIMEOUT": "60000"
4862
}
4963
},
@@ -54,12 +68,12 @@
5468
"DBEAVER_TIMEOUT": "30000"
5569
}
5670
},
57-
"custom_path": {
71+
"restricted": {
5872
"command": "dbeaver-mcp-server",
5973
"env": {
60-
"DBEAVER_PATH": "/custom/path/to/dbeaver",
61-
"DBEAVER_DEBUG": "false",
62-
"DBEAVER_TIMEOUT": "45000"
74+
"DBEAVER_READ_ONLY": "true",
75+
"DBEAVER_DISABLED_TOOLS": "drop_table,alter_table",
76+
"DBEAVER_ALLOWED_CONNECTIONS": "analytics-db,reporting-db"
6377
}
6478
}
6579
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dbeaver-mcp-server",
3-
"version": "1.2.4",
3+
"version": "1.2.5",
44
"description": "Production-ready Model Context Protocol server for universal database access through DBeaver connections - supports 200+ database types",
55
"main": "dist/index.js",
66
"type": "module",

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class DBeaverMCPServer {
176176
* Get all connections, filtered by the whitelist.
177177
*/
178178
private async getFilteredConnections(): Promise<DBeaverConnection[]> {
179-
const connections = await this.getFilteredConnections();
179+
const connections = await this.configParser.parseConnections();
180180
if (!this.allowedConnections) return connections;
181181
return connections.filter((conn) => this.isConnectionAllowed(conn));
182182
}
@@ -185,7 +185,7 @@ class DBeaverMCPServer {
185185
* Get a single connection by ID/name, respecting the whitelist.
186186
*/
187187
private async getConnection(connectionId: string): Promise<DBeaverConnection | null> {
188-
const connection = await this.getConnection(connectionId);
188+
const connection = await this.configParser.getConnection(connectionId);
189189
if (!connection) return null;
190190
if (!this.isConnectionAllowed(connection)) return null;
191191
return connection;

0 commit comments

Comments
 (0)