@bytebase/dbhub 0.11.10 → 0.13.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 +38 -29
- package/dist/builtin-tools-SVENYBIA.js +10 -0
- package/dist/chunk-D23WQQY7.js +13 -0
- package/dist/chunk-VWZF5OAJ.js +112 -0
- package/dist/chunk-WSLDVMBA.js +1773 -0
- package/dist/custom-tool-registry-EW3KOBGC.js +7 -0
- package/dist/index.js +1205 -2094
- package/dist/public/assets/index-gVrYRID4.css +1 -0
- package/dist/public/assets/index-hd88eD9m.js +51 -0
- package/dist/public/index.html +2 -2
- package/dist/registry-GJGPWR3I.js +11 -0
- package/package.json +3 -3
- package/dist/public/assets/index--LC9Foha.css +0 -1
- package/dist/public/assets/index-BZTaHJm6.js +0 -51
package/README.md
CHANGED
|
@@ -11,42 +11,44 @@
|
|
|
11
11
|
</a>
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
|
-

|
|
15
|
-
|
|
16
|
-
</p>
|
|
17
|
-
|
|
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.
|
|
19
|
-
|
|
20
14
|
```bash
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
+------------------+ +--------------+ +------------------+
|
|
16
|
+
| | | | | |
|
|
17
|
+
| | | | | |
|
|
18
|
+
| Claude Desktop +--->+ +--->+ PostgreSQL |
|
|
19
|
+
| | | | | |
|
|
20
|
+
| Claude Code +--->+ +--->+ SQL Server |
|
|
21
|
+
| | | | | |
|
|
22
|
+
| Cursor +--->+ DBHub +--->+ SQLite |
|
|
23
|
+
| | | | | |
|
|
24
|
+
| VS Code +--->+ +--->+ MySQL |
|
|
25
|
+
| | | | | |
|
|
26
|
+
| Other Clients +--->+ +--->+ MariaDB |
|
|
27
|
+
| | | | | |
|
|
28
|
+
| | | | | |
|
|
29
|
+
+------------------+ +--------------+ +------------------+
|
|
30
|
+
MCP Clients MCP Server Databases
|
|
37
31
|
```
|
|
38
32
|
|
|
33
|
+
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:
|
|
34
|
+
|
|
35
|
+
- **Universal Gateway**: Single interface for PostgreSQL, MySQL, MariaDB, SQL Server, and SQLite
|
|
36
|
+
- **Secure Access**: Read-only mode, SSH tunneling, and SSL/TLS encryption support
|
|
37
|
+
- **Multi-Database**: Connect to multiple databases simultaneously with TOML configuration
|
|
38
|
+
- **Production-Ready**: Row limiting, lock timeout control, and connection pooling
|
|
39
|
+
- **MCP Native**: Full implementation of Model Context Protocol with comprehensive tools
|
|
40
|
+
|
|
39
41
|
## Supported Databases
|
|
40
42
|
|
|
41
43
|
PostgreSQL, MySQL, SQL Server, MariaDB, and SQLite.
|
|
42
44
|
|
|
43
|
-
## MCP
|
|
45
|
+
## MCP Tools
|
|
44
46
|
|
|
45
|
-
DBHub implements MCP
|
|
47
|
+
DBHub implements MCP tools for database operations:
|
|
46
48
|
|
|
47
|
-
- **[
|
|
48
|
-
- **[
|
|
49
|
-
- **[
|
|
49
|
+
- **[execute_sql](https://dbhub.ai/tools/execute-sql)**: Execute SQL queries with transaction support and safety controls
|
|
50
|
+
- **[search_objects](https://dbhub.ai/tools/search-objects)**: Search and explore database schemas, tables, columns, indexes, and procedures with progressive disclosure
|
|
51
|
+
- **[Custom Tools](https://dbhub.ai/tools/custom-tools)**: Define reusable, parameterized SQL operations in your `dbhub.toml` configuration file
|
|
50
52
|
|
|
51
53
|
## Installation
|
|
52
54
|
|
|
@@ -55,6 +57,7 @@ See the full [Installation Guide](https://dbhub.ai/installation) for detailed in
|
|
|
55
57
|
### Quick Start
|
|
56
58
|
|
|
57
59
|
**Docker:**
|
|
60
|
+
|
|
58
61
|
```bash
|
|
59
62
|
docker run --rm --init \
|
|
60
63
|
--name dbhub \
|
|
@@ -66,13 +69,15 @@ docker run --rm --init \
|
|
|
66
69
|
```
|
|
67
70
|
|
|
68
71
|
**NPM:**
|
|
72
|
+
|
|
69
73
|
```bash
|
|
70
74
|
npx @bytebase/dbhub --transport http --port 8080 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
|
|
71
75
|
```
|
|
72
76
|
|
|
73
77
|
**Demo Mode:**
|
|
78
|
+
|
|
74
79
|
```bash
|
|
75
|
-
npx @bytebase/dbhub --transport http --port 8080 --
|
|
80
|
+
npx @bytebase/dbhub --transport http --port 8080 --demo
|
|
76
81
|
```
|
|
77
82
|
|
|
78
83
|
See [Server Options](https://dbhub.ai/config/server-options) for all available parameters.
|
|
@@ -107,7 +112,7 @@ See [Multi-Database Configuration](https://dbhub.ai/config/multi-database) for c
|
|
|
107
112
|
|
|
108
113
|
See [TESTING.md](.claude/skills/testing/SKILL.md).
|
|
109
114
|
|
|
110
|
-
### Debug
|
|
115
|
+
### Debug
|
|
111
116
|
|
|
112
117
|
See [Debug](https://dbhub.ai/config/debug).
|
|
113
118
|
|
|
@@ -116,3 +121,7 @@ See [Debug](https://dbhub.ai/config/debug).
|
|
|
116
121
|
<a href="https://github.com/bytebase/dbhub/graphs/contributors">
|
|
117
122
|
<img src="https://contrib.rocks/image?repo=bytebase/dbhub" />
|
|
118
123
|
</a>
|
|
124
|
+
|
|
125
|
+
## Star History
|
|
126
|
+
|
|
127
|
+

|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/tools/builtin-tools.ts
|
|
2
|
+
var BUILTIN_TOOL_EXECUTE_SQL = "execute_sql";
|
|
3
|
+
var BUILTIN_TOOL_SEARCH_OBJECTS = "search_objects";
|
|
4
|
+
var BUILTIN_TOOLS = [
|
|
5
|
+
BUILTIN_TOOL_EXECUTE_SQL,
|
|
6
|
+
BUILTIN_TOOL_SEARCH_OBJECTS
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
BUILTIN_TOOL_EXECUTE_SQL,
|
|
11
|
+
BUILTIN_TOOL_SEARCH_OBJECTS,
|
|
12
|
+
BUILTIN_TOOLS
|
|
13
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BUILTIN_TOOLS
|
|
3
|
+
} from "./chunk-D23WQQY7.js";
|
|
4
|
+
|
|
5
|
+
// src/tools/registry.ts
|
|
6
|
+
var ToolRegistry = class {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.toolsBySource = this.buildRegistry(config);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check if a tool name is a built-in tool
|
|
12
|
+
*/
|
|
13
|
+
isBuiltinTool(toolName) {
|
|
14
|
+
return BUILTIN_TOOLS.includes(toolName);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Build the internal registry mapping sources to their enabled tools
|
|
18
|
+
*/
|
|
19
|
+
buildRegistry(config) {
|
|
20
|
+
const registry = /* @__PURE__ */ new Map();
|
|
21
|
+
for (const tool of config.tools || []) {
|
|
22
|
+
const existing = registry.get(tool.source) || [];
|
|
23
|
+
existing.push(tool);
|
|
24
|
+
registry.set(tool.source, existing);
|
|
25
|
+
}
|
|
26
|
+
for (const source of config.sources) {
|
|
27
|
+
if (!registry.has(source.id)) {
|
|
28
|
+
const defaultTools = BUILTIN_TOOLS.map((name) => {
|
|
29
|
+
if (name === "execute_sql") {
|
|
30
|
+
return { name: "execute_sql", source: source.id };
|
|
31
|
+
} else {
|
|
32
|
+
return { name: "search_objects", source: source.id };
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
registry.set(source.id, defaultTools);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return registry;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get all tools enabled for a specific source
|
|
42
|
+
*/
|
|
43
|
+
getToolsForSource(sourceId) {
|
|
44
|
+
return this.toolsBySource.get(sourceId) || [];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get built-in tool configuration for a specific source
|
|
48
|
+
* Returns undefined if tool is not enabled or not a built-in
|
|
49
|
+
*/
|
|
50
|
+
getBuiltinToolConfig(toolName, sourceId) {
|
|
51
|
+
if (!this.isBuiltinTool(toolName)) {
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
const tools = this.getToolsForSource(sourceId);
|
|
55
|
+
return tools.find((t) => t.name === toolName);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get all unique tools across all sources (for tools/list response)
|
|
59
|
+
* Returns the union of all enabled tools
|
|
60
|
+
*/
|
|
61
|
+
getAllTools() {
|
|
62
|
+
const seen = /* @__PURE__ */ new Set();
|
|
63
|
+
const result = [];
|
|
64
|
+
for (const tools of this.toolsBySource.values()) {
|
|
65
|
+
for (const tool of tools) {
|
|
66
|
+
if (!seen.has(tool.name)) {
|
|
67
|
+
seen.add(tool.name);
|
|
68
|
+
result.push(tool);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get all custom tools (non-builtin) across all sources
|
|
76
|
+
*/
|
|
77
|
+
getCustomTools() {
|
|
78
|
+
return this.getAllTools().filter((tool) => !this.isBuiltinTool(tool.name));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get all built-in tool names that are enabled across any source
|
|
82
|
+
*/
|
|
83
|
+
getEnabledBuiltinToolNames() {
|
|
84
|
+
const enabledBuiltins = /* @__PURE__ */ new Set();
|
|
85
|
+
for (const tools of this.toolsBySource.values()) {
|
|
86
|
+
for (const tool of tools) {
|
|
87
|
+
if (this.isBuiltinTool(tool.name)) {
|
|
88
|
+
enabledBuiltins.add(tool.name);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return Array.from(enabledBuiltins);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var globalRegistry = null;
|
|
96
|
+
function initializeToolRegistry(config) {
|
|
97
|
+
globalRegistry = new ToolRegistry(config);
|
|
98
|
+
}
|
|
99
|
+
function getToolRegistry() {
|
|
100
|
+
if (!globalRegistry) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
"Tool registry not initialized. Call initializeToolRegistry first."
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return globalRegistry;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
ToolRegistry,
|
|
110
|
+
initializeToolRegistry,
|
|
111
|
+
getToolRegistry
|
|
112
|
+
};
|