db-mcp 1.1.0 → 2.0.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 (84) hide show
  1. package/.gitleaks.toml +9 -0
  2. package/.trivyignore +8 -0
  3. package/README.md +193 -120
  4. package/dist/{chunk-DWJXQEFA.js → chunk-5Y42NPBP.js} +4168 -2411
  5. package/dist/{chunk-AOUL5SHS.js → chunk-645ZEFLA.js} +70 -20
  6. package/dist/chunk-OKOVZ5QE.js +28 -0
  7. package/dist/chunk-SFJQCNG7.js +131 -0
  8. package/dist/{chunk-S5IDDSSB.js → chunk-VIDSICEL.js} +12 -1
  9. package/dist/chunk-WBER5YY4.js +2053 -0
  10. package/dist/{chunk-4IA3DB5C.js → chunk-X3MUUOWM.js} +19 -2
  11. package/dist/{chunk-Z2GFQU3G.js → chunk-Z7C2TM4L.js} +114 -21
  12. package/dist/cli.js +79 -5
  13. package/dist/{http-VSB7DBJR.js → http-6KF4ULDI.js} +199 -77
  14. package/dist/index.d.ts +231 -8
  15. package/dist/index.js +6 -5
  16. package/dist/{sqlite-VHBA4ABV.js → sqlite-U5KSYQXK.js} +63 -140
  17. package/dist/{sqlite-native-D2LH5ZT7.js → sqlite-native-JXMCFQBA.js} +576 -114
  18. package/dist/worker-script.js +34 -10
  19. package/logs/.gitkeep +1 -0
  20. package/mcp-config-example.json +83 -0
  21. package/package.json +9 -8
  22. package/playwright.config.ts +1 -1
  23. package/scripts/update-badges.ts +99 -0
  24. package/server.json +7 -5
  25. package/test-server/README.md +20 -23
  26. package/test-server/code-map.md +45 -33
  27. package/test-server/reset-database.ps1 +59 -17
  28. package/test-server/scripts/README.md +27 -0
  29. package/test-server/{test-help-resources.mjs → scripts/test-help-resources.mjs} +12 -5
  30. package/test-server/scripts/test-prompts.mjs +251 -0
  31. package/test-server/{test-tool-annotations.mjs → scripts/test-tool-annotations.mjs} +9 -4
  32. package/test-server/test-advanced/README.md +70 -0
  33. package/test-server/test-advanced/test-codemode-advanced-admin.md +174 -0
  34. package/test-server/test-advanced/test-codemode-advanced-core.md +193 -0
  35. package/test-server/test-advanced/test-codemode-advanced-geo.md +157 -0
  36. package/test-server/test-advanced/test-codemode-advanced-introspection.md +171 -0
  37. package/test-server/test-advanced/test-codemode-advanced-json.md +169 -0
  38. package/test-server/test-advanced/test-codemode-advanced-migration.md +160 -0
  39. package/test-server/test-advanced/test-codemode-advanced-stats.md +185 -0
  40. package/test-server/test-advanced/test-codemode-advanced-text.md +183 -0
  41. package/test-server/test-advanced/test-codemode-advanced-transactions.md +136 -0
  42. package/test-server/test-advanced/test-codemode-advanced-vector.md +141 -0
  43. package/test-server/test-codemode/README.md +121 -0
  44. package/test-server/test-codemode/test-codemode-admin.md +223 -0
  45. package/test-server/test-codemode/test-codemode-core.md +286 -0
  46. package/test-server/test-codemode/test-codemode-geo.md +177 -0
  47. package/test-server/test-codemode/test-codemode-introspection.md +190 -0
  48. package/test-server/test-codemode/test-codemode-json.md +237 -0
  49. package/test-server/test-codemode/test-codemode-migration.md +278 -0
  50. package/test-server/test-codemode/test-codemode-sandbox.md +413 -0
  51. package/test-server/test-codemode/test-codemode-stats.md +232 -0
  52. package/test-server/test-codemode/test-codemode-text.md +237 -0
  53. package/test-server/test-codemode/test-codemode-transactions.md +236 -0
  54. package/test-server/test-codemode/test-codemode-vector.md +244 -0
  55. package/test-server/test-codemode/test-codemode-wasm-degradation.md +394 -0
  56. package/test-server/test-database.sql +37 -1
  57. package/test-server/test-resources.md +43 -16
  58. package/test-server/test-tool-groups/README.md +100 -0
  59. package/test-server/test-tool-groups/test-admin-core.md +165 -0
  60. package/test-server/test-tool-groups/test-admin-extensions.md +133 -0
  61. package/test-server/{test-tools.md → test-tool-groups/test-core-data.md} +103 -17
  62. package/test-server/test-tool-groups/test-core-schema.md +240 -0
  63. package/test-server/test-tool-groups/test-geo-haversine.md +130 -0
  64. package/test-server/test-tool-groups/test-geo-spatialite.md +110 -0
  65. package/test-server/test-tool-groups/test-introspection-diagnostics.md +123 -0
  66. package/test-server/test-tool-groups/test-introspection-schema.md +133 -0
  67. package/test-server/test-tool-groups/test-json-read.md +219 -0
  68. package/test-server/test-tool-groups/test-json-write.md +157 -0
  69. package/test-server/test-tool-groups/test-migration.md +193 -0
  70. package/test-server/test-tool-groups/test-stats-advanced.md +118 -0
  71. package/test-server/test-tool-groups/test-stats-basic.md +156 -0
  72. package/test-server/test-tool-groups/test-text-advanced.md +169 -0
  73. package/test-server/test-tool-groups/test-text-basic.md +177 -0
  74. package/test-server/test-tool-groups/test-transactions.md +179 -0
  75. package/test-server/test-tool-groups/test-vector-read.md +130 -0
  76. package/test-server/test-tool-groups/test-vector-write.md +115 -0
  77. package/test-server/tool-reference.md +79 -58
  78. package/tsconfig.build.json +6 -0
  79. package/dist/chunk-DZQLDEQS.js +0 -879
  80. package/test-server/test-agent-experience.md +0 -243
  81. package/test-server/test-group-tools.md +0 -861
  82. package/test-server/test-tools-advanced-1.md +0 -517
  83. package/test-server/test-tools-advanced-2.md +0 -487
  84. package/test-server/test-tools-codemode.md +0 -629
