@bytebase/dbhub 0.12.0 → 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 CHANGED
@@ -36,19 +36,19 @@ DBHub is a Universal Database MCP Server implementing the Model Context Protocol
36
36
  - **Secure Access**: Read-only mode, SSH tunneling, and SSL/TLS encryption support
37
37
  - **Multi-Database**: Connect to multiple databases simultaneously with TOML configuration
38
38
  - **Production-Ready**: Row limiting, lock timeout control, and connection pooling
39
- - **MCP Native**: Full implementation of Model Context Protocol with resources, tools, and prompts
39
+ - **MCP Native**: Full implementation of Model Context Protocol with comprehensive tools
40
40
 
41
41
  ## Supported Databases
42
42
 
43
43
  PostgreSQL, MySQL, SQL Server, MariaDB, and SQLite.
44
44
 
45
- ## MCP Components
45
+ ## MCP Tools
46
46
 
47
- DBHub implements MCP Resources, Tools, and Prompts for database operations:
47
+ DBHub implements MCP tools for database operations:
48
48
 
49
- - **[Resources](https://dbhub.ai/components/resources)**: Database schema exploration (schemas, tables, indexes, procedures)
50
- - **[Tools](https://dbhub.ai/components/tools)**: SQL execution with transaction support
51
- - **[Prompts](https://dbhub.ai/components/prompts)**: AI-assisted SQL generation and database explanation
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
52
52
 
53
53
  ## Installation
54
54
 
@@ -0,0 +1,10 @@
1
+ import {
2
+ BUILTIN_TOOLS,
3
+ BUILTIN_TOOL_EXECUTE_SQL,
4
+ BUILTIN_TOOL_SEARCH_OBJECTS
5
+ } from "./chunk-D23WQQY7.js";
6
+ export {
7
+ BUILTIN_TOOLS,
8
+ BUILTIN_TOOL_EXECUTE_SQL,
9
+ BUILTIN_TOOL_SEARCH_OBJECTS
10
+ };
@@ -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
+ };