db-mcp 1.0.2 → 1.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.
Files changed (241) hide show
  1. package/.gitattributes +2 -0
  2. package/LICENSE +1 -1
  3. package/README.md +244 -518
  4. package/dist/chunk-4IA3DB5C.js +135 -0
  5. package/dist/chunk-AOUL5SHS.js +930 -0
  6. package/dist/chunk-DWJXQEFA.js +13759 -0
  7. package/dist/chunk-DZQLDEQS.js +879 -0
  8. package/dist/chunk-S5IDDSSB.js +74 -0
  9. package/dist/chunk-Z2GFQU3G.js +363 -0
  10. package/dist/cli.d.ts +0 -7
  11. package/dist/cli.js +227 -183
  12. package/dist/http-VSB7DBJR.js +1541 -0
  13. package/dist/index.d.ts +842 -10
  14. package/dist/index.js +5 -17
  15. package/dist/sqlite-VHBA4ABV.js +600 -0
  16. package/dist/sqlite-native-D2LH5ZT7.js +2498 -0
  17. package/dist/worker-script.d.ts +2 -0
  18. package/dist/worker-script.js +126 -0
  19. package/package.json +26 -16
  20. package/playwright.config.ts +101 -0
  21. package/scripts/generate-server-instructions.ts +111 -0
  22. package/server.json +5 -6
  23. package/test-server/README.md +118 -0
  24. package/test-server/code-map.md +409 -0
  25. package/test-server/fixtures/sample.csv +6 -0
  26. package/test-server/reset-database.ps1 +373 -0
  27. package/test-server/sample.csv +11 -0
  28. package/test-server/test-agent-experience.md +243 -0
  29. package/test-server/test-database.sql +388 -0
  30. package/test-server/test-group-tools.md +861 -0
  31. package/test-server/test-help-resources.mjs +238 -0
  32. package/test-server/test-preflight.md +53 -0
  33. package/test-server/test-prompts.md +354 -0
  34. package/test-server/test-resources.md +245 -0
  35. package/test-server/test-tool-annotations.mjs +157 -0
  36. package/test-server/test-tools-advanced-1.md +517 -0
  37. package/test-server/test-tools-advanced-2.md +487 -0
  38. package/test-server/test-tools-codemode.md +629 -0
  39. package/test-server/test-tools.md +176 -0
  40. package/test-server/tool-reference.md +236 -0
  41. package/tsconfig.test.json +9 -0
  42. package/dist/adapters/DatabaseAdapter.d.ts +0 -141
  43. package/dist/adapters/DatabaseAdapter.d.ts.map +0 -1
  44. package/dist/adapters/DatabaseAdapter.js +0 -131
  45. package/dist/adapters/DatabaseAdapter.js.map +0 -1
  46. package/dist/adapters/sqlite/SchemaManager.d.ts +0 -58
  47. package/dist/adapters/sqlite/SchemaManager.d.ts.map +0 -1
  48. package/dist/adapters/sqlite/SchemaManager.js +0 -187
  49. package/dist/adapters/sqlite/SchemaManager.js.map +0 -1
  50. package/dist/adapters/sqlite/SqliteAdapter.d.ts +0 -161
  51. package/dist/adapters/sqlite/SqliteAdapter.d.ts.map +0 -1
  52. package/dist/adapters/sqlite/SqliteAdapter.js +0 -741
  53. package/dist/adapters/sqlite/SqliteAdapter.js.map +0 -1
  54. package/dist/adapters/sqlite/index.d.ts +0 -9
  55. package/dist/adapters/sqlite/index.d.ts.map +0 -1
  56. package/dist/adapters/sqlite/index.js +0 -8
  57. package/dist/adapters/sqlite/index.js.map +0 -1
  58. package/dist/adapters/sqlite/json-utils.d.ts +0 -100
  59. package/dist/adapters/sqlite/json-utils.d.ts.map +0 -1
  60. package/dist/adapters/sqlite/json-utils.js +0 -274
  61. package/dist/adapters/sqlite/json-utils.js.map +0 -1
  62. package/dist/adapters/sqlite/output-schemas.d.ts +0 -1187
  63. package/dist/adapters/sqlite/output-schemas.d.ts.map +0 -1
  64. package/dist/adapters/sqlite/output-schemas.js +0 -1337
  65. package/dist/adapters/sqlite/output-schemas.js.map +0 -1
  66. package/dist/adapters/sqlite/prompts.d.ts +0 -13
  67. package/dist/adapters/sqlite/prompts.d.ts.map +0 -1
  68. package/dist/adapters/sqlite/prompts.js +0 -605
  69. package/dist/adapters/sqlite/prompts.js.map +0 -1
  70. package/dist/adapters/sqlite/resources.d.ts +0 -13
  71. package/dist/adapters/sqlite/resources.d.ts.map +0 -1
  72. package/dist/adapters/sqlite/resources.js +0 -251
  73. package/dist/adapters/sqlite/resources.js.map +0 -1
  74. package/dist/adapters/sqlite/tools/admin.d.ts +0 -14
  75. package/dist/adapters/sqlite/tools/admin.d.ts.map +0 -1
  76. package/dist/adapters/sqlite/tools/admin.js +0 -788
  77. package/dist/adapters/sqlite/tools/admin.js.map +0 -1
  78. package/dist/adapters/sqlite/tools/core.d.ts +0 -25
  79. package/dist/adapters/sqlite/tools/core.d.ts.map +0 -1
  80. package/dist/adapters/sqlite/tools/core.js +0 -359
  81. package/dist/adapters/sqlite/tools/core.js.map +0 -1
  82. package/dist/adapters/sqlite/tools/fts.d.ts +0 -13
  83. package/dist/adapters/sqlite/tools/fts.d.ts.map +0 -1
  84. package/dist/adapters/sqlite/tools/fts.js +0 -347
  85. package/dist/adapters/sqlite/tools/fts.js.map +0 -1
  86. package/dist/adapters/sqlite/tools/geo.d.ts +0 -14
  87. package/dist/adapters/sqlite/tools/geo.d.ts.map +0 -1
  88. package/dist/adapters/sqlite/tools/geo.js +0 -252
  89. package/dist/adapters/sqlite/tools/geo.js.map +0 -1
  90. package/dist/adapters/sqlite/tools/index.d.ts +0 -30
  91. package/dist/adapters/sqlite/tools/index.d.ts.map +0 -1
  92. package/dist/adapters/sqlite/tools/index.js +0 -61
  93. package/dist/adapters/sqlite/tools/index.js.map +0 -1
  94. package/dist/adapters/sqlite/tools/json-helpers.d.ts +0 -14
  95. package/dist/adapters/sqlite/tools/json-helpers.d.ts.map +0 -1
  96. package/dist/adapters/sqlite/tools/json-helpers.js +0 -477
  97. package/dist/adapters/sqlite/tools/json-helpers.js.map +0 -1
  98. package/dist/adapters/sqlite/tools/json-operations.d.ts +0 -14
  99. package/dist/adapters/sqlite/tools/json-operations.d.ts.map +0 -1
  100. package/dist/adapters/sqlite/tools/json-operations.js +0 -839
  101. package/dist/adapters/sqlite/tools/json-operations.js.map +0 -1
  102. package/dist/adapters/sqlite/tools/stats.d.ts +0 -15
  103. package/dist/adapters/sqlite/tools/stats.d.ts.map +0 -1
  104. package/dist/adapters/sqlite/tools/stats.js +0 -1219
  105. package/dist/adapters/sqlite/tools/stats.js.map +0 -1
  106. package/dist/adapters/sqlite/tools/text.d.ts +0 -14
  107. package/dist/adapters/sqlite/tools/text.d.ts.map +0 -1
  108. package/dist/adapters/sqlite/tools/text.js +0 -1141
  109. package/dist/adapters/sqlite/tools/text.js.map +0 -1
  110. package/dist/adapters/sqlite/tools/vector.d.ts +0 -14
  111. package/dist/adapters/sqlite/tools/vector.d.ts.map +0 -1
  112. package/dist/adapters/sqlite/tools/vector.js +0 -613
  113. package/dist/adapters/sqlite/tools/vector.js.map +0 -1
  114. package/dist/adapters/sqlite/tools/virtual.d.ts +0 -13
  115. package/dist/adapters/sqlite/tools/virtual.d.ts.map +0 -1
  116. package/dist/adapters/sqlite/tools/virtual.js +0 -930
  117. package/dist/adapters/sqlite/tools/virtual.js.map +0 -1
  118. package/dist/adapters/sqlite/types.d.ts +0 -207
  119. package/dist/adapters/sqlite/types.d.ts.map +0 -1
  120. package/dist/adapters/sqlite/types.js +0 -186
  121. package/dist/adapters/sqlite/types.js.map +0 -1
  122. package/dist/adapters/sqlite-native/NativeSqliteAdapter.d.ts +0 -163
  123. package/dist/adapters/sqlite-native/NativeSqliteAdapter.d.ts.map +0 -1
  124. package/dist/adapters/sqlite-native/NativeSqliteAdapter.js +0 -748
  125. package/dist/adapters/sqlite-native/NativeSqliteAdapter.js.map +0 -1
  126. package/dist/adapters/sqlite-native/index.d.ts +0 -11
  127. package/dist/adapters/sqlite-native/index.d.ts.map +0 -1
  128. package/dist/adapters/sqlite-native/index.js +0 -11
  129. package/dist/adapters/sqlite-native/index.js.map +0 -1
  130. package/dist/adapters/sqlite-native/tools/spatialite.d.ts +0 -19
  131. package/dist/adapters/sqlite-native/tools/spatialite.d.ts.map +0 -1
  132. package/dist/adapters/sqlite-native/tools/spatialite.js +0 -628
  133. package/dist/adapters/sqlite-native/tools/spatialite.js.map +0 -1
  134. package/dist/adapters/sqlite-native/tools/transactions.d.ts +0 -12
  135. package/dist/adapters/sqlite-native/tools/transactions.d.ts.map +0 -1
  136. package/dist/adapters/sqlite-native/tools/transactions.js +0 -255
  137. package/dist/adapters/sqlite-native/tools/transactions.js.map +0 -1
  138. package/dist/adapters/sqlite-native/tools/window.d.ts +0 -12
  139. package/dist/adapters/sqlite-native/tools/window.d.ts.map +0 -1
  140. package/dist/adapters/sqlite-native/tools/window.js +0 -370
  141. package/dist/adapters/sqlite-native/tools/window.js.map +0 -1
  142. package/dist/auth/AuthorizationServerDiscovery.d.ts +0 -90
  143. package/dist/auth/AuthorizationServerDiscovery.d.ts.map +0 -1
  144. package/dist/auth/AuthorizationServerDiscovery.js +0 -204
  145. package/dist/auth/AuthorizationServerDiscovery.js.map +0 -1
  146. package/dist/auth/OAuthResourceServer.d.ts +0 -65
  147. package/dist/auth/OAuthResourceServer.d.ts.map +0 -1
  148. package/dist/auth/OAuthResourceServer.js +0 -121
  149. package/dist/auth/OAuthResourceServer.js.map +0 -1
  150. package/dist/auth/TokenValidator.d.ts +0 -60
  151. package/dist/auth/TokenValidator.d.ts.map +0 -1
  152. package/dist/auth/TokenValidator.js +0 -235
  153. package/dist/auth/TokenValidator.js.map +0 -1
  154. package/dist/auth/errors.d.ts +0 -74
  155. package/dist/auth/errors.d.ts.map +0 -1
  156. package/dist/auth/errors.js +0 -133
  157. package/dist/auth/errors.js.map +0 -1
  158. package/dist/auth/index.d.ts +0 -13
  159. package/dist/auth/index.d.ts.map +0 -1
  160. package/dist/auth/index.js +0 -15
  161. package/dist/auth/index.js.map +0 -1
  162. package/dist/auth/middleware.d.ts +0 -81
  163. package/dist/auth/middleware.d.ts.map +0 -1
  164. package/dist/auth/middleware.js +0 -291
  165. package/dist/auth/middleware.js.map +0 -1
  166. package/dist/auth/scopes.d.ts +0 -136
  167. package/dist/auth/scopes.d.ts.map +0 -1
  168. package/dist/auth/scopes.js +0 -349
  169. package/dist/auth/scopes.js.map +0 -1
  170. package/dist/auth/types.d.ts +0 -257
  171. package/dist/auth/types.d.ts.map +0 -1
  172. package/dist/auth/types.js +0 -8
  173. package/dist/auth/types.js.map +0 -1
  174. package/dist/cli.d.ts.map +0 -1
  175. package/dist/cli.js.map +0 -1
  176. package/dist/constants/ServerInstructions.d.ts +0 -45
  177. package/dist/constants/ServerInstructions.d.ts.map +0 -1
  178. package/dist/constants/ServerInstructions.js +0 -356
  179. package/dist/constants/ServerInstructions.js.map +0 -1
  180. package/dist/filtering/ToolConstants.d.ts +0 -34
  181. package/dist/filtering/ToolConstants.d.ts.map +0 -1
  182. package/dist/filtering/ToolConstants.js +0 -174
  183. package/dist/filtering/ToolConstants.js.map +0 -1
  184. package/dist/filtering/ToolFilter.d.ts +0 -82
  185. package/dist/filtering/ToolFilter.d.ts.map +0 -1
  186. package/dist/filtering/ToolFilter.js +0 -296
  187. package/dist/filtering/ToolFilter.js.map +0 -1
  188. package/dist/index.d.ts.map +0 -1
  189. package/dist/index.js.map +0 -1
  190. package/dist/server/McpServer.d.ts +0 -61
  191. package/dist/server/McpServer.d.ts.map +0 -1
  192. package/dist/server/McpServer.js +0 -270
  193. package/dist/server/McpServer.js.map +0 -1
  194. package/dist/transports/http.d.ts +0 -134
  195. package/dist/transports/http.d.ts.map +0 -1
  196. package/dist/transports/http.js +0 -516
  197. package/dist/transports/http.js.map +0 -1
  198. package/dist/transports/index.d.ts +0 -5
  199. package/dist/transports/index.d.ts.map +0 -1
  200. package/dist/transports/index.js +0 -5
  201. package/dist/transports/index.js.map +0 -1
  202. package/dist/types/index.d.ts +0 -380
  203. package/dist/types/index.d.ts.map +0 -1
  204. package/dist/types/index.js +0 -68
  205. package/dist/types/index.js.map +0 -1
  206. package/dist/utils/annotations.d.ts +0 -44
  207. package/dist/utils/annotations.d.ts.map +0 -1
  208. package/dist/utils/annotations.js +0 -77
  209. package/dist/utils/annotations.js.map +0 -1
  210. package/dist/utils/errors.d.ts +0 -155
  211. package/dist/utils/errors.d.ts.map +0 -1
  212. package/dist/utils/errors.js +0 -329
  213. package/dist/utils/errors.js.map +0 -1
  214. package/dist/utils/identifiers.d.ts +0 -121
  215. package/dist/utils/identifiers.d.ts.map +0 -1
  216. package/dist/utils/identifiers.js +0 -319
  217. package/dist/utils/identifiers.js.map +0 -1
  218. package/dist/utils/index.d.ts +0 -7
  219. package/dist/utils/index.d.ts.map +0 -1
  220. package/dist/utils/index.js +0 -7
  221. package/dist/utils/index.js.map +0 -1
  222. package/dist/utils/insightsManager.d.ts +0 -39
  223. package/dist/utils/insightsManager.d.ts.map +0 -1
  224. package/dist/utils/insightsManager.js +0 -63
  225. package/dist/utils/insightsManager.js.map +0 -1
  226. package/dist/utils/logger.d.ts +0 -189
  227. package/dist/utils/logger.d.ts.map +0 -1
  228. package/dist/utils/logger.js +0 -394
  229. package/dist/utils/logger.js.map +0 -1
  230. package/dist/utils/progress-utils.d.ts +0 -54
  231. package/dist/utils/progress-utils.d.ts.map +0 -1
  232. package/dist/utils/progress-utils.js +0 -74
  233. package/dist/utils/progress-utils.js.map +0 -1
  234. package/dist/utils/resourceAnnotations.d.ts +0 -36
  235. package/dist/utils/resourceAnnotations.d.ts.map +0 -1
  236. package/dist/utils/resourceAnnotations.js +0 -57
  237. package/dist/utils/resourceAnnotations.js.map +0 -1
  238. package/dist/utils/where-clause.d.ts +0 -41
  239. package/dist/utils/where-clause.d.ts.map +0 -1
  240. package/dist/utils/where-clause.js +0 -116
  241. package/dist/utils/where-clause.js.map +0 -1
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,126 @@
1
+ import { workerData, parentPort } from 'worker_threads';
2
+ import vm from 'vm';
3
+
4
+ // src/codemode/worker-script.ts
5
+ function buildSqliteProxy(bindings, rpcPort) {
6
+ const pending = /* @__PURE__ */ new Map();
7
+ let nextId = 0;
8
+ rpcPort.on("message", (msg) => {
9
+ const p = pending.get(msg.id);
10
+ if (p) {
11
+ pending.delete(msg.id);
12
+ if (msg.error) {
13
+ p.reject(new Error(msg.error));
14
+ } else {
15
+ p.resolve(msg.result);
16
+ }
17
+ }
18
+ });
19
+ const sqlite = {};
20
+ const groupNames = [];
21
+ for (const [key, methods] of Object.entries(bindings)) {
22
+ if (key === "_topLevel") continue;
23
+ groupNames.push(key);
24
+ const groupApi = {};
25
+ for (const method of methods) {
26
+ if (method === "help") continue;
27
+ groupApi[method] = (...args) => new Promise((resolve, reject) => {
28
+ const id = nextId++;
29
+ pending.set(id, { resolve, reject });
30
+ rpcPort.postMessage({ id, group: key, method, args });
31
+ });
32
+ }
33
+ groupApi["help"] = () => ({
34
+ group: key,
35
+ methods: methods.filter((m) => m !== "help")
36
+ });
37
+ sqlite[key] = groupApi;
38
+ }
39
+ const topLevel = bindings["_topLevel"];
40
+ if (topLevel) {
41
+ for (const method of topLevel) {
42
+ if (method === "help") {
43
+ sqlite["help"] = () => ({
44
+ groups: groupNames
45
+ });
46
+ } else {
47
+ sqlite[method] = (...args) => new Promise((resolve, reject) => {
48
+ const id = nextId++;
49
+ pending.set(id, { resolve, reject });
50
+ rpcPort.postMessage({
51
+ id,
52
+ group: "_topLevel",
53
+ method,
54
+ args
55
+ });
56
+ });
57
+ }
58
+ }
59
+ }
60
+ if (sqlite["help"] === void 0) {
61
+ sqlite["help"] = () => ({
62
+ groups: groupNames
63
+ });
64
+ }
65
+ return sqlite;
66
+ }
67
+ async function executeInWorker() {
68
+ const data = workerData;
69
+ const { code, apiBindings, timeout, rpcPort } = data;
70
+ try {
71
+ rpcPort.ref();
72
+ const sqlite = buildSqliteProxy(apiBindings, rpcPort);
73
+ const sandbox = {
74
+ sqlite,
75
+ console: {
76
+ log: () => {
77
+ },
78
+ error: () => {
79
+ },
80
+ warn: () => {
81
+ },
82
+ info: () => {
83
+ },
84
+ debug: () => {
85
+ }
86
+ },
87
+ setTimeout: void 0,
88
+ setInterval: void 0,
89
+ setImmediate: void 0,
90
+ process: void 0,
91
+ require: void 0,
92
+ __dirname: void 0,
93
+ __filename: void 0,
94
+ globalThis: void 0,
95
+ global: void 0
96
+ };
97
+ const context = vm.createContext(sandbox, {
98
+ name: "worker-sandbox"
99
+ });
100
+ const wrappedCode = `(async () => { ${code} })()`;
101
+ const script = new vm.Script(wrappedCode, {
102
+ filename: "user-code.js"
103
+ });
104
+ const result = await script.runInContext(context, {
105
+ timeout,
106
+ displayErrors: true
107
+ });
108
+ rpcPort.unref();
109
+ rpcPort.close();
110
+ const response = {
111
+ success: true,
112
+ result
113
+ };
114
+ parentPort?.postMessage(response);
115
+ } catch (error) {
116
+ rpcPort.unref();
117
+ rpcPort.close();
118
+ const response = {
119
+ success: false,
120
+ error: error instanceof Error ? error.message : String(error),
121
+ stack: error instanceof Error ? error.stack : void 0
122
+ };
123
+ parentPort?.postMessage(response);
124
+ }
125
+ }
126
+ void executeInWorker();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "db-mcp",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "SQLite MCP server with OAuth 2.1 authentication, HTTP/SSE transport, and smart tool filtering",
5
5
  "mcpName": "io.github.neverinfamous/db-mcp",