@@ -0,0 +1,394 @@
1
+ # db-mcp Code Mode Testing: [wasm-degradation]
2
+
3
+ > [!IMPORTANT]
4
+ > **Do not track progress in this file.** Track your test progress, coverage matrix, and findings in your internal task tracking system (artifact). However, you SHOULD edit this file to fix any factual errors, broken code, or incorrect assertions in the test prompts.
5
+ > If there is nothing to fix, don't update UNRELEASED.md.
6
+ > We're currently testing WASM mode.
7
+
8
+ > [!CAUTION]
9
+ > **WASM ONLY** — This prompt must be run against a WASM backend (`--sqlite` flag). Running it against Native will produce false results since the tools being tested are expected to _fail_ in WASM but _succeed_ in Native.
10
+
11
+ **Step 1:** Read `C:\Users\chris\Desktop\db-mcp\src\constants\server-instructions\gotchas.md` using `view_file`.
12
+
13
+ **Step 2:** Validate that WASM-unavailable features degrade gracefully with structured errors, not crashes or raw MCP exceptions.
14
+
15
+ **Step 3:** The agent should update C:\Users\chris\Desktop\db-mcp\UNRELEASED.md with any/all changes/fixes.
16
+
17
+ ## Purpose
18
+
19
+ This prompt validates the **graceful degradation contract**: tools that are registered in WASM mode but rely on unavailable Native extensions must return structured `{success: false, error: "..."}` responses. It also validates that the Code Mode API bridge correctly reflects the reduced WASM tool surface.
20
+
21
+ ## Reporting Format
22
+
23
+ - ❌ Fail: Tool crashes, returns raw MCP error, or doesn't return `{success: false}`
24
+ - ⚠️ Issue: Error message is unclear or missing `wasmLimitation` hint
25
+ - ✅ Pass: Returns `{success: false, error: "..."}` with helpful message
26
+
27
+ ## Test Database Schema
28
+
29
+ Same seed database as all other prompts. Key difference: `test_articles_fts` (FTS5 virtual table) exists in `sqlite_master` because the seed was created with native SQLite, but FTS5 queries will fail in WASM.
30
+
31
+ ## Testing Requirements
32
+
33
+ > [!CAUTION]
34
+ > **Zero tolerance for raw MCP errors.** Every tool in this prompt is expected to return a structured error — not crash.
35
+
36
+ 1. **Batched scripting**: Bundle checks into `sqlite_execute_code` calls with `failures` array.
37
+ 2. **Structured error validation**: Every response must have `success: false` and a human-readable `error` string.
38
+ 3. **Token tracking**: Monitor `metrics.tokenEstimate`.
39
+ 4. **Coverage Matrix**: `| Category | Test | Result | Error Message Quality |`
40
+ 5. **Code Over Docs**: Fix the handler code if a tool returns a raw MCP error instead of a structured error.
41
+
42
+ ## Structured Error Response Pattern
43
+
44
+ ```json
45
+ { "success": false, "error": "Human-readable error message" }
46
+ ```
47
+
48
+ | Type | What you see | Verdict |
49
+ | -------------------- | --------------------------------------------- | ------- |
50
+ | **Handler error** ✅ | JSON object with `success` and `error` fields | Correct |
51
+ | **MCP error** ❌ | Raw text, `isError: true`, no `success` field | Bug |
52
+
53
+ ---
54
+
55
+ ## Phase 1: API Surface Verification (3 tests)
56
+
57
+ > Verify the Code Mode bridge correctly reflects the reduced WASM tool surface.
58
+
59
+ ### 1.1 — Total method count
60
+
61
+ ```javascript
62
+ const help = await sqlite.help();
63
+ return { groups: help.groups, totalMethods: help.totalMethods };
64
+ ```
65
+
66
+ Expected: `totalMethods` should be significantly less than 151 (the Native count). The exact WASM count depends on adapter registration but should be approximately 125.
67
+
68
+ ### 1.2 — Transactions group is empty
69
+
70
+ ```javascript
71
+ const txHelp = await sqlite.transactions.help();
72
+ return {
73
+ group: txHelp.group,
74
+ methodCount: txHelp.methods.length,
75
+ methods: txHelp.methods,
76
+ };
77
+ ```
78
+
79
+ Expected: `methodCount: 0` (or only `help` itself). No transaction methods should be available.
80
+
81
+ ### 1.3 — Window functions absent from stats
82
+
83
+ ```javascript
84
+ const statsHelp = await sqlite.stats.help();
85
+ const windowMethods = statsHelp.methods.filter((m) => m.startsWith("window"));
86
+ return { totalStatsMethods: statsHelp.methods.length, windowMethods };
87
+ ```
88
+
89
+ Expected: `windowMethods` is empty (`[]`). The 6 window tools should not appear.
90
+
91
+ ### 1.4 — SpatiaLite absent from geo
92
+
93
+ ```javascript
94
+ const geoHelp = await sqlite.geo.help();
95
+ const spatialMethods = geoHelp.methods.filter((m) =>
96
+ m.startsWith("spatialite"),
97
+ );
98
+ return {
99
+ totalGeoMethods: geoHelp.methods.length,
100
+ spatialMethods,
101
+ haversineMethods: geoHelp.methods,
102
+ };
103
+ ```
104
+
105
+ Expected: `spatialMethods` is empty. Only 4 Haversine methods remain: `distance`, `nearby`, `boundingBox`, `cluster`.
106
+
107
+ ### 1.5 — FTS5 absent from text
108
+
109
+ ```javascript
110
+ const textHelp = await sqlite.text.help();
111
+ const ftsMethods = textHelp.methods.filter((m) => m.startsWith("fts"));
112
+ return { totalTextMethods: textHelp.methods.length, ftsMethods };
113
+ ```
114
+
115
+ Expected: `ftsMethods` is empty. The 5 FTS5 tools should not appear.
116
+
117
+ ---
118
+
119
+ ## Phase 2: Backup/Restore/Verify — Graceful Errors (batched)
120
+
121
+ > These 3 tools are registered in WASM but return structured errors because file system access is unavailable.
122
+
123
+ ```javascript
124
+ const failures = [];
125
+
126
+ // 2.1 — Backup
127
+ const backup = await sqlite.admin.backup({
128
+ targetPath:
129
+ "C:\\Users\\chris\\Desktop\\db-mcp\\test-server\\test-wasm-backup.db",
130
+ });
131
+ if (backup.success !== false)
132
+ failures.push("backup: expected {success: false}");
133
+ if (!backup.error || !backup.error.toLowerCase().includes("wasm")) {
134
+ failures.push(
135
+ "backup: error message should mention WASM — got: " + backup.error,
136
+ );
137
+ }
138
+
139
+ // 2.2 — Restore
140
+ const restore = await sqlite.admin.restore({
141
+ sourcePath: "C:\\Users\\chris\\Desktop\\db-mcp\\test-server\\test.db",
142
+ });
143
+ if (restore.success !== false)
144
+ failures.push("restore: expected {success: false}");
145
+ if (!restore.error || !restore.error.toLowerCase().includes("wasm")) {
146
+ failures.push(
147
+ "restore: error message should mention WASM — got: " + restore.error,
148
+ );
149
+ }
150
+
151
+ // 2.3 — Verify Backup
152
+ const verify = await sqlite.admin.verifyBackup({
153
+ backupPath: "C:\\Users\\chris\\Desktop\\db-mcp\\test-server\\test.db",
154
+ });
155
+ if (verify.success !== false)
156
+ failures.push("verifyBackup: expected {success: false}");
157
+ if (!verify.error || !verify.error.toLowerCase().includes("wasm")) {
158
+ failures.push(
159
+ "verifyBackup: error message should mention WASM — got: " + verify.error,
160
+ );
161
+ }
162
+
163
+ return { failures, success: failures.length === 0 };
164
+ ```
165
+
166
+ ---
167
+
168
+ ## Phase 3: CSV Tools — Graceful Errors (batched)
169
+
170
+ > CSV virtual tables require the `csv` extension which is not available in WASM.
171
+
172
+ ```javascript
173
+ const failures = [];
174
+
175
+ // 3.1 — Create CSV Table
176
+ const csvCreate = await sqlite.admin.createCsvTable({
177
+ tableName: "temp_wasm_csv",
178
+ filePath: "C:\\Users\\chris\\Desktop\\db-mcp\\test-server\\sample.csv",
179
+ });
180
+ if (csvCreate.success !== false)
181
+ failures.push("createCsvTable: expected {success: false}");
182
+
183
+ // 3.2 — Analyze CSV Schema
184
+ const csvAnalyze = await sqlite.admin.analyzeCsvSchema({
185
+ filePath: "C:\\Users\\chris\\Desktop\\db-mcp\\test-server\\sample.csv",
186
+ });
187
+ if (csvAnalyze.success !== false)
188
+ failures.push("analyzeCsvSchema: expected {success: false}");
189
+
190
+ return { failures, success: failures.length === 0 };
191
+ ```
192
+
193
+ ---
194
+
195
+ ## Phase 4: R-Tree — Graceful Error
196
+
197
+ > R-Tree spatial indexing requires a module not available in WASM's sql.js.
198
+
199
+ ```javascript
200
+ const failures = [];
201
+
202
+ const rtree = await sqlite.admin.createRtreeTable({
203
+ tableName: "temp_wasm_rtree",
204
+ dimensions: 2,
205
+ });
206
+ if (rtree.success !== false)
207
+ failures.push("createRtreeTable: expected {success: false}");
208
+
209
+ return { failures, success: failures.length === 0 };
210
+ ```
211
+
212
+ ---
213
+
214
+ ## Phase 5: FTS5 — Phantom Table Behavior (batched)
215
+
216
+ > `test_articles_fts` exists in sqlite_master (created by native seed) but FTS5 queries will fail in WASM.
217
+
218
+ ```javascript
219
+ const failures = [];
220
+
221
+ // 5.1 — Verify phantom table appears in sqlite_master
222
+ const tables = await sqlite.core.readQuery(
223
+ "SELECT name, type FROM sqlite_master WHERE name = 'test_articles_fts'",
224
+ );
225
+ if (!tables.rows || tables.rows.length === 0) {
226
+ failures.push(
227
+ "test_articles_fts not found in sqlite_master — seed may not include FTS5",
228
+ );
229
+ }
230
+
231
+ // 5.2 — Attempting FTS5 query should fail gracefully
232
+ const ftsQuery = await sqlite.core.readQuery({
233
+ query:
234
+ "SELECT * FROM test_articles_fts WHERE test_articles_fts MATCH 'SQLite' LIMIT 1",
235
+ });
236
+ // This should either return {success: false} or empty results — it should NOT crash
237
+ if (ftsQuery.success === false) {
238
+ // Expected: structured error
239
+ } else if (ftsQuery.rows && ftsQuery.rows.length > 0) {
240
+ failures.push(
241
+ "FTS5 query succeeded in WASM — unexpected (sql.js should not support FTS5)",
242
+ );
243
+ }
244
+
245
+ return { failures, success: failures.length === 0 };
246
+ ```
247
+
248
+ ---
249
+
250
+ ## Phase 6: dbstat WASM Fallback
251
+
252
+ > In WASM, `dbstat` returns counts-only (JS fallback) rather than per-table storage breakdown.
253
+
254
+ ```javascript
255
+ const failures = [];
256
+
257
+ const dbstat = await sqlite.admin.dbstat({ summarize: true });
258
+ // Should succeed but with limited data
259
+ if (dbstat.success === false) {
260
+ failures.push("dbstat failed entirely in WASM — expected JS fallback");
261
+ }
262
+
263
+ return {
264
+ failures,
265
+ success: failures.length === 0,
266
+ dbstatResult: dbstat,
267
+ };
268
+ ```
269
+
270
+ ---
271
+
272
+ ## Phase 7: PRAGMA Compile Options — FTS3 vs FTS5
273
+
274
+ > WASM (sql.js) is compiled with FTS3, not FTS5.
275
+
276
+ ```javascript
277
+ const failures = [];
278
+
279
+ const options = await sqlite.admin.pragmaCompileOptions({});
280
+ const optionList = options.compileOptions || options.options || [];
281
+
282
+ const hasFTS5 = optionList.some((o) => o.toUpperCase().includes("FTS5"));
283
+ const hasFTS3 = optionList.some((o) => o.toUpperCase().includes("FTS3"));
284
+
285
+ if (hasFTS5) {
286
+ failures.push("WASM should NOT have FTS5 compile option");
287
+ }
288
+
289
+ return {
290
+ failures,
291
+ success: failures.length === 0,
292
+ hasFTS3,
293
+ hasFTS5,
294
+ optionCount: optionList.length,
295
+ };
296
+ ```
297
+
298
+ ---
299
+
300
+ ## Phase 8: Zod Validation — WASM-Degraded Tools (batched)
301
+
302
+ > Even though these tools degrade gracefully for domain reasons, their Zod validation must also work. Passing `{}` should return a structured error, not a raw MCP exception.
303
+
304
+ ```javascript
305
+ const failures = [];
306
+
307
+ const zodTests = [
308
+ { name: "backup", fn: () => sqlite.admin.backup({}) },
309
+ { name: "restore", fn: () => sqlite.admin.restore({}) },
310
+ { name: "verifyBackup", fn: () => sqlite.admin.verifyBackup({}) },
311
+ { name: "createCsvTable", fn: () => sqlite.admin.createCsvTable({}) },
312
+ { name: "analyzeCsvSchema", fn: () => sqlite.admin.analyzeCsvSchema({}) },
313
+ { name: "createRtreeTable", fn: () => sqlite.admin.createRtreeTable({}) },
314
+ ];
315
+
316
+ for (const test of zodTests) {
317
+ const result = await test.fn();
318
+ if (result.success !== false) {
319
+ failures.push(`${test.name}({}): expected {success: false}`);
320
+ }
321
+ }
322
+
323
+ return { failures, success: failures.length === 0 };
324
+ ```
325
+
326
+ ---
327
+
328
+ ## Phase 9: Multi-Step WASM Workflow
329
+
330
+ ### 9.1 — WASM capability audit pipeline
331
+
332
+ ```javascript
333
+ const failures = [];
334
+
335
+ // Step 1: Get full API surface
336
+ const help = await sqlite.help();
337
+ const groups = help.groups;
338
+ const totalMethods = help.totalMethods;
339
+
340
+ // Step 2: Check each group's method count
341
+ const groupSizes = {};
342
+ for (const g of groups) {
343
+ const gHelp = await sqlite[g].help();
344
+ groupSizes[g] = gHelp.methods.length;
345
+ }
346
+
347
+ // Step 3: Verify transactions is empty
348
+ if (groupSizes.transactions > 0) {
349
+ failures.push(
350
+ `transactions should have 0 methods, got ${groupSizes.transactions}`,
351
+ );
352
+ }
353
+
354
+ // Step 4: Verify no window methods in stats
355
+ const statsHelp = await sqlite.stats.help();
356
+ const windowMethods = statsHelp.methods.filter((m) => m.startsWith("window"));
357
+ if (windowMethods.length > 0) {
358
+ failures.push(
359
+ `stats should have 0 window methods, got ${windowMethods.length}`,
360
+ );
361
+ }
362
+
363
+ // Step 5: Test a WASM-compatible tool works
364
+ const count = await sqlite.core.count({ table: "test_products" });
365
+ if (count.count !== 16)
366
+ failures.push(`expected 16 products, got ${count.count}`);
367
+
368
+ // Step 6: Test a degraded tool fails gracefully
369
+ const backup = await sqlite.admin.backup({ targetPath: "wasm-test.db" });
370
+ if (backup.success !== false) failures.push("backup should fail in WASM");
371
+
372
+ return {
373
+ failures,
374
+ success: failures.length === 0,
375
+ summary: {
376
+ totalGroups: groups.length,
377
+ totalMethods,
378
+ groupSizes,
379
+ wasmCompatible: true,
380
+ },
381
+ };
382
+ ```
383
+
384
+ ---
385
+
386
+ ## Post-Test Procedures
387
+
388
+ 1. **No cleanup needed**: This prompt does not create any tables (all write operations are expected to fail)
389
+ 2. **Triage findings**: Create implementation plan if any tool returns raw MCP error instead of structured error
390
+ 3. **Scope of fixes**: Handler code only — fix WASM error handling paths
391
+ 4. **Validate**: Instruct the user to run the test suite (Vitest/Playwright), lint, and typecheck. Do NOT run them yourself.
392
+ 5. **Commit**: Stage and commit — do NOT push
393
+ 6. **Token audit**: Report most expensive block
394
+ 7. **Final summary**: After testing/re-testing
@@ -2,7 +2,7 @@
2
2
  -- DB-MCP Test Database - Seed Data
