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,165 @@
1
+ # db-mcp Tool Group Testing: [admin-core]
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 Native mode.
7
+
8
+ ## WASM Mode
9
+
10
+ > When testing against a **WASM backend** (`sqlite-wasm` / sql.js), apply these adjustments:
11
+ >
12
+ > - **Items 13-15** (`sqlite_backup`, `sqlite_verify_backup`, `sqlite_restore`) — return `{success: false, error: "...WASM mode"}`. Treat as **negative validation** — verify the structured error, do not skip.
13
+ > - **Item 10** (`sqlite_pragma_compile_options` FTS filter) — WASM shows FTS3 instead of FTS5.
14
+ > - **Item 3** (`sqlite_dbstat` with `summarize: true`) — WASM returns counts-only (JS fallback) instead of per-table storage breakdown.
15
+
16
+ **Step 1:** Confirm you read the server help content sourced from `C:\Users\chris\Desktop\db-mcp\src\constants\server-instructions\gotchas.md` using `view_file` (not grep or search) — to understand documented behaviors, edge cases, and response structures for this tool group.
17
+
18
+ **Step 2:** Please conduct an exhaustive test of the **admin-core** tool group specified in the group-specific checklist below using live MCP server tool calls directly — not scripts/terminal.
19
+
20
+ **Step 3:** The agent should update C:\Users\chris\Desktop\db-mcp\UNRELEASED.md with any/all changes/fixes.
21
+
22
+ **Note** If temp tables are present from a previous test pass, it's because the database is locked. Ignore them.
23
+
24
+ ## Reporting Format
25
+
26
+ - ❌ Fail: Tool errors or produces incorrect results (include error message)
27
+ - ⚠️ Issue: Unexpected behavior or improvement opportunity
28
+ - 📦 Payload: Unnecessarily large response that should be optimized — **blocking, equally important as ❌ bugs**.
29
+
30
+ ## Test Database Schema
31
+
32
+ | Table | Rows | Columns | JSON Columns |
33
+ | ----------------- | ---- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
34
+ | test_products | 16 | id, name, description, price, category, created_at | — |
35
+ | test_orders | 20 | id, product_id (FK), customer_name, quantity, total_price, order_date, status | — |
36
+ | test_jsonb_docs | 6 | id, doc, metadata, tags, created_at | **doc**, **metadata** (nested), **tags** (array) |
37
+ | test_articles | 8 | id, title, body, author, category, published_at | — |
38
+ | test_users | 9 | id, username, email, phone, bio, created_at | — |
39
+ | test_measurements | 200 | id, sensor_id, temperature, humidity, pressure, measured_at | — |
40
+ | test_embeddings | 20 | id, content, category, embedding | **embedding** (8-dim float array); category values: database, fitness, food, tech, travel |
41
+ | test_locations | 15 | id, name, city, latitude, longitude, type | — |
42
+ | test_categories | 17 | id, name, path, level | — |
43
+ | test_events | 100 | id, event_type, user_id (INT, 8 values), payload, event_date | **payload** (JSON) |
44
+
45
+ ## Testing Requirements
46
+
47
+ > [!CAUTION]
48
+ > **Zero tolerance for raw MCP errors.** ANY response that is a raw MCP error (e.g., `-32602`, `isError: true`, no `success` field) is a **bug that must be reported and fixed**.
49
+
50
+ 1. Use existing `test_*` tables for read operations
51
+ 2. Create temporary views with `temp_view_*` prefix for write operations
52
+ 3. **Error path testing**: For **every** tool, test (a) domain error and (b) Zod validation error (`{}`). Both must return `{success: false, error: "..."}`.
53
+ 4. **Output schema testing**: For tools with `outputSchema`, confirm valid calls return structured JSON.
54
+
55
+ ## Structured Error Response Pattern
56
+
57
+ ```json
58
+ { "success": false, "error": "Human-readable error message" }
59
+ ```
60
+
61
+ | Type | Source | What you see | Verdict |
62
+ | -------------------- | ------------------------------------------------------------------ | ----------------------------------------------------------- | ------------------ |
63
+ | **Handler error** ✅ | Handler catches error and returns `{success: false, error: "..."}` | Parseable JSON object with `success` and `error` fields | Correct |
64
+ | **MCP error** ❌ | Uncaught throw propagates to MCP framework | Raw text error string, `isError: true` — no `success` field | Bug — report as ❌ |
65
+
66
+ ### Zod Validation Errors
67
+
68
+ **Zod refinement leak pattern:** `.partial()` does NOT strip `.min(N)` / `.max(N)` refinements. **Fix:** Remove refinements from schema, validate inside handler.
69
+
70
+ ### Output Schema Validation Errors
71
+
72
+ If valid inputs return raw MCP `-32602` mentioning "output schema", report as ❌.
73
+
74
+ ---
75
+
76
+ ## Group Focus: admin-core
77
+
78
+ > **Instructions**: Execute every numbered checklist item with the exact inputs shown. Compare responses against the expected results. Report any deviation.
79
+
80
+ ### admin-core Group Tools (19)
81
+
82
+ 1. sqlite_create_view
83
+ 2. sqlite_list_views
84
+ 3. sqlite_drop_view
85
+ 4. sqlite_dbstat
86
+ 5. sqlite_vacuum
87
+ 6. sqlite_backup
88
+ 7. sqlite_analyze
89
+ 8. sqlite_integrity_check
90
+ 9. sqlite_optimize
91
+ 10. sqlite_restore
92
+ 11. sqlite_verify_backup
93
+ 12. sqlite_index_stats
94
+ 13. sqlite_pragma_compile_options
95
+ 14. sqlite_pragma_database_list
96
+ 15. sqlite_pragma_optimize
97
+ 16. sqlite_pragma_settings
98
+ 17. sqlite_pragma_table_info
99
+ 18. sqlite_append_insight
100
+ 19. sqlite_execute_code
101
+
102
+ **Checklist — Pragma & Inspection:**
103
+
104
+ 1. `sqlite_pragma_database_list` → verify database path matches `test.db`
105
+ 2. `sqlite_index_stats` → verify index statistics for test database
106
+ 3. `sqlite_dbstat({summarize: true})` → per-table storage metrics
107
+ 4. `sqlite_integrity_check` → `ok` result
108
+ 5. `sqlite_analyze` → success
109
+ 6. `sqlite_vacuum` → success
110
+ 7. `sqlite_optimize` → success with optimization details
111
+ 8. `sqlite_pragma_optimize` → success (note: distinct from `sqlite_optimize` — this runs `PRAGMA optimize`)
112
+ 9. `sqlite_pragma_compile_options` → verify list of compile options returned
113
+ 10. `sqlite_pragma_compile_options({filter: "FTS"})` → filtered subset containing FTS-related options (`ENABLE_FTS3`, `ENABLE_FTS4`, `ENABLE_FTS5`)
114
+ 11. `sqlite_pragma_settings({pragma: "journal_mode"})` → `{value: "wal"}`
115
+ 12. `sqlite_pragma_table_info({table: "test_products"})` → verify columns: id, name, description, price, category, created_at
116
+
117
+ **Checklist — Backup/Restore:**
118
+
119
+ 13. `sqlite_backup({targetPath: "<absolute-path>/test-server/test-backup.db"})` → success with backup file info (⚠️ use absolute path — relative paths resolve from IDE CWD)
120
+ 14. `sqlite_verify_backup({backupPath: "<absolute-path>/test-server/test-backup.db"})` → integrity verified
121
+ 15. `sqlite_restore({sourcePath: "<absolute-path>/test-server/test-backup.db"})` → restore from backup, verify success
122
+ 16. Cleanup: note backup file location for manual removal if desired
123
+
124
+ **Checklist — View Management:**
125
+
126
+ 17. `sqlite_create_view({viewName: "temp_view_orders", selectQuery: "SELECT product_id, COUNT(*) as order_count, SUM(total_price) as revenue FROM test_orders GROUP BY product_id"})` → success
127
+ 18. `sqlite_list_views` → verify `temp_view_orders` present
128
+ 19. `sqlite_drop_view({viewName: "temp_view_orders"})` → success
129
+
130
+ **Checklist — Insights:**
131
+
132
+ 20. `sqlite_append_insight({insight: "Test insight for verification"})` → success
133
+
134
+ **Code mode testing:**
135
+
136
+ 21. `sqlite_execute_code({code: "const result = await sqlite.admin.integrityCheck(); return result;"})` → `ok` result
137
+ 22. `sqlite_execute_code({code: "const result = await sqlite.admin.pragmaSettings({pragma: 'journal_mode'}); return result;"})` → `{pragma: "journal_mode", value: "wal"}`
138
+
139
+ **Error path testing:**
140
+
141
+ 🔴 23. `sqlite_pragma_table_info({table: "nonexistent_table_xyz"})` → report behavior
142
+ 🔴 24. `sqlite_verify_backup({backupPath: "nonexistent_file.db"})` → structured error
143
+
144
+ **Zod validation sweep** — call each tool with `{}` (empty params). Must return handler error, NOT raw MCP error:
145
+
146
+ 🔴 25. `sqlite_backup({})` → handler error
147
+ 🔴 26. `sqlite_restore({})` → handler error
148
+ 🔴 27. `sqlite_verify_backup({})` → handler error
149
+ 🔴 28. `sqlite_pragma_table_info({})` → handler error
150
+ 🔴 29. `sqlite_pragma_settings({})` → handler error (has required `pragma` param)
151
+ 🔴 30. `sqlite_append_insight({})` → handler error
152
+ 🔴 31. `sqlite_create_view({})` → handler error
153
+ 🔴 32. `sqlite_drop_view({})` → handler error
154
+ 🔴 33. `sqlite_dbstat({})` → handler error (or success if no required params)
155
+
156
+ ---
157
+
158
+ ## Post-Test Procedures
159
+
160
+ 1. **Triage findings**: Create implementation plan if issues found
161
+ 2. **Scope of fixes**: Handler code, server-instructions, test database, this prompt
162
+ 3. **Validate**: Instruct the user to run the test suite (Vitest/Playwright), lint, and typecheck. Do NOT run them yourself.
163
+ 4. **Commit**: Stage and commit — do NOT push
164
+ 5. **Live re-test**: After server rebuild
165
+ 6. **Final summary**: After testing/re-testing
@@ -0,0 +1,133 @@
1
+ # db-mcp Tool Group Testing: [admin-extensions]
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 Native mode.
7
+
8
+ ## WASM Mode
9
+
10
+ > When testing against a **WASM backend** (`sqlite-wasm` / sql.js), apply these adjustments:
11
+ >
12
+ > - **Items 3-4** (`sqlite_create_csv_table`, `sqlite_analyze_csv_schema`) — return `{success: false}` in WASM (CSV extension unavailable). Treat as **negative validation**.
13
+ > - **Item 5** (`sqlite_create_rtree_table`) — returns `{success: false}` in WASM (R-Tree unavailable). Treat as **negative validation**.
14
+ > - **Item 1** (`sqlite_list_virtual_tables`) — `test_articles_fts` may appear but is not queryable.
15
+
16
+ **Step 1:** Confirm you read the server help content sourced from `C:\Users\chris\Desktop\db-mcp\src\constants\server-instructions\gotchas.md` using `view_file` (not grep or search) — to understand documented behaviors, edge cases, and response structures for this tool group.
17
+
18
+ **Step 2:** Please conduct an exhaustive test of the **admin-extensions** tool group specified in the group-specific checklist below using live MCP server tool calls directly — not scripts/terminal.
19
+
20
+ **Step 3:** The agent should update C:\Users\chris\Desktop\db-mcp\UNRELEASED.md with any/all changes/fixes.
21
+
22
+ **Note** If temp tables are present from a previous test pass, it's because the database is locked. Ignore them.
23
+
24
+ ## Reporting Format
25
+
26
+ - ❌ Fail: Tool errors or produces incorrect results (include error message)
27
+ - ⚠️ Issue: Unexpected behavior or improvement opportunity
28
+ - 📦 Payload: Unnecessarily large response that should be optimized.
29
+
30
+ ## Test Database Schema
31
+
32
+ | Table | Rows | Columns | JSON Columns |
33
+ | ----------------- | ---- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
34
+ | test_products | 16 | id, name, description, price, category, created_at | — |
35
+ | test_orders | 20 | id, product_id (FK), customer_name, quantity, total_price, order_date, status | — |
36
+ | test_jsonb_docs | 6 | id, doc, metadata, tags, created_at | **doc**, **metadata** (nested), **tags** (array) |
37
+ | test_articles | 8 | id, title, body, author, category, published_at | — |
38
+ | test_users | 9 | id, username, email, phone, bio, created_at | — |
39
+ | test_measurements | 200 | id, sensor_id, temperature, humidity, pressure, measured_at | — |
40
+ | test_embeddings | 20 | id, content, category, embedding | **embedding** (8-dim float array); category values: database, fitness, food, tech, travel |
41
+ | test_locations | 15 | id, name, city, latitude, longitude, type | — |
42
+ | test_categories | 17 | id, name, path, level | — |
43
+ | test_events | 100 | id, event_type, user_id (INT, 8 values), payload, event_date | **payload** (JSON) |
44
+
45
+ ## Testing Requirements
46
+
47
+ > [!CAUTION]
48
+ > **Zero tolerance for raw MCP errors.** ANY response that is a raw MCP error (e.g., `-32602`, `isError: true`, no `success` field) is a **bug that must be reported and fixed**.
49
+
50
+ 1. Use existing `test_*` tables for read operations
51
+ 2. Create temporary tables with `temp_*` prefix for write operations
52
+ 3. **Error path testing**: For **every** tool, test (a) domain error and (b) Zod validation error (`{}`). Both must return `{success: false, error: "..."}`.
53
+ 4. **Output schema testing**: For tools with `outputSchema`, confirm valid calls return structured JSON.
54
+
55
+ ## Structured Error Response Pattern
56
+
57
+ ```json
58
+ { "success": false, "error": "Human-readable error message" }
59
+ ```
60
+
61
+ | Type | Source | What you see | Verdict |
62
+ | -------------------- | ------------------------------------------------------------------ | ----------------------------------------------------------- | ------------------ |
63
+ | **Handler error** ✅ | Handler catches error and returns `{success: false, error: "..."}` | Parseable JSON object with `success` and `error` fields | Correct |
64
+ | **MCP error** ❌ | Uncaught throw propagates to MCP framework | Raw text error string, `isError: true` — no `success` field | Bug — report as ❌ |
65
+
66
+ ### Zod Validation Errors
67
+
68
+ **Zod refinement leak pattern:** `.partial()` does NOT strip `.min(N)` / `.max(N)` refinements. **Fix:** Remove refinements from schema, validate inside handler.
69
+
70
+ ### Output Schema Validation Errors
71
+
72
+ If valid inputs return raw MCP `-32602` mentioning "output schema", report as ❌.
73
+
74
+ ---
75
+
76
+ ## Group Focus: admin-extensions
77
+
78
+ > **Instructions**: Execute every numbered checklist item with the exact inputs shown. Compare responses against the expected results. Report any deviation.
79
+
80
+ > **CSV Testing Note:** Use `test-server/sample.csv` (columns: id, name, category, price, quantity, created_at) with **absolute paths** for CSV tool testing — relative paths resolve from IDE CWD.
81
+
82
+ ### admin-extensions Group Tools (8)
83
+
84
+ 1. sqlite_generate_series
85
+ 2. sqlite_list_virtual_tables
86
+ 3. sqlite_virtual_table_info
87
+ 4. sqlite_drop_virtual_table
88
+ 5. sqlite_create_csv_table
89
+ 6. sqlite_analyze_csv_schema
90
+ 7. sqlite_create_rtree_table
91
+ 8. sqlite_create_series_table
92
+
93
+ **Checklist:**
94
+
95
+ **Virtual Tables:**
96
+
97
+ 1. `sqlite_list_virtual_tables` → verify `test_articles_fts` present (Native)
98
+ 2. `sqlite_virtual_table_info({tableName: "test_articles_fts"})` → verify module and column info (Native)
99
+ 3. `sqlite_generate_series({start: 1, stop: 5, step: 1})` → 5 values
100
+ 4. `sqlite_create_rtree_table({tableName: "temp_rtree_test", dimensions: 2})` → R-Tree virtual table created with 2D bounding box columns
101
+ 5. `sqlite_create_series_table({tableName: "temp_series_test", start: 1, stop: 10})` → regular table created with 10 rows (not a virtual table — see gotcha #14)
102
+ 6. Cleanup: `sqlite_drop_virtual_table({tableName: "temp_rtree_test"})` and `sqlite_drop_table({table: "temp_series_test"})` (series is a regular table — use core `sqlite_drop_table`)
103
+
104
+ **CSV:**
105
+
106
+ 7. `sqlite_analyze_csv_schema({filePath: "<absolute-path>/test-server/sample.csv"})` → inferred column types (⚠️ CSV requires absolute paths — see gotcha #13)
107
+ 8. `sqlite_create_csv_table({tableName: "temp_csv_test", filePath: "<absolute-path>/test-server/sample.csv"})` → virtual table created
108
+ 9. Cleanup: `sqlite_drop_virtual_table({tableName: "temp_csv_test"})`
109
+
110
+ **Error path testing:**
111
+
112
+ 🔴 10. `sqlite_virtual_table_info({tableName: "nonexistent_table_xyz"})` → structured error
113
+
114
+ **Zod validation sweep** — call each tool with `{}` (empty params). Must return handler error, NOT raw MCP error:
115
+
116
+ 🔴 11. `sqlite_virtual_table_info({})` → handler error
117
+ 🔴 12. `sqlite_drop_virtual_table({})` → handler error
118
+ 🔴 13. `sqlite_create_csv_table({})` → handler error
119
+ 🔴 14. `sqlite_analyze_csv_schema({})` → handler error
120
+ 🔴 15. `sqlite_create_rtree_table({})` → handler error
121
+ 🔴 16. `sqlite_create_series_table({})` → handler error
122
+ 🔴 17. `sqlite_generate_series({})` → handler error
123
+
124
+ ---
125
+
126
+ ## Post-Test Procedures
127
+
128
+ 1. **Triage findings**: Create implementation plan if issues found
129
+ 2. **Scope of fixes**: Handler code, server-instructions, test database, this prompt
130
+ 3. **Validate**: Instruct the user to run the test suite (Vitest/Playwright), lint, and typecheck. Do NOT run them yourself.
131
+ 4. **Commit**: Stage and commit — do NOT push
132
+ 5. **Live re-test**: After server rebuild
133
+ 6. **Final summary**: After testing/re-testing
@@ -1,13 +1,28 @@
1
- # db-mcp (SQLite) Tool Testing
1
+ # db-mcp Tool Group Testing: [core-data]
2
2
 
3
- **Ignore WASM content. Test Native Mode Only**
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 Native mode.
7
+
8
+ ## WASM Mode
9
+
10
+ > When testing against a **WASM backend** (`sqlite-wasm` / sql.js): All 7 core data tools are fully WASM-compatible. No items to skip or adjust.
4
11
 
5
12
  **Step 1:** Confirm you read the server help content sourced from `C:\Users\chris\Desktop\db-mcp\src\constants\server-instructions\gotchas.md` using `view_file` (not grep or search) — to understand documented behaviors, edge cases, and response structures for this tool group.
6
13
 
7
- **Step 2:** Please conduct an exhaustive test of the tool group specified in the group-specific checklist (pasted after this document) using live MCP server tool calls directly — not scripts/terminal.
14
+ **Step 2:** Please conduct an exhaustive test of the **core-data** tool group specified in the group-specific checklist below using live MCP server tool calls directly — not scripts/terminal.
15
+
16
+ **Step 3:** The agent should update C:\Users\chris\Desktop\db-mcp\UNRELEASED.md with any/all changes/fixes.
8
17
 
9
18
  **Note** If temp tables are present from a previous test pass, it's because the database is locked. Ignore them.
10
19
 
20
+ ## Reporting Format
21
+
22
+ - ❌ Fail: Tool errors or produces incorrect results (include error message)
23
+ - ⚠️ Issue: Unexpected behavior or improvement opportunity
24
+ - 📦 Payload: Unnecessarily large response that should be optimized — **blocking, equally important as ❌ bugs**. Oversized payloads waste LLM context window tokens and degrade downstream tool-calling quality. Report the response size in KB and suggest a concrete optimization (e.g., filter system tables, add `compact` option, omit empty arrays).
25
+
11
26
  ## Test Database Schema
12
27
 
13
28
  The test database (test-server/test.db) contains these tables with JSON-relevant columns:
@@ -36,8 +51,6 @@ The test database (test-server/test.db) contains these tables with JSON-relevant
36
51
 
37
52
  > **Note:** `test_measurements.sensor_id` is an **INTEGER** column (values 1-5), not a string. Use `sensor_id = 1`, not `sensor_id = 'S001'`.
38
53
 
39
- > **Note:** When testing `sqlite_execute_code`, do **not** pass `readonly: true` unless specifically testing read-only filtering. The `readonly` flag makes write methods return structured errors (`{success: false, code: "CODEMODE_READONLY_VIOLATION"}`). Methods remain callable but reject write operations. Use `readonly: false` (or omit it) to get the full API surface.
40
-
41
54
  ## Testing Requirements
42
55
 
43
56
  > [!CAUTION]
@@ -49,8 +62,9 @@ The test database (test-server/test.db) contains these tables with JSON-relevant
49
62
  4. Report all failures, unexpected behaviors, improvement opportunities, or unnecessarily large payloads
50
63
  5. Do not mention what already works well or issues well documented in help resources and runtime hints which are already optimal
51
64
  6. **Error path testing**: For **every** tool, test at least **two** invalid inputs: (a) a domain error (nonexistent table, invalid column, missing required parameter) and (b) a **Zod validation error** (call the tool with `{}` empty params if it has required parameters, or pass the wrong type). Both must return a **structured handler error** (`{success: false, error: "..."}`) — NOT a raw MCP error frame. See the "Structured Error Response Pattern" section below for how to distinguish the two. This is the most common deficiency found across tool groups.
52
- 7. **Output schema testing**: For **every** tool that has an `outputSchema`, confirm that at least one valid happy-path call returns a structured JSON response — NOT a raw MCP `-32602` "output schema" error. Output schema mismatches (handler returns fields not declared in the schema) produce the same `-32602` code as input errors but are only caught with valid inputs. See "Output Schema Validation Errors" below. Also check for the inverse: if a schema is **defined** in `src/adapters/sqlite/output-schemas/` but **not wired** to the tool definition, report as ⚠️ — the schema exists but provides no enforcement.
65
+ 7. **Output schema testing**: For **every** tool that has an `outputSchema`, confirm that at least one valid happy-path call returns a structured JSON response — NOT a raw MCP `-32602` "output schema" error. Output schema mismatches (handler returns fields not declared in the schema) produce the same `-32602` code as input errors but are only caught with valid inputs. See "Output Schema Validation Errors" below. Also check for the inverse: if a schema is **defined** in `src/adapters/sqlite/schemas/` but **not wired** to the tool definition, report as ⚠️ — the schema exists but provides no enforcement.
53
66
  8. **Deterministic checklist first**: Complete ALL items in the group-specific checklist before moving to freeform exploration. The checklist uses exact inputs and expected outputs to ensure reproducible coverage every run.
67
+ 9. **Code Over Docs**: Fix the handler code if standards (Structured Errors/Zod) are violated. Do NOT change docs/prompts to accommodate broken code.
54
68
 
55
69
  ## Structured Error Response Pattern
56
70
 
@@ -119,7 +133,7 @@ The MCP SDK enforces `additionalProperties: false` on **output** schemas. If a h
119
133
  - **Input `-32602`**: Triggered by sending unrecognized/invalid parameters → caught by the Zod sweep (call with `{}` or `extraParam`)
120
134
  - **Output `-32602`**: Triggered by the handler **returning** undeclared fields → caught by a valid happy-path call that still produces a raw MCP error
121
135
 
122
- **How to detect:** If a tool call with **correct, valid inputs** returns a raw MCP `-32602` mentioning "does not match the tool's output schema" or "additional properties", the output schema in `src/adapters/sqlite/output-schemas/` is missing fields that the handler returns. Report as ❌ with both the tool name and the missing field(s).
136
+ **How to detect:** If a tool call with **correct, valid inputs** returns a raw MCP `-32602` mentioning "does not match the tool's output schema" or "additional properties", the output schema in `src/adapters/sqlite/schemas/` is missing fields that the handler returns. Report as ❌ with both the tool name and the missing field(s).
123
137
 
124
138
  **Fix pattern:** Add the missing fields to the output schema (e.g., `durationMs: z.number().optional()`, `message: z.string().optional()`). Do NOT remove fields from the handler response — the schema must match reality.
125
139
 
@@ -134,8 +148,21 @@ During testing, check for these inconsistencies across tool groups:
134
148
  3. **Zod validation leaks**: If calling a tool with an invalid enum value or missing required field produces a raw MCP `-32602` error instead of a structured response, report as ❌.
135
149
  4. **Output schema leaks**: If calling a tool with valid inputs produces a raw MCP `-32602` mentioning "output schema" or "additional properties", report as ❌ (see "Output Schema Validation Errors" above).
136
150
  5. **Centralized error formatting**: db-mcp uses `DbMcpError`. If any tool group catches errors but formats them inconsistently (e.g., different message patterns for the same error type), report as ⚠️.
137
- 6. **Orphaned output schemas**: If a schema is exported from `src/adapters/sqlite/output-schemas/` (e.g., `TransactionBeginOutputSchema`) but the corresponding tool definition does not reference it via `outputSchema`, report as ⚠️. Use `grep_search` to check whether the schema name appears in any tool file under `src/adapters/`. Defined-but-unwired schemas provide zero enforcement.
138
- 7. **Inline output schemas**: If any tool defines `outputSchema: z.object({...})` inline in the handler file instead of importing a named schema from `output-schemas/`, report as ⚠️. All output schemas must live in `src/adapters/sqlite/output-schemas/` with named exports. Use `grep_search` with pattern `outputSchema: z.object` across `src/adapters/` to detect violations.
151
+ 6. **Orphaned output schemas**: If a schema is exported from `src/adapters/sqlite/schemas/` (e.g., `TransactionBeginOutputSchema`) but the corresponding tool definition does not reference it via `outputSchema`, report as ⚠️. Use `grep_search` to check whether the schema name appears in any tool file under `src/adapters/`. Defined-but-unwired schemas provide zero enforcement.
152
+ 7. **Inline output schemas**: If any tool defines `outputSchema: z.object({...})` inline in the handler file instead of importing a named schema from `schemas/`, report as ⚠️. All output schemas must live in `src/adapters/sqlite/schemas/` with named exports. Use `grep_search` with pattern `outputSchema: z.object` across `src/adapters/` to detect violations.
153
+
154
+ ## Error Path Testing Checklist
155
+
156
+ For each tool group under test, verify at least one scenario from each applicable row:
157
+
158
+ | Error Scenario | Tool Groups to Test | Example Input |
159
+ | --------------------------------- | ----------------------------------- | ----------------------------------------------------------------------- |
160
+ | Nonexistent table | All table-accepting tools | `table: "nonexistent_xyz"` |
161
+ | Invalid SQL syntax | Core (`read_query`, `write_query`) | `query: "SELEKT * FROM"` |
162
+ | Invalid column name | Stats, JSON, text, vector, geo | `column: "nonexistent_col"` |
163
+ | Missing required field | All tools with required params | Omit `table`, `query`, etc. |
164
+ | **Zod validation (empty params)** | **Every tool with required params** | `{}` (empty object — must return handler error, not MCP `-32602` error) |
165
+ | **Zod validation (wrong type)** | **Tools with typed params** | Pass string where number expected, etc. |
139
166
 
140
167
  ### Split Schema Pattern Verification
141
168
 
@@ -144,11 +171,72 @@ All tools use the Split Schema pattern: a plain `z.object()` Base schema for MCP
144
171
  1. **Parameter visibility**: For tools with optional parameters (e.g., `limit`, `readonly`), make a direct MCP call using those parameters. If the tool ignores or rejects documented parameters, report as a Split Schema violation.
145
172
  2. **Alias acceptance**: For tools with documented parameter aliases (e.g., `table`/`tableName`, `query`/`sql`, `indexName`/`name`), verify that direct MCP tool calls correctly accept the aliases.
146
173
 
147
- ## Reporting Format
174
+ ## Cleanup Conventions
148
175
 
149
- - Fail: Tool errors or produces incorrect results (include error message)
150
- - ⚠️ Issue: Unexpected behavior or improvement opportunity
151
- - 📦 Payload: Unnecessarily large response that should be optimized — **blocking, equally important as bugs**. Oversized payloads waste LLM context window tokens and degrade downstream tool-calling quality. Report the response size in KB and suggest a concrete optimization (e.g., filter system tables, add `compact` option, omit empty arrays).
176
+ During testing, use these naming conventions:
177
+
178
+ - **Temporary tables**: Prefix with `temp_` (e.g., `temp_core_test`)
179
+
180
+ After testing, clean up:
181
+
182
+ ```sql
183
+ -- Drop temp table
184
+ DROP TABLE IF EXISTS temp_core_test;
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Group Focus: core-data
190
+
191
+ > **Instructions**: Execute every numbered checklist item with the exact inputs shown. Compare responses against the expected results. Report any deviation.
192
+
193
+ ### Built-in Tools (3)
194
+
195
+ 1. server_info
196
+ 2. server_health
197
+ 3. list_adapters
198
+
199
+ ### core-data Group Tools (7)
200
+
201
+ 4. sqlite_read_query
202
+ 5. sqlite_write_query
203
+ 6. sqlite_upsert
204
+ 7. sqlite_batch_insert
205
+ 8. sqlite_count
206
+ 9. sqlite_exists
207
+ 10. sqlite_truncate
208
+
209
+ **Checklist:**
210
+
211
+ 1. `server_info` → verify server name, version, adapter info present
212
+ 2. `server_health` → verify healthy status
213
+ 3. `list_adapters` → verify at least one adapter listed
214
+ 4. `sqlite_read_query({query: "SELECT COUNT(*) AS n FROM test_products"})` → `{rows: [{n: 16}]}`
215
+ 5. `sqlite_read_query({query: "SELECT name, price FROM test_products WHERE price > ?", params: [500]})` → 1 result: `Laptop Pro 15` (1299.99) (Note: Parameter binding test)
216
+ 6. `sqlite_read_query({query: "SELECT COUNT(*) AS n FROM test_orders WHERE status = 'completed'"})` → `{rows: [{n: 8}]}`
217
+ 7. `sqlite_create_table({table: "temp_core_test2", columns: [{name: "id", type: "INTEGER", primaryKey: true}, {name: "val", type: "TEXT"}]})` → success
218
+ 8. `sqlite_batch_insert({table: "temp_core_test2", rows: [{id: 1, val: "a"}, {id: 2, val: "b"}], returning: true})` → `{rowsAffected: 2}` and returns inserted rows (Note: Test `returning` parameter)
219
+ 9. `sqlite_upsert({table: "temp_core_test2", data: {id: 1, val: "c"}, conflictColumns: ["id"], updateColumns: ["val"], returning: true})` → `{rowsAffected: 1}` and returns updated row
220
+ 10. `sqlite_count({table: "test_products"})` → `{count: 16}`
221
+ 11. `sqlite_exists({table: "test_products", where: "id = 1"})` → `{exists: true}`
222
+ 12. `sqlite_truncate({table: "temp_core_test2"})` → `{rowsAffected: 2}`
223
+ 13. `sqlite_drop_table({table: "temp_core_test2"})` → success
224
+
225
+ **Error path testing:**
226
+
227
+ 🔴 14. `sqlite_read_query({query: "SELECT * FROM nonexistent_table_xyz"})` → structured error mentioning table name
228
+
229
+ **Zod validation sweep** — call each tool with `{}` (empty params). Every response must be a handler error (`{success: false, error: "Validation error: ..."}`) — NOT a raw MCP error frame:
230
+
231
+ 🔴 15. `sqlite_read_query({})` → handler error
232
+ 🔴 16. `sqlite_write_query({})` → handler error
233
+ 🔴 17. `sqlite_upsert({})` → handler error
234
+ 🔴 18. `sqlite_batch_insert({})` → handler error
235
+ 🔴 19. `sqlite_count({})` → handler error
236
+ 🔴 20. `sqlite_exists({})` → handler error
237
+ 🔴 21. `sqlite_truncate({})` → handler error
238
+
239
+ ---
152
240
 
153
241
  ## Post-Test Procedures
154
242
 
@@ -164,13 +252,11 @@ All tools use the Split Schema pattern: a plain `z.object()` Base schema for MCP
164
252
  - Handler code
165
253
  - `src/constants/server-instructions/*.md` (per-group help files) — run `npm run generate:instructions` after editing to regenerate `server-instructions.ts`
166
254
  - Test database (`test-server/test.db`)
167
- - This prompt (`test-tools.md`) and group file (`test-group-tools.md`)
255
+ - This prompt
168
256
 
169
257
  ### After Implementation
170
258
 
171
- 3. **Validate**: Run test suite and fix broken tests, run lint + typecheck and fix issues, update changelog (no duplicate headers)
259
+ 3. **Validate**: Instruct the user to run the test suite (Vitest/Playwright), lint, and typecheck. Do NOT run them yourself.
172
260
  4. **Commit**: Stage and commit all changes — do NOT push
173
261
  5. **Live re-test**: Test fixes with direct MCP tool calls. I will have already rebuilt and restarted the server.
174
262
  6. **Final summary**: If no issues found, provide the final summary after testing. If issues were fixed, provide the summary after live MCP re-testing confirms fixes are working. If the test prompt/database can be improved, make the improvements.
175
-
176
- ---