6
6
  "type": "module",
@@ -10,19 +10,24 @@
10
10
  "db-mcp": "./dist/cli.js"
11
11
  },
12
12
  "scripts": {
13
- "build": "tsc",
13
+ "build": "tsup",
14
14
  "dev": "tsx watch src/index.ts",
15
15
  "start": "node dist/index.js",
16
16
  "start:stdio": "node dist/cli.js --transport=stdio",
17
17
  "start:http": "node dist/cli.js --transport=http",
18
18
  "lint": "eslint .",
19
19
  "lint:fix": "eslint . --fix",
20
+ "lint:json": "eslint . --format json --output-file eslint-results.json",
20
21
  "typecheck": "tsc --noEmit",
21
22
  "check": "npm run lint && npm run typecheck",
22
23
  "test": "vitest run",
23
24
  "test:watch": "vitest",
24
25
  "test:coverage": "vitest run --coverage",
26
+ "test:e2e": "playwright test",
27
+ "bench": "vitest bench --run",
28
+ "bench:verbose": "vitest bench --run --reporter=verbose",
25
29
  "clean": "rimraf dist",
30
+ "generate:instructions": "node scripts/generate-server-instructions.ts",
26
31
  "prepublishOnly": "npm run build"
27
32
  },
28
33
  "keywords": [
@@ -48,36 +53,41 @@
48
53
  "node": ">=24.0.0"
49
54
  },