3
3
  -- =============================================================================
4
4
  -- This file creates all test tables needed for comprehensive testing of
5
- -- the db-mcp SQLite MCP server's 9 tool groups.
5
+ -- the db-mcp SQLite MCP server's 10 tool groups.
6
6
  --
7
7
  -- Usage: sqlite3 test.db < test-database.sql
8
8
  -- =============================================================================
@@ -367,10 +367,46 @@ FROM (
367
367
  -- =============================================================================
368
368
  -- When the MCP server holds the DB open, the reset script overwrites in-place.
369
369
  -- Non-test tables from prior runs survive because only test_* tables are re-created.
370
+ -- This section drops all known artifact patterns to prevent stale warnings.
370
371
 
372
+ -- temp_* leftovers from ad-hoc testing
371
373
  DROP TABLE IF EXISTS temp_text_test;
374
+ DROP TABLE IF EXISTS temp_series_test;
372
375
  DROP TABLE IF EXISTS "";
373
376
 
377
+ -- stress_* leftovers from advanced stress tests
378
+ DROP TABLE IF EXISTS stress_empty_table;
379
+ DROP TABLE IF EXISTS stress_cycle_table;
380
+ DROP TABLE IF EXISTS stress_json_test;
381
+ DROP TABLE IF EXISTS stress_json_write;
382
+ DROP TABLE IF EXISTS stress_json_inject;
383
+ DROP TABLE IF EXISTS stress_sentiment_test;
384
+ DROP TABLE IF EXISTS stress_stats_table;
385
+ DROP TABLE IF EXISTS stress_vec_empty;
386
+ DROP TABLE IF EXISTS stress_pipeline;
387
+ DROP TABLE IF EXISTS stress_search;
388
+ DROP TABLE IF EXISTS stress_migrated;
389
+ DROP TABLE IF EXISTS stress_migration_data;
390
+ DROP TABLE IF EXISTS stress_tx_test;
391
+ DROP TABLE IF EXISTS stress_tx_fail;
392
+ DROP TABLE IF EXISTS stress_tx_fail2;
393
+ DROP TABLE IF EXISTS stress_tx_sp;
394
+ DROP TABLE IF EXISTS stress_geo_spatial;
395
+ DROP TABLE IF EXISTS stress_rtree_test;
396
+ DROP TABLE IF EXISTS stress_csv;
397
+ DROP VIEW IF EXISTS stress_view_orders;
398
+ DROP INDEX IF EXISTS stress_idx_cycle;
399
+ DROP INDEX IF EXISTS stress_idx_flag;
400
+
401
+ -- E2E Playwright SpatiaLite R-Tree shadow tables
402
+ DROP TABLE IF EXISTS idx__e2e_spatial_test_geom;
403
+ DROP TABLE IF EXISTS idx__e2e_spatial_test_geom_node;
404
+ DROP TABLE IF EXISTS idx__e2e_spatial_test_geom_parent;
405
+ DROP TABLE IF EXISTS idx__e2e_spatial_test_geom_rowid;
406
+
407
+ -- Migration tracking table
408
+ DROP TABLE IF EXISTS _mcp_migrations;
409
+
374
410
  -- =============================================================================
375
411
  -- Summary: Test Tables Created
376
412
  -- =============================================================================
@@ -1,19 +1,22 @@
1
1
  # db-mcp Resource Testing Plan
2
2
 
3
- Please test all db-mcp resources (8 data + up to 9 help) using the test database (test-server/test.db) and concisely report any issues.
3
+ Please test all db-mcp resources (11 data + up to 9 help) using the test database (test-server/test.db) and concisely report any issues.
4
4
 
5
5
  ## Resources to Test
6
6
 
7
- | # | Resource Name | URI | Type | Expected Data Source |
8
- | --- | ------------------- | ---------------------------- | --------- | ------------------------------------------ |
9
- | 1 | sqlite_schema | sqlite://schema | Static | Full schema via adapter.getSchema() |
10
- | 2 | sqlite_tables | sqlite://tables | Static | Table list via adapter.listTables() |
11
- | 3 | sqlite_table_schema | sqlite://table/{name}/schema | Templated | Specific table via adapter.describeTable() |
12
- | 4 | sqlite_indexes | sqlite://indexes | Static | All indexes via adapter.getAllIndexes() |
13
- | 5 | sqlite_views | sqlite://views | Static | Views from sqlite_master |
14
- | 6 | sqlite_health | sqlite://health | Static | Connection health via adapter.getHealth() |
15
- | 7 | sqlite_meta | sqlite://meta | Static | PRAGMA values + adapter info |
16
- | 8 | sqlite_insights | memo://insights | Static | In-memory insights memo |
7
+ | # | Resource Name | URI | Type | Expected Data Source |
8
+ | --- | ---------------------- | ---------------------------- | --------- | ------------------------------------------ |
9
+ | 1 | sqlite_schema | sqlite://schema | Static | Full schema via adapter.getSchema() |
10
+ | 2 | sqlite_tables | sqlite://tables | Static | Table list via adapter.listTables() |
11
+ | 3 | sqlite_table_schema | sqlite://table/{name}/schema | Templated | Specific table via adapter.describeTable() |
12
+ | 4 | sqlite_indexes | sqlite://indexes | Static | All indexes via adapter.getAllIndexes() |
13
+ | 5 | sqlite_views | sqlite://views | Static | Views from sqlite_master |
14
+ | 6 | sqlite_health | sqlite://health | Static | Connection health via adapter.getHealth() |
15
+ | 7 | sqlite_meta | sqlite://meta | Static | PRAGMA values + adapter info |
16
+ | 8 | sqlite_compile_options | sqlite://compile_options | Static | SQLite compile-time build options |
17
+ | 9 | sqlite_pragma | sqlite://pragma | Static | Runtime PRAGMA config snapshot |
18
+ | 10 | sqlite_insights | memo://insights | Static | In-memory insights memo |
19
+ | 11 | sqlite_audit | sqlite://audit | Static | Audit log access (if enabled) |
17
20
 
18
21
  ---
19
22
 
@@ -147,9 +150,9 @@ DROP VIEW IF EXISTS test_view_order_summary;
147
150
  **Test Sequence:**
148
151
 
149
152
  1. Read memo://insights — May be empty or have default content ("No business insights have been discovered yet.")
150
- 2. Call sqlite_append_insight tool with a test insight (requires admin tools)
153
+ 2. Call sqlite_append_insight tool with a test insight `{"insight": "Test insight"}` (requires admin tools)
151
154
  3. Read memo://insights again — Should contain the new insight
152
- 4. Verify timestamp, category, and finding text are present
155
+ 4. Verify the exact insight text is present
153
156
 
154
157
  **Expected Output:**
155
158
 
@@ -158,7 +161,31 @@ DROP VIEW IF EXISTS test_view_order_summary;
158
161
 
159
162
  ---
160
163
 
161
- ### 9. Help Resources On-Demand Reference Documentation
164
+ ### 9. sqlite_compile_optionsCompile-Time Options
165
+
166
+ **URI:** `sqlite://compile_options`
167
+ **Test:** Read the compile options resource.
168
+
169
+ **Expected Output:**
170
+
171
+ - JSON with an `options` array, `count`, and `highlights` array.
172
+ - Should contain fundamental build options (e.g., `THREADSAFE`).
173
+
174
+ ---
175
+
176
+ ### 10. sqlite_pragma — Runtime Configuration Snapshot
177
+
178
+ **URI:** `sqlite://pragma`
179
+ **Test:** Read the pragma configuration resource.
180
+
181
+ **Expected Output:**
182
+
183
+ - JSON with a `settings` object grouping configuration into categories (storage, performance, safety, behavior).
184
+ - Each setting should include `value`, `category`, and `description`.
185
+
186
+ ---
187
+
188
+ ### 11. Help Resources — On-Demand Reference Documentation
162
189
 
163
190
  **Test A — sqlite://help (always registered):**
164
191
 
@@ -231,9 +258,9 @@ Use live MCP resource reads via the `read_resource` tool against the running sql
231
258
 
232
259
  | Metric | Value |
233
260
  | ------------------------- | -------------------------------------------- |
234
- | Data resources to test | 8 |
261
+ | Data resources to test | 10 |
235
262
  | Help resources to test | 1 (sqlite://help) + up to 8 group-specific |
236
- | Static resources | 7 |
263
+ | Static resources | 9 |
237
264
  | Templated resources | 1 (sqlite_table_schema with URI parameter) |
238
265
  | Protocol validation tests | 2 (help resource content + tool annotations) |
239
266
  | Error cases to test | 1 (nonexistent table in template) |
@@ -0,0 +1,100 @@
1
+ # db-mcp Standard Testing Suite
2
+
3
+ **Directory Purpose**: This folder contains 10 self-contained, modular test prompts covering every tool group in `db-mcp`. Each file is a **complete, standalone prompt** — paste it directly into a conversation to test that tool group without needing any other files.
4
+
5
+ ## File Inventory
6
+
7
+ | File | Group | Tools | Notes |
8
+ | ----------------------------------- | ------------------------- | -------------- | -------------------------------- |
9
+ | `test-core-data.md` | core-data | 7 | Identical Native/WASM |
10
+ | `test-core-schema.md` | core-schema | 8 + Code Mode | Identical Native/WASM |
11
+ | `test-json-read.md` | json-read | 18 | Identical Native/WASM |
12
+ | `test-json-write.md` | json-write | 7 | Identical Native/WASM |
13
+ | `test-text-basic.md` | text-basic | 11 + Code Mode | Identical Native/WASM |
14
+ | `test-text-advanced.md` | text-advanced | 9N/4W | FTS5 tools `[NATIVE ONLY]` |
15
+ | `test-stats-basic.md` | stats-basic | 16 + Code Mode | Identical Native/WASM |
16
+ | `test-stats-advanced.md` | stats-advanced | 6N/0W | Window functions `[NATIVE ONLY]` |
17
+ | `test-vector-read.md` | vector-read | 7 + Code Mode | Identical Native/WASM |
18
+ | `test-vector-write.md` | vector-write | 4 | Identical Native/WASM |
19
+ | `test-admin-core.md` | admin-core | 19 + Code Mode | Identical Native/WASM |
20
+ | `test-admin-extensions.md` | admin-extensions | 8 | CSV, series, rtree |
21
+ | `test-transactions.md` | transactions | 8 + Code Mode | `[NATIVE ONLY]` |
22
+ | `test-geo-haversine.md` | geo-haversine | 4 + Code Mode | Identical Native/WASM |
23
+ | `test-geo-spatialite.md` | geo-spatialite | 7N/0W | SpatiaLite `[NATIVE ONLY]` |
24
+ | `test-introspection-schema.md` | introspection-schema | 6 | Identical Native/WASM |
25
+ | `test-introspection-diagnostics.md` | introspection-diagnostics | 3 + Code Mode | Identical Native/WASM |
26
+ | `test-migration.md` | migration | 6 + Code Mode | Identical Native/WASM |
27
+
28
+ **Total**: 151 Native / 125 WASM tools across 10 groups + Code Mode.
29
+
30
+ ## Agent Instructions
31
+
32
+ When tasked with running tests from this folder, adhere to the following protocol:
33
+
34
+ ### 1. Execution Strictness
35
+
36
+ - **Direct Calls Exclusive**: Test tools ONLY using direct MCP tool calls (e.g., calling `mcp_sqlite_sqlite_read_query`). Do not use Code Mode (`sqlite_execute_code`) or scripts to batch the tests, except for checklist items explicitly testing Code Mode.
37
+ - **No Scripted Loops**: Each happy and error path must be tested individually with a distinct tool call. This simulates exact client interaction behavior.
38
+
39
+ ### 2. Validation Targets
40
+
41
+ - **Happy Path Consistency**: Validate that each tool outputs exactly what is expected from the explicit checklist items given in the prompt.
42
+ - **Structured Error Path**: Ensure domain errors (e.g., nonexistent table) return an object `{"success": false, "error": "..."}`. A raw MCP error indicates a missing try/catch in the handler.
43
+ - **Zod Exceptions**: Pass `{}` with missing required parameters or invalid types. The response must be a handler error, not a raw MCP `-32602` error.
44
+ - **Payload Limits**: Watch for payload bloat and explicitly log it as a 📦 warning if it risks overflowing context window token limits.
45
+ - **Code Over Docs (When Standards Violated)**: If the code deviates from established standards (e.g., throwing raw MCP errors instead of Structured Errors, or failing Zod validation), **fix the handler code**. Do not modify documentation, prompts, or `gotchas.md` to accommodate buggy code.
46
+ - **Documentation Parity & Test Prompt Integrity**: Only update files in `src/constants/server-instructions` (or test prompts) if the code's behavior is mathematically/logically correct and intended, but the documentation is inaccurate, outdated, or lacking specificity. You SHOULD directly edit the markdown test files in this directory to fix factual errors, broken code blocks, or incorrect test assertions.
47
+
48
+ ### 2.5 Testing Limits
49
+
50
+ - **No Automated Execution**: Do not run build or tests automatically (`npm run lint`, `npm run typecheck`, `npm run test:e2e`, `vitest`, or `playwright`). The user will execute them manually. When you reach the validate step, explicitly instruct the user to run the validations.
51
+
52
+ ### 2.6 WASM Mode Execution
53
+
54
+ When testing against a **WASM backend** (`sqlite-wasm` server entry, sql.js adapter), follow these additional rules:
55
+
56
+ #### Skip Rules
57
+
58
+ - **`[NATIVE ONLY]` items**: Skip all checklist items and Zod sweep items for tools annotated with `[NATIVE ONLY]`.
59
+ - **Transactions prompt**: Skip entirely — all 8 transaction tools are `[NATIVE ONLY]`.
60
+ - **Window function tools** (stats items 20-25): Skip — 6 window tools are Native-only.
61
+ - **SpatiaLite tools** (geo items 8-14): Skip — 7 SpatiaLite tools are Native-only.
62
+ - **FTS5 tools** (text items 18-22): Skip — 5 FTS5 tools are Native-only.
63
+ - **Unregistered tools**: In WASM mode, `[NATIVE ONLY]` tools are not registered at all. Direct MCP calls to them will fail with an "unknown tool" error — this is expected, not a bug.
64
+
65
+ #### Graceful Degradation (Don't Skip — Validate Errors)
66
+
67
+ Several admin tools are **registered in WASM mode but return structured errors**. Test these as **negative validation**:
68
+
69
+ | Tool | Expected WASM Behavior |
70
+ | --------------------------- | ---------------------------------------------- |
71
+ | `sqlite_backup` | `{success: false, error: "...WASM mode"}` |
72
+ | `sqlite_restore` | `{success: false, error: "...WASM mode"}` |
73
+ | `sqlite_verify_backup` | `{success: false, error: "...WASM mode"}` |
74
+ | `sqlite_create_csv_table` | `{success: false}` — CSV extension unavailable |
75
+ | `sqlite_analyze_csv_schema` | `{success: false}` — CSV extension unavailable |
76
+ | `sqlite_create_rtree_table` | `{success: false}` — R-Tree module unavailable |
77
+
78
+ #### Adjusted Expectations
79
+
80
+ | Item | Native Behavior | WASM Behavior |
81
+ | --------------------------------------------------- | --------------------------- | -------------------------------- |
82
+ | `sqlite_dbstat({summarize: true})` | Per-table storage breakdown | Counts-only (JS fallback) |
83
+ | `sqlite_pragma_compile_options({filter: "FTS"})` | Matches FTS5 | Matches FTS3 |
84
+ | `test_articles_fts` in `sqlite_list_virtual_tables` | Present and queryable | May appear but FTS5 queries fail |
85
+
86
+ ### 3. Tracking Metrics & Progress
87
+
88
+ - **Strict Coverage Matrix**: Maintain a table tracking your progress in `tmp/task.md` logging completion for:
89
+ `| Tool | Direct Call (Happy Path) | Domain Error | Zod Empty Param | Alias Acceptance |`
90
+ Never proceed to the final step until every tool in a given group is fully checked off.
91
+
92
+ ### 4. Cleanup & Scope
93
+
94
+ - Direct write tests should operate on temporary tables or objects prefixed with `temp_`.
95
+ - When completed, explicitly drop all `temp_` artifacts.
96
+ - Update `code-map.md`, handlers, and instructions if bugs are uncovered, then update the Changelog with fixes before summarizing your work.
97
+
98
+ ## Execution
99
+
100
+ Begin with any requested group prompt from this folder (e.g., `test-admin.md`), and execute the deterministic checklist line-by-line using direct tool calls only.