@zz1996/dbhub-dameng 0.1.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.
@@ -0,0 +1,143 @@
1
+ # Dameng/DM8 Connector Plan
2
+
3
+ This fork tracks the work needed to add Dameng/DM8 support to DBHub without
4
+ changing DBHub's MCP surface area. The desired result is that agents can keep
5
+ using `search_objects` and `execute_sql`, while Dameng behaves like the existing
6
+ PostgreSQL/MySQL/SQL Server/SQLite connectors.
7
+
8
+ ## Current Baseline
9
+
10
+ - Upstream repository: `https://github.com/bytebase/dbhub.git`
11
+ - Local branch: `dameng-connector`
12
+ - Upstream connector types currently include PostgreSQL, MySQL, MariaDB,
13
+ SQL Server, and SQLite.
14
+ - DBHub is MIT licensed, so this fork can be modified and used locally while
15
+ preserving the upstream license notice.
16
+
17
+ ## Implementation Checklist
18
+
19
+ 1. Add `dameng` to connector type definitions.
20
+ - `src/connectors/interface.ts`
21
+ - `src/types/config.ts`
22
+ - `src/api/openapi.yaml`
23
+ - regenerate `src/api/openapi.d.ts`
24
+
25
+ 2. Add DSN support.
26
+ - Accept `dameng://user:password@host:5236/schema`.
27
+ - Map default port `5236`.
28
+ - Update `src/utils/dsn-obfuscate.ts`.
29
+
30
+ 3. Add driver loading.
31
+ - Add optional dependency `dmdb`.
32
+ - Add a lazy loader entry in `src/index.ts`.
33
+ - Keep startup behavior consistent with other optional database drivers.
34
+
35
+ 4. Implement `src/connectors/dameng/index.ts`.
36
+ - `clone`
37
+ - `connect`
38
+ - `disconnect`
39
+ - `getSchemas`
40
+ - `getDefaultSchema`
41
+ - `getTables`
42
+ - `getViews`
43
+ - `getTableSchema`
44
+ - `tableExists`
45
+ - `getTableIndexes`
46
+ - `getStoredProcedures`
47
+ - `getStoredProcedureDetail`
48
+ - `getTableRowCount`
49
+ - `getTableComment`
50
+ - `executeSQL`
51
+
52
+ 5. Add read-only handling.
53
+ - Add Dameng allowed keywords in `src/utils/allowed-keywords.ts`.
54
+ - Add Dameng scanner fallback in `src/utils/sql-parser.ts` if needed.
55
+ - Prefer database account permissions as the primary safety boundary.
56
+
57
+ 6. Add identifier quoting and parameter mapping.
58
+ - `src/utils/identifier-quoter.ts`
59
+ - `src/utils/parameter-mapper.ts`
60
+ - Dameng generally accepts Oracle-style uppercase identifiers and bind
61
+ variables; verify actual `dmdb` binding shape before finalizing.
62
+
63
+ 7. Add docs and examples.
64
+ - `dbhub.dameng.toml.example`
65
+ - README support list
66
+ - docs installation/configuration references if this fork is published.
67
+
68
+ 8. Add tests.
69
+ - Unit tests for DSN parsing and readonly SQL classification.
70
+ - Connector tests against a reachable DM8 instance when available.
71
+ - Build smoke test before using the MCP server in an agent.
72
+
73
+ ## Useful Catalog Queries
74
+
75
+ List schemas:
76
+
77
+ ```sql
78
+ SELECT USERNAME AS SCHEMA_NAME
79
+ FROM ALL_USERS
80
+ WHERE USERNAME NOT IN ('SYS', 'SYSTEM', 'SYSAUDITOR', 'SYSSSO', 'CTISYS')
81
+ ORDER BY USERNAME;
82
+ ```
83
+
84
+ List tables:
85
+
86
+ ```sql
87
+ SELECT TABLE_NAME
88
+ FROM ALL_TABLES
89
+ WHERE OWNER = :owner
90
+ ORDER BY TABLE_NAME;
91
+ ```
92
+
93
+ List columns:
94
+
95
+ ```sql
96
+ SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH, DATA_PRECISION, DATA_SCALE,
97
+ NULLABLE, DATA_DEFAULT, COLUMN_ID
98
+ FROM ALL_TAB_COLUMNS
99
+ WHERE OWNER = :owner AND TABLE_NAME = :table
100
+ ORDER BY COLUMN_ID;
101
+ ```
102
+
103
+ List indexes:
104
+
105
+ ```sql
106
+ SELECT i.INDEX_NAME, i.UNIQUENESS, ic.COLUMN_NAME, ic.COLUMN_POSITION
107
+ FROM ALL_INDEXES i
108
+ JOIN ALL_IND_COLUMNS ic
109
+ ON i.OWNER = ic.INDEX_OWNER AND i.INDEX_NAME = ic.INDEX_NAME
110
+ WHERE i.TABLE_OWNER = :owner AND i.TABLE_NAME = :table
111
+ ORDER BY i.INDEX_NAME, ic.COLUMN_POSITION;
112
+ ```
113
+
114
+ Table comments:
115
+
116
+ ```sql
117
+ SELECT COMMENTS
118
+ FROM ALL_TAB_COMMENTS
119
+ WHERE OWNER = :owner AND TABLE_NAME = :table;
120
+ ```
121
+
122
+ Column comments:
123
+
124
+ ```sql
125
+ SELECT COLUMN_NAME, COMMENTS
126
+ FROM ALL_COL_COMMENTS
127
+ WHERE OWNER = :owner AND TABLE_NAME = :table;
128
+ ```
129
+
130
+ ## Suggested First Milestone
131
+
132
+ Build the minimum useful connector first:
133
+
134
+ - DSN parser
135
+ - `connect` / `disconnect`
136
+ - `executeSQL`
137
+ - `getSchemas`
138
+ - `getTables`
139
+ - `getTableSchema`
140
+ - readonly keyword support
141
+
142
+ After that, wire the connector into `search_objects` and test agent behavior
143
+ with `detail_level: "names"` before adding richer metadata.
package/package.json ADDED
@@ -0,0 +1,110 @@
1
+ {
2
+ "name": "@zz1996/dbhub-dameng",
3
+ "version": "0.1.0",
4
+ "mcpName": "io.github.zuozh11/dbhub-dameng",
5
+ "description": "Local fork of DBHub with Dameng/DM8 database connector support",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/zuozh11/dbhub-dameng.git"
9
+ },
10
+ "homepage": "https://github.com/zuozh11/dbhub-dameng#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/zuozh11/dbhub-dameng/issues"
13
+ },
14
+ "main": "dist/index.js",
15
+ "type": "module",
16
+ "bin": {
17
+ "dbhub-dameng": "dist/index.js"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "dbhub.dameng.toml.example",
22
+ "docs/dameng-connector-plan.md",
23
+ "LICENSE",
24
+ "README.md"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "scripts": {
30
+ "build": "pnpm run generate:api-types && tsup && cd frontend && pnpm run build",
31
+ "build:backend": "npm run generate:api-types && tsup",
32
+ "build:frontend": "cd frontend && pnpm run build",
33
+ "start": "node dist/index.js",
34
+ "dev": "concurrently --kill-others \"pnpm run dev:backend\" \"pnpm run dev:frontend\"",
35
+ "dev:backend": "NODE_ENV=development tsx src/index.ts --transport=http",
36
+ "dev:frontend": "cd frontend && pnpm run dev",
37
+ "crossdev": "cross-env NODE_ENV=development tsx src/index.ts",
38
+ "generate:api-types": "openapi-typescript src/api/openapi.yaml -o src/api/openapi.d.ts",
39
+ "test": "vitest run",
40
+ "test:unit": "vitest run --project unit",
41
+ "test:watch": "vitest",
42
+ "test:integration": "vitest run --project integration",
43
+ "test:build": "node scripts/smoke-test-build.mjs",
44
+ "prepublishOnly": "npm run build:backend"
45
+ },
46
+ "engines": {
47
+ "node": ">=22.5.0"
48
+ },
49
+ "packageManager": "pnpm@10.17.1",
50
+ "keywords": [
51
+ "mcp",
52
+ "database",
53
+ "dbhub",
54
+ "dameng",
55
+ "dm8"
56
+ ],
57
+ "author": "zuozh11",
58
+ "license": "MIT",
59
+ "dependencies": {
60
+ "@iarna/toml": "^2.2.5",
61
+ "@modelcontextprotocol/sdk": "^1.25.1",
62
+ "dotenv": "^16.4.7",
63
+ "express": "^4.18.2",
64
+ "ssh-config": "^5.0.3",
65
+ "ssh2": "^1.16.0",
66
+ "zod": "^3.24.2"
67
+ },
68
+ "optionalDependencies": {
69
+ "@aws-sdk/rds-signer": "^3.1001.0",
70
+ "@azure/identity": "^4.8.0",
71
+ "mariadb": "^3.4.0",
72
+ "mssql": "^11.0.1",
73
+ "mysql2": "^3.13.0",
74
+ "pg": "^8.13.3",
75
+ "dmdb": "^1.0.49630"
76
+ },
77
+ "devDependencies": {
78
+ "@testcontainers/mariadb": "^11.0.3",
79
+ "@testcontainers/mssqlserver": "^11.0.3",
80
+ "@testcontainers/mysql": "^11.0.3",
81
+ "@testcontainers/postgresql": "^11.0.3",
82
+ "@types/express": "^4.17.21",
83
+ "@types/mssql": "^9.1.7",
84
+ "@types/node": "^22.13.10",
85
+ "@types/pg": "^8.11.11",
86
+ "@types/ssh2": "^1.15.5",
87
+ "concurrently": "^9.2.1",
88
+ "cross-env": "^7.0.3",
89
+ "openapi-typescript": "^7.10.1",
90
+ "prettier": "^3.5.3",
91
+ "testcontainers": "^11.0.3",
92
+ "ts-node": "^10.9.2",
93
+ "tsup": "^8.4.0",
94
+ "tsx": "^4.19.3",
95
+ "typescript": "^5.8.2",
96
+ "vitest": "^4.0.6"
97
+ },
98
+ "compilerOptions": {
99
+ "target": "ES2020",
100
+ "module": "NodeNext",
101
+ "moduleResolution": "NodeNext",
102
+ "esModuleInterop": true,
103
+ "strict": true,
104
+ "outDir": "dist",
105
+ "rootDir": "src"
106
+ },
107
+ "include": [
108
+ "src/**/*"
109
+ ]
110
+ }