50
55
  "dependencies": {
51
- "@modelcontextprotocol/sdk": "^1.25.2",
56
+ "@modelcontextprotocol/sdk": "^1.27.1",
52
57
  "cors": "^2.8.5",
53
- "dotenv": "^17.2.3",
54
58
  "express": "^5.2.1",
55
- "jose": "^6.1.3",
56
- "pg": "^8.18.0",
57
- "sql.js": "^1.13.0",
59
+ "jose": "^6.2.1",
60
+ "sql.js": "^1.14.1",
58
61
  "zod": "^3.25.0 || ^4.0.0"
59
62
  },
60
63
  "devDependencies": {
61
- "@eslint/js": "^9.39.2",
64
+ "@eslint/js": "^10.0.1",
65
+ "@playwright/test": "^1.58.2",
62
66
  "@types/better-sqlite3": "^7.6.13",
63
67
  "@types/cors": "^2.8.19",
64
68
  "@types/express": "^5.0.6",
65
- "@types/node": "^25.2.0",
66
- "@types/pg": "^8.16.0",
69
+ "@types/node": "^25.4.0",
67
70
  "@types/sql.js": "^1.4.9",
68
71
  "@vitest/coverage-v8": "^4.0.18",
69
- "eslint": "^9.39.2",
70
- "globals": "^17.3.0",
71
- "rimraf": "^6.1.2",
72
+ "eslint": "^10.0.2",
73
+ "globals": "^17.4.0",
74
+ "rimraf": "^6.1.3",
75
+ "tsup": "^8.5.1",
72
76
  "tsx": "^4.21.0",
73
77
  "typescript": "^5.9.3",
74
- "typescript-eslint": "^8.54.0",
78
+ "typescript-eslint": "^8.57.1",
75
79
  "vitest": "^4.0.17"
76
80
  },
77
81
  "peerDependencies": {
78
82
  "zod": "^3.25.0 || ^4.0.0"
79
83
  },
80
84
  "optionalDependencies": {
81
- "better-sqlite3": "^12.6.2"
85
+ "better-sqlite3": "^12.8.0"
86
+ },
87
+ "overrides": {
88
+ "diff": "8.0.3",
89
+ "@isaacs/brace-expansion": "5.0.1",
90
+ "tar": "7.5.11",
91
+ "minimatch": "10.2.4"
82
92
  }
83
- }
93
+ }
@@ -0,0 +1,101 @@
1
+ import { defineConfig, devices } from "@playwright/test";
2
+
3
+ export default defineConfig({
4
+ testDir: "./tests/e2e",
5
+ fullyParallel: false,
6
+ forbidOnly: !!process.env.CI,
7
+ retries: process.env.CI ? 2 : 0,
8
+ // MCP SDK McpServer only supports one active transport at a time.
9
+ // Parallel workers create competing SSE connections that steal each other's transport.
10
+ workers: 1,
11
+ reporter: "list",
12
+ use: {
13
+ trace: "on-first-retry",
14
+ // 60s timeout — allows slow operations (vector stats, code mode ETL)
15
+ // to complete without flaky timeouts from rate-limit backpressure
16
+ actionTimeout: 0,
17
+ },
18
+ timeout: 60_000,
19
+ projects: [
20
+ {
21
+ name: "wasm",
22
+ use: {
23
+ ...devices["Desktop Chrome"],
24
+ baseURL: "http://localhost:3000",
25
+ },
26
+ testIgnore: [
27
+ /native\./,
28
+ /auth\./,
29
+ /payloads-window\./,
30
+ /payloads-fts\./,
31
+ /payloads-transactions\./,
32
+ /payloads-spatialite\./,
33
+ /payloads-csv\./,
34
+ /transactions-nested\./,
35
+ /integration-workflows\./,
36
+ /codemode-introspection\./,
37
+ ],
38
+ },
39
+ {
40
+ name: "native",
41
+ use: {
42
+ ...devices["Desktop Chrome"],
43
+ baseURL: "http://localhost:3001",
44
+ },
45
+ testIgnore: [/wasm\./, /auth\./],
46
+ dependencies: ["wasm"],
47
+ },
48
+ {
49
+ name: "auth",
50
+ use: {
51
+ ...devices["Desktop Chrome"],
52
+ baseURL: "http://localhost:3003",
53
+ },
54
+ testMatch: /auth\./,
55
+ dependencies: ["native"],
56
+ },
57
+ ],
58
+ webServer: [
59
+ {
60
+ command:
61
+ "node dist/cli.js --transport http --port 3000 --sqlite ./test-server/test.db --tool-filter +all",
62
+ url: "http://localhost:3000/health",
63
+ reuseExistingServer: !process.env.CI,
64
+ timeout: 30000,
65
+ stdout: "pipe",
66
+ stderr: "pipe",
67
+ env: {
68
+ ...process.env,
69
+ MCP_RATE_LIMIT_MAX: "10000",
70
+ MCP_CODEMODE_RATE_LIMIT: "10000",
71
+ },
72
+ },
73
+ {
74
+ command:
75
+ "node dist/cli.js --transport http --port 3001 --sqlite-native ./test-server/test.db --csv --spatialite --tool-filter +all",
76
+ url: "http://localhost:3001/health",
77
+ reuseExistingServer: !process.env.CI,
78
+ timeout: 30000,
79
+ stdout: "pipe",
80
+ stderr: "pipe",
81
+ env: {
82
+ ...process.env,
83
+ MCP_RATE_LIMIT_MAX: "10000",
84
+ MCP_CODEMODE_RATE_LIMIT: "10000",
85
+ SPATIALITE_PATH:
86
+ "./extensions/mod_spatialite-5.1.0-win-amd64/mod_spatialite.dll",
87
+ CSV_EXTENSION_PATH: "./extensions/xsv0.dll",
88
+ },
89
+ },
90
+ {
91
+ command:
92
+ "node dist/cli.js --transport http --port 3003 --auth-token test-secret --sqlite ./test-server/test.db --tool-filter +all",
93
+ url: "http://localhost:3003/health",
94
+ reuseExistingServer: !process.env.CI,
95
+ timeout: 30000,
96
+ stdout: "pipe",
97
+ stderr: "pipe",
98
+ env: { ...process.env, MCP_RATE_LIMIT_MAX: "10000" },
99
+ },
100
+ ],
101
+ });
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Generates src/constants/server-instructions.ts from per-group markdown files.
3
+ *
4
+ * Reads server-instructions/*.md, escapes for template literals, and wraps them
5
+ * in a TypeScript module with a slim INSTRUCTIONS constant and a HELP_CONTENT map.
6
+ *
7
+ * Usage: node scripts/generate-server-instructions.ts
8
+ */
9
+
10
+ import { readFileSync, readdirSync, writeFileSync } from "node:fs";
11
+ import { dirname, resolve, basename } from "node:path";
12
+ import { fileURLToPath } from "node:url";
13
+
14
+ const __dirname = dirname(fileURLToPath(import.meta.url));
15
+ const projectRoot = resolve(__dirname, "..");
16
+ const constantsDir = resolve(projectRoot, "src/constants");
17
+ const helpDir = resolve(constantsDir, "server-instructions");
18
+
19
+ /**
20
+ * Escape content for use inside a JS/TS template literal.
21
+ * Handles: backslashes, backticks, and template expressions (${).
22
+ */
23
+ function escapeForTemplateLiteral(content: string): string {
24
+ return content
25
+ .replace(/\\/g, "\\\\")
26
+ .replace(/`/g, "\\`")
27
+ .replace(/\$\{/g, "\\${");
28
+ }
29
+
30
+ // Read overview (slim instructions field content)
31
+ const overviewMd = readFileSync(
32
+ resolve(helpDir, "overview.md"),
33
+ "utf-8",
34
+ ).trim();
35
+ const overviewEscaped = escapeForTemplateLiteral(overviewMd);
36
+
37
+ // Read all help files (everything except overview.md)
38
+ const helpFiles = readdirSync(helpDir)
39
+ .filter((f) => f.endsWith(".md") && f !== "overview.md")
40
+ .sort();
41
+
42
+ const helpEntries: { key: string; content: string }[] = [];
43
+ for (const file of helpFiles) {
44
+ const key = basename(file, ".md"); // "gotchas", "json", "stats", etc.
45
+ const content = readFileSync(resolve(helpDir, file), "utf-8").trim();
46
+ helpEntries.push({ key, content });
47
+ }
48
+
49
+ // Use backtick char for building string to avoid nesting issues
50
+ const BT = "`";
51
+
52
+ // Build the TypeScript file using string concatenation
53
+ const lines: string[] = [];
54
+
55
+ lines.push("/**");
56
+ lines.push(" * Server instructions for db-mcp (SQLite MCP Server).");
57
+ lines.push(" *");
58
+ lines.push(
59
+ " * \u26a0\ufe0f AUTO-GENERATED \u2014 DO NOT EDIT THIS FILE DIRECTLY",
60
+ );
61
+ lines.push(" * Edit src/constants/server-instructions/*.md instead,");
62
+ lines.push(" * then run: npm run generate:instructions");
63
+ lines.push(" *");
64
+ lines.push(
65
+ " * Slim instructions are sent to MCP clients during initialization.",
66
+ );
67
+ lines.push(
68
+ " * Detailed help is available on-demand via sqlite://help resources.",
69
+ );
70
+ lines.push(" */");
71
+ lines.push("");
72
+ lines.push("/**");
73
+ lines.push(" * Slim instructions for the MCP instructions field (~600 chars).");
74
+ lines.push(
75
+ " * Points agents to sqlite://help resources for detailed reference.",
76
+ );
77
+ lines.push(" */");
78
+ lines.push("export const INSTRUCTIONS = " + BT + overviewEscaped + BT + ";");
79
+ lines.push("");
80
+ lines.push("/**");
81
+ lines.push(" * Help content keyed by group name.");
82
+ lines.push(" * 'gotchas' is the always-available help (sqlite://help).");
83
+ lines.push(" * Other keys are tool groups (sqlite://help/{group}).");
84
+ lines.push(" */");
85
+ lines.push(
86
+ "export const HELP_CONTENT: ReadonlyMap<string, string> = new Map([",
87
+ );
88
+ for (const { key, content } of helpEntries) {
89
+ const escaped = escapeForTemplateLiteral(content);
90
+ lines.push(" [" + JSON.stringify(key) + ", " + BT + escaped + BT + "],");
91
+ }
92
+ lines.push("]);");
93
+ lines.push("");
94
+
95
+ const tsContent = lines.join("\n");
96
+ const tsPath = resolve(constantsDir, "server-instructions.ts");
97
+ writeFileSync(tsPath, tsContent, "utf-8");
98
+
99
+ process.stderr.write(
100
+ [
101
+ "",
102
+ "\u2705 Generated server-instructions.ts (" +
103
+ tsContent.length.toLocaleString() +
104
+ " bytes) from " +
105
+ (helpEntries.length + 1) +
106
+ " markdown files",
107
+ " Overview: " + overviewMd.length.toLocaleString() + " chars",
108
+ " Help entries: " + helpEntries.map((e) => e.key).join(", "),
109
+ "",
110
+ ].join("\n"),
111
+ );
package/server.json CHANGED
@@ -2,21 +2,20 @@
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
3
  "name": "io.github.neverinfamous/db-mcp",
4
4
  "title": "db-mcp (SQLite MCP Server)",
5
- "description": "SQLite MCP server with OAuth 2.1, HTTP/SSE, 122 tools, and smart tool filtering",
6
- "version": "1.0.2",
5
+ "description": "SQLite MCP server with OAuth 2.1, HTTP/SSE, 139 tools, and smart tool filtering",
6
+ "version": "1.1.0",
7
7
  "packages": [
8
8
  {
9
9
  "registryType": "npm",
10
10
  "identifier": "db-mcp",
11
- "version": "1.0.2",
11
+ "version": "1.1.0",
12
12
  "transport": {
13
13
  "type": "stdio"
14
14
  }
15
15
  },
16
16
  {
17
17
  "registryType": "oci",
18
- "identifier": "docker.io/writenotenow/db-mcp:v1.0.2",
19
- "version": "1.0.2",
18
+ "identifier": "docker.io/writenotenow/db-mcp:v1.1.0",
20
19
  "transport": {
21
20
  "type": "stdio"
22
21
  }
@@ -50,4 +49,4 @@
50
49
  "source": "github"
51
50
  },
52
51
  "license": "MIT"
53
- }
52
+ }
@@ -0,0 +1,118 @@
1
+ # db-mcp Test Database — Agent Testing Instructions
2
+
3
+ > **This README is optimized for AI agent consumption.** It serves as the primary orchestration document for running manual MCP functionality tests against the local SQLite database.
4
+
5
+ ## Files
6
+
7
+ | File | Size | Purpose | When to Read |
8
+ | ---------------------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
9
+ | `test-tools.md` | ~12KB | **Entry-point protocol** — schema reference, error pattern docs, reporting format, cleanup rules. Paste a group checklist from `test-group-tools.md` at the bottom. | Always read first (Step 1 says read help resources, Step 2 is the testing) |
10
+ | `test-group-tools.md` | ~54KB | Per-group **deterministic checklists** (core, json, text, stats, vector, admin, geo, introspection, migration). Copy the relevant section into `test-tools.md`. | When running a specific tool group |
11
+ | `test-tools-advanced-1.md` | ~28KB | **Second-pass stress tests (Part 1)** — boundary values, state pollution, error message quality, WASM parity. | After basic checklist passes |
12
+ | `test-tools-advanced-2.md` | ~32KB | **Second-pass stress tests (Part 2)** — cross-group integration. Self-contained. | After basic checklist passes |
13
+ | `test-resources.md` | ~6KB | Resource testing plan (8 data + 7 help resources via `read_resource`) | When testing resources |
14
+ | `test-preflight.md` | ~2KB | **Pre-flight check** — validates slim instructions, help resources, data resources, and tool-filter alignment in 5 steps | Before any test pass |
15
+ | `test-agent-experience.md` | ~9KB | **Agent experience test** — 29 open-ended scenarios across 7 passes validating help resource sufficiency | After help resource changes |
16
+ | `test-prompts.md` | ~10KB | Prompt testing plan (10 prompts, tested manually since agents typically don't invoke prompts) | When testing prompts |
17
+ | `tool-groups-list.md` | — | **Canonical tool inventory** — all 9 groups + codemode, 139 Native / 115 WASM tools. Source of truth for tool counts. | Reference / auditing |
18
+ | `tool-reference.md` | ~18KB | **Complete Tool Reference** — Detailed list of all 139 Native / 115 WASM tools organized by group. | Reference |
19
+ | [`code-map.md`](code-map.md) | ~12KB | **Source Code Map** — Directory tree, handler→tool mapping, type/schema locations, error hierarchy, constants, architecture patterns. | When debugging source code or making changes |
20
+ | `reset-database.ps1` | ~11KB | PowerShell script to delete + re-seed `test.db` from `test-database.sql`. Verifies row counts. | After migration group testing or if data is polluted |
21
+ | `test-database.sql` | ~21KB | Seed SQL (DDL + DML) for all `test_*` tables | Reference only — reset script consumes this |
22
+ | `sample.csv` | <1KB | CSV fixture for `sqlite_create_csv_table` / `sqlite_analyze_csv_schema` testing | Used by admin group checklist |
23
+
24
+ ## Test Database Schema
25
+
26
+ | Table | Rows | Notable Columns |
27
+ | ------------------- | ---- | ----------------------------------------------------------------------------------------------------------------- |
28
+ | `test_products` | 16 | price (REAL), category (TEXT, lowercase). Row 16: `Café Décor Light` (accented) |
29
+ | `test_orders` | 20 | product_id FK → test_products, status (TEXT) |
30
+ | `test_jsonb_docs` | 6 | **doc** (JSON), **metadata** (nested JSON), **tags** (JSON array). Row 4: `$.nested.level1.level2 = "deep value"` |
31
+ | `test_articles` | 8 | FTS5 searchable: SQLite, database, JSON, FTS, vector, API, search, MCP |
32
+ | `test_users` | 9 | email, phone (`+1-555-...` format), bio. 1 NULL phone. |
33
+ | `test_measurements` | 200 | sensor_id (INTEGER 1-5), temperature, humidity, pressure |
34
+ | `test_embeddings` | 20 | 8-dim float vectors. Categories: tech, database, food, fitness, travel |
35
+ | `test_locations` | 15 | latitude/longitude. Cities: NYC(3), Paris(3), London(3), Tokyo(2), Sydney(2), SF(2) |
36
+ | `test_categories` | 17 | Hierarchical: name, path, level |
37
+ | `test_events` | 100 | **payload** (JSON), event_type, user_id (INT, 8 values) |
38
+
39
+ **Key FK:** `test_orders.product_id → test_products.id`
40
+ **Redundant index (intentional):** `idx_orders_status` is a prefix of `idx_orders_status_date` — used to test index audit tools.
41
+
42
+ ## Conventions
43
+
44
+ | Convention | Rule |
45
+ | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
46
+ | **Temp tables (basic tests)** | `temp_*` prefix → drop after testing |
47
+ | **Temp tables (stress tests)** | `stress_*` prefix → drop after testing |
48
+ | **String values** | Lowercase (`'electronics'`, not `'Electronics'`) |
49
+ | **sensor_id** | INTEGER (use `= 1`, not `= 'S001'`) |
50
+ | **Reporting** | ❌ Fail, ⚠️ Issue, 📦 Payload concern. ✅ inline only, omit from final summary. |
51
+ | **Error testing** | Every tool: test (a) domain error + (b) Zod error (`{}`). Must return `{success: false, error: "..."}`, NOT raw MCP error. |
52
+ | **Error item prefix** | All error-path checklist items use 🔴 prefix to distinguish from happy-path items |
53
+ | **Code mode** | Don't pass `readonly: true` unless specifically testing read-only filtering |
54
+ | **Post-test** | Clean up temps → plan fixes → implement → lint+typecheck → changelog → commit (no push) → re-test fixes |
55
+ | **Database reset** | Run `.\reset-database.ps1` after migration testing or data pollution |
56
+
57
+ ## WASM Parity Protocol
58
+
59
+ To validate WASM mode produces identical results for shared tools:
60
+
61
+ 1. **Configure for WASM**: Set `--sqlite` (not `--sqlite-native`) in your MCP client config
62
+ 2. **Expected tool count**: 115 WASM vs 139 Native (24 fewer: 4 FTS5, 6 window, 7 transaction, 7 SpatiaLite)
63
+ 3. **Run the same checklists**: Use `test-group-tools.md` but skip items marked `[NATIVE ONLY]`
64
+ 4. **Verify shared tools**: All non-`[NATIVE ONLY]` items should produce identical output in both backends
65
+ 5. **Verify absent tools**: Calling a Native-only tool in WASM mode should return a structured error (not crash)
66
+ 6. **Key groups to verify**: text (FTS5 absent), stats (window functions absent), admin (transactions absent), geo (SpatiaLite absent)
67
+
68
+ ## Integration Test Scripts
69
+
70
+ These scripts test features that require separate server processes — they **cannot** be run via MCP tool calls. All scripts are Node.js (`.mjs`), require no dependencies beyond Node.js, and exit with code 0 on success.
71
+
72
+ > [!IMPORTANT]
73
+ > Always `npm run build` before running these scripts — they execute `dist/cli.js` directly.
74
+
75
+ ### Script Reference
76
+
77
+ | Script | Tests | Transport | Duration |
78
+ | --------------------------- | --------------------------------------------------------------- | --------- | -------- |
79
+ | `test-help-resources.mjs` | Slim instructions + `sqlite://help` resource filtering by group | stdio | ~15s |
80
+ | `test-tool-annotations.mjs` | `tools/list` openWorldHint annotation presence and consistency | stdio | ~5s |
81
+
82
+ ### Quick Run
83
+
84
+ ```powershell
85
+ cd C:\Users\chris\Desktop\db-mcp
86
+ npm run build
87
+
88
+ # Help resources
89
+ node test-server/test-help-resources.mjs
90
+
91
+ # Tool annotations
92
+ node test-server/test-tool-annotations.mjs
93
+ ```
94
+
95
+ ### Success Criteria
96
+
97
+ #### Help Resources
98
+
99
+ - [ ] Instructions under 1000 chars (~680)
100
+ - [ ] `sqlite://help` always registered
101
+ - [ ] Group-specific help only for enabled groups
102
+ - [ ] No old content leaked into slim instructions
103
+
104
+ #### Tool Annotations
105
+
106
+ - [ ] All tools have `annotations` object with `openWorldHint` set
107
+ - [ ] All `openWorldHint` values are `false` (db-mcp tools are local-only)
108
+ - [ ] 0 missing annotations
109
+
110
+ ## Agent Workflow
111
+
112
+ 1. Read `sqlite://help` resource (or `view_file` on `src/constants/server-instructions/gotchas.md`).
113
+ 2. Read `test-tools.md` for protocol and schema details.
114
+ 3. Access `test-group-tools.md` and copy the target group checklist.
115
+ 4. Execute via direct MCP tool calls to test logic. Run both happy-path and error-path tests.
116
+ 5. Clean up any temporary tables generated during execution.
117
+ 6. Report findings using the designated reporting convention.
118
+ 7. (Optional) Run stress tests from `test-tools-advanced-1.md` or `test-tools-advanced-2.md`.