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,177 @@
1
+ # db-mcp Tool Group Testing: [text-basic]
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): All 11 tools in this basic text suite are fully WASM-compatible. No items to skip or adjust.
11
+
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.
13
+
14
+ **Step 2:** Please conduct an exhaustive test of the **text-basic** 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.
17
+
18
+ **Note** If temp tables are present from a previous test pass, it's because the database is locked. Ignore them.
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.
25
+
26
+ ## Test Database Schema
27
+
28
+ The test database (test-server/test.db) contains these tables with JSON-relevant columns:
29
+
30
+ | Table | Rows | Columns | JSON Columns |
31
+ | ----------------- | ---- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
32
+ | test_products | 16 | id, name, description, price, category, created_at | — |
33
+ | test_orders | 20 | id, product_id (FK), customer_name, quantity, total_price, order_date, status | — |
34
+ | test_jsonb_docs | 6 | id, doc, metadata, tags, created_at | **doc**, **metadata** (nested), **tags** (array) |
35
+ | test_articles | 8 | id, title, body, author, category, published_at | — |
36
+ | test_users | 9 | id, username, email, phone, bio, created_at | — |
37
+ | test_measurements | 200 | id, sensor_id, temperature, humidity, pressure, measured_at | — |
38
+ | test_embeddings | 20 | id, content, category, embedding | **embedding** (8-dim float array); category values: database, fitness, food, tech, travel |
39
+ | test_locations | 15 | id, name, city, latitude, longitude, type | — |
40
+ | test_categories | 17 | id, name, path, level | — |
41
+ | test_events | 100 | id, event_type, user_id (INT, 8 values), payload, event_date | **payload** (JSON) |
42
+
43
+ ## Testing Requirements
44
+
45
+ > [!CAUTION]
46
+ > **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** — never an acceptable design choice, SDK limitation, or expected behavior. If you see one, report it as ❌ immediately. Do not rationalize it as "the SDK rejecting at the boundary" or "by design for range-constrained params." The handler MUST catch it.
47
+
48
+ 1. Use existing `test_*` tables for read operations.
49
+ 2. Test each tool with realistic inputs based on the schema above.
50
+ 3. Report all failures, unexpected behaviors, improvement opportunities, or unnecessarily large payloads.
51
+ 4. **Error path testing**: For **every** tool, test at least **two** invalid inputs: (a) a domain error and (b) a **Zod validation error** (call the tool with `{}` empty params). Both must return a **structured handler error** (`{success: false, error: "..."}`) — NOT a raw MCP error frame.
52
+ 5. **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 produce the same `-32602` code as input errors but are only caught with valid inputs.
53
+ 6. **Code Over Docs**: Fix the handler code if standards (Structured Errors/Zod) are violated. Do NOT change docs/prompts to accommodate broken code.
54
+
55
+ ## Structured Error Response Pattern
56
+
57
+ All tools should return errors as structured objects instead of throwing. The expected pattern:
58
+
59
+ ```json
60
+ { "success": false, "error": "Human-readable error message" }
61
+ ```
62
+
63
+ ### Handler Error vs MCP Error — How to Distinguish
64
+
65
+ | Type | Source | What you see | Verdict |
66
+ | -------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------- | ------------------ |
67
+ | **Handler error** ✅ | Handler catches error and returns `{success: false, error: "..."}` | Parseable JSON object with `success` and `error` fields | Correct |
68
+ | **MCP error** ❌ | Uncaught throw propagates to MCP framework | Raw text error string, often prefixed with `Error:`, wrapped in an `isError: true` content block — no `success` field | Bug — report as ❌ |
69
+
70
+ ### Zod Validation Errors
71
+
72
+ Calling a tool with wrong parameter types or missing required fields triggers a Zod validation error. If the handler has no outer `try/catch`, this surfaces as a raw MCP error (often `-32602`). Test every tool with `{}` (empty params) if it has required parameters — the response must be a handler error, not an MCP error.
73
+
74
+ **Fix:** Remove ALL `.min(N)` / `.max(N)` refinements from the schema and validate inside the handler instead.
75
+
76
+ ### Wrong-Type Numeric Parameter Coercion
77
+
78
+ For every tool with optional numeric parameters (e.g., `limit`), call the tool with `param: "abc"` (string instead of number). The tool must NOT return a raw MCP `-32602` error.
79
+
80
+ ### Output Schema Validation Errors
81
+
82
+ The MCP SDK enforces `additionalProperties: false` on **output** schemas. If a handler returns fields not declared in its output schema, the SDK rejects the response with a raw `-32602` error.
83
+
84
+ **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", report as ❌ with both the tool name and the missing field(s).
85
+
86
+ ### Error Consistency Audit
87
+
88
+ 1. **Throw-vs-return**: If a tool throws a raw error instead of returning `{success: false}`, report as ❌.
89
+ 2. **Error field name**: All `{success: false}` responses should use `error` as the field name.
90
+ 3. **Zod validation leaks**: If calling a tool with missing required field produces a raw MCP `-32602` error instead of a structured response, report as ❌.
91
+ 4. **Output schema leaks**: If calling a tool with valid inputs produces a raw MCP `-32602` mentioning "output schema", report as ❌.
92
+
93
+ ---
94
+
95
+ ## Group Focus: text-basic
96
+
97
+ > **Instructions**: Execute every numbered checklist item with the exact inputs shown. Compare responses against the expected results. Report any deviation.
98
+
99
+ ### text-basic Group Tools (11)
100
+
101
+ 1. sqlite_regex_extract
102
+ 2. sqlite_regex_match
103
+ 3. sqlite_text_split
104
+ 4. sqlite_text_concat
105
+ 5. sqlite_text_replace
106
+ 6. sqlite_text_trim
107
+ 7. sqlite_text_case
108
+ 8. sqlite_text_substring
109
+ 9. sqlite_text_validate
110
+ 10. sqlite_text_normalize
111
+ 11. sqlite_execute_code
112
+
113
+ **Test data reference:**
114
+
115
+ - `test_users` (9 rows): Emails include `@example.com`, `@company.org`, `@gmail.com`, etc. One user (`testuser`) has `test.user@gmail.com`. Phone formats: `+1-555-0101`, `+44-20-7123-4567`, `+82-2-1234-5678`
116
+ - `test_products` row 16: `name = 'Café Décor Light'` — has accented characters for `strip_accents` testing
117
+
118
+ **Checklist:**
119
+
120
+ 1. `sqlite_regex_match({table: "test_users", column: "email", pattern: "@gmail\\.com$"})` → at least 1 result (`test.user@gmail.com`)
121
+ 2. `sqlite_regex_extract({table: "test_users", column: "email", pattern: "@([^.]+)\\.", groupIndex: 1})` → extract domain parts (example, company, startup, etc.)
122
+ 3. `sqlite_text_validate({table: "test_users", column: "email", pattern: "email"})` → all 9 rows should be valid emails
123
+ 4. `sqlite_text_validate({table: "test_users", column: "phone", pattern: "phone"})` → report valid/invalid counts (one user has NULL phone)
124
+ 5. `sqlite_text_case({table: "test_users", column: "username", mode: "upper"})` → all usernames uppercased
125
+ 6. `sqlite_text_normalize({table: "test_products", column: "name", mode: "strip_accents"})` → `Café Décor Light` becomes `Cafe Decor Light`
126
+ 7. `sqlite_text_split({table: "test_users", column: "email", delimiter: "@"})` → each email split into local + domain parts
127
+ 8. `sqlite_text_concat({table: "test_users", columns: ["username", "email"], separator: " - "})` → concatenated strings
128
+ 9. `sqlite_text_replace({table: "test_users", column: "email", searchPattern: "@example.com", replaceWith: "@test.org", whereClause: "email LIKE '%@example.com'"})` → 1 row affected (write operation — revert with `searchPattern: "@test.org", replaceWith: "@example.com", whereClause: "email LIKE '%@test.org'"` afterward)
129
+ 10. `sqlite_text_trim({table: "test_users", column: "bio"})` → trimmed bios
130
+ 11. `sqlite_text_substring({table: "test_users", column: "username", start: 1, length: 4})` → first 4 chars of each username
131
+
132
+ **Code mode testing:**
133
+
134
+ 12. `sqlite_execute_code({code: "const result = await sqlite.text.regexMatch({table: 'test_users', column: 'email', pattern: '@gmail\\\\.com$'}); return result;"})` → at least 1 result
135
+
136
+ **Error path testing:**
137
+
138
+ 🔴 13. `sqlite_regex_match({table: "nonexistent_table_xyz", column: "x", pattern: "."})` → structured error
139
+
140
+ **Zod validation sweep** — call each tool with `{}` (empty params). Must return handler error, NOT raw MCP error:
141
+
142
+ 🔴 14. `sqlite_regex_extract({})` → handler error
143
+ 🔴 15. `sqlite_regex_match({})` → handler error
144
+ 🔴 16. `sqlite_text_split({})` → handler error
145
+ 🔴 17. `sqlite_text_concat({})` → handler error
146
+ 🔴 18. `sqlite_text_replace({})` → handler error
147
+ 🔴 19. `sqlite_text_trim({})` → handler error
148
+ 🔴 20. `sqlite_text_case({})` → handler error
149
+ 🔴 21. `sqlite_text_substring({})` → handler error
150
+ 🔴 22. `sqlite_text_normalize({})` → handler error
151
+ 🔴 23. `sqlite_text_validate({})` → handler error
152
+ 🔴 24. `sqlite_execute_code({})` → handler error
153
+
154
+ ---
155
+
156
+ ## Post-Test Procedures
157
+
158
+ ### Reporting Rules
159
+
160
+ - Use ✅ only in inline notes during testing; omit from Final Summary
161
+ - Do not mention what already works well or issues already documented in help resources and runtime hints
162
+
163
+ ### After Testing
164
+
165
+ 1. **Triage findings**: If issues were found, create an implementation plan, making sure they are consistent with working patterns in other tools/tool groups. If the plan requires no user decisions, proceed directly to implementation
166
+ 2. **Scope of fixes** includes corrections to any of:
167
+ - Handler code
168
+ - `src/constants/server-instructions/*.md` (per-group help files) — run `npm run generate:instructions` after editing to regenerate `server-instructions.ts`
169
+ - Test database (`test-server/test.db`)
170
+ - This prompt
171
+
172
+ ### After Implementation
173
+
174
+ 3. **Validate**: Instruct the user to run the test suite (Vitest/Playwright), lint, and typecheck. Do NOT run them yourself.
175
+ 4. **Commit**: Stage and commit all changes — do NOT push
176
+ 5. **Live re-test**: Test fixes with direct MCP tool calls. I will have already rebuilt and restarted the server.
177
+ 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.
@@ -0,0 +1,179 @@
1
+ # db-mcp Tool Group Testing: [transactions]
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
+ > [!CAUTION]
11
+ > **Skip this entire prompt in WASM mode.** All 8 transaction tools are `[NATIVE ONLY]` — they are not registered in the WASM adapter. Direct MCP calls will fail with "unknown tool". Use `test-tool-group-codemode-wasm-degradation.md` to verify this behavior.
12
+
13
+ **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.
14
+
15
+ **Step 2:** Please conduct an exhaustive test of the **transactions** tool group specified in the group-specific checklist below using live MCP server tool calls directly — not scripts/terminal.
16
+
17
+ **Step 3:** The agent should update C:\Users\chris\Desktop\db-mcp\UNRELEASED.md with any/all changes/fixes.
18
+
19
+ **Note** If temp tables are present from a previous test pass, it's because the database is locked. Ignore them.
20
+
21
+ ## Reporting Format
22
+
23
+ - ❌ Fail: Tool errors or produces incorrect results (include error message)
24
+ - ⚠️ Issue: Unexpected behavior or improvement opportunity
25
+ - 📦 Payload: Unnecessarily large response that should be optimized — **blocking, equally important as ❌ bugs**. Report the response size in KB and suggest a concrete optimization.
26
+
27
+ ## Test Database Schema
28
+
29
+ | Table | Rows | Columns | JSON Columns |
30
+ | ----------------- | ---- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
31
+ | test_products | 16 | id, name, description, price, category, created_at | — |
32
+ | test_orders | 20 | id, product_id (FK), customer_name, quantity, total_price, order_date, status | — |
33
+ | test_jsonb_docs | 6 | id, doc, metadata, tags, created_at | **doc**, **metadata** (nested), **tags** (array) |
34
+ | test_articles | 8 | id, title, body, author, category, published_at | — |
35
+ | test_users | 9 | id, username, email, phone, bio, created_at | — |
36
+ | test_measurements | 200 | id, sensor_id, temperature, humidity, pressure, measured_at | — |
37
+ | test_embeddings | 20 | id, content, category, embedding | **embedding** (8-dim float array); category values: database, fitness, food, tech, travel |
38
+ | test_locations | 15 | id, name, city, latitude, longitude, type | — |
39
+ | test_categories | 17 | id, name, path, level | — |
40
+ | test_events | 100 | id, event_type, user_id (INT, 8 values), payload, event_date | **payload** (JSON) |
41
+
42
+ > **Note:** When testing `sqlite_execute_code`, do **not** pass `readonly: true` unless specifically testing read-only filtering.
43
+
44
+ ## Testing Requirements
45
+
46
+ > [!CAUTION]
47
+ > **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**.
48
+
49
+ 1. Use existing `test_*` tables for read operations
50
+ 2. Create temporary tables with `temp_*` prefix for write operations
51
+ 3. Report all failures, unexpected behaviors, or unnecessarily large payloads
52
+ 4. Do not mention what already works well or issues documented in help resources
53
+ 5. **Error path testing**: For **every** tool, test (a) domain error and (b) Zod validation error (`{}`). Both must return `{success: false, error: "..."}`.
54
+ 6. **Output schema testing**: For tools with `outputSchema`, confirm valid calls return structured JSON.
55
+ 7. **Deterministic checklist first**: Complete ALL items before freeform exploration.
56
+ 8. **Code Over Docs**: Fix the handler code if standards (Structured Errors/Zod) are violated. Do NOT change docs/prompts to accommodate broken code.
57
+
58
+ ## Structured Error Response Pattern
59
+
60
+ ```json
61
+ { "success": false, "error": "Human-readable error message" }
62
+ ```
63
+
64
+ | Type | Source | What you see | Verdict |
65
+ | -------------------- | ------------------------------------------------------------------ | ----------------------------------------------------------- | ------------------ |
66
+ | **Handler error** ✅ | Handler catches error and returns `{success: false, error: "..."}` | Parseable JSON object with `success` and `error` fields | Correct |
67
+ | **MCP error** ❌ | Uncaught throw propagates to MCP framework | Raw text error string, `isError: true` — no `success` field | Bug — report as ❌ |
68
+
69
+ ### Zod Validation Errors
70
+
71
+ **Zod refinement leak pattern:** `.partial()` does NOT strip `.min(N)` / `.max(N)` refinements. **Fix:** Remove refinements from schema, validate inside handler.
72
+
73
+ - Raw MCP error (no `success` field) → report as ❌
74
+ - `{success: false, error: "..."}` → correct
75
+ - Successful response for invalid input → report as ⚠️
76
+
77
+ ### Output Schema Validation Errors
78
+
79
+ If valid inputs return raw MCP `-32602` mentioning "output schema", report as ❌.
80
+
81
+ ### Error Consistency Audit
82
+
83
+ 1. Raw error instead of `{success: false}` → ❌
84
+ 2. Must use `error` field name
85
+ 3. Orphaned/inline output schemas → ⚠️
86
+
87
+ ### Split Schema Pattern Verification
88
+
89
+ Verify parameter visibility and alias acceptance.
90
+
91
+ ## Cleanup Conventions
92
+
93
+ - **Temporary tables**: Prefix with `temp_`
94
+ - If DROP fails due to database lock, move on.
95
+
96
+ ---
97
+
98
+ ## Group Focus: transactions
99
+
100
+ > **Instructions**: Execute every numbered checklist item with the exact inputs shown. Compare responses against the expected results. Report any deviation.
101
+
102
+ > **Note:** All 8 transaction tools are **`[NATIVE ONLY]`** — they are not available in WASM mode. Transaction operations require the `write` OAuth scope.
103
+
104
+ ### Built-in Tools (3)
105
+
106
+ 1. server_info
107
+ 2. server_health
108
+ 3. list_adapters
109
+
110
+ ### transactions Group Tools (8) `[NATIVE ONLY]`
111
+
112
+ 4. sqlite_transaction_begin
113
+ 5. sqlite_transaction_status
114
+ 6. sqlite_transaction_commit
115
+ 7. sqlite_transaction_rollback
116
+ 8. sqlite_transaction_savepoint
117
+ 9. sqlite_transaction_release
118
+ 10. sqlite_transaction_rollback_to
119
+ 11. sqlite_transaction_execute
120
+ 12. sqlite_execute_code
121
+
122
+ **Checklist — Full Lifecycle:**
123
+
124
+ 1. `sqlite_transaction_status` → `{status: "none", active: false}` (no active transaction)
125
+ 2. `sqlite_transaction_begin` → capture transaction ID
126
+ 3. `sqlite_transaction_status` → `{status: "active", active: true}`
127
+ 4. `sqlite_transaction_rollback` → rollback entire transaction, verify success
128
+ 5. `sqlite_transaction_status` → `{status: "none", active: false}` (back to none)
129
+ 6. `sqlite_transaction_begin` → start a new transaction for savepoint tests
130
+ 7. `sqlite_transaction_savepoint({name: "sp1"})` → success
131
+ 8. `sqlite_transaction_rollback_to({name: "sp1"})` → success
132
+ 9. `sqlite_transaction_release({name: "sp1"})` → success (released savepoints cannot be rolled back to)
133
+ 10. `sqlite_transaction_commit` → success
134
+ 11. `sqlite_transaction_execute({statements: ["SELECT 1 AS test", "SELECT 2 AS test2"]})` → success with 2 statements executed
135
+
136
+ **Code mode testing:**
137
+
138
+ 12. `sqlite_execute_code({code: "const result = await sqlite.transactions.status(); return result;"})` → transaction status
139
+ 13. `sqlite_execute_code({code: "const result = await sqlite.transactions.execute({statements: ['SELECT 1 AS test']}); return result;"})` → success
140
+
141
+ **Error path testing:**
142
+
143
+ 🔴 14. `sqlite_transaction_execute({statements: ["INSERT INTO nonexistent_table VALUES (1)"]})` → structured error with rollback info
144
+ 🔴 15. `sqlite_transaction_execute({statements: []})` → report behavior for empty array
145
+
146
+ **Zod validation sweep** — call each tool with `{}` (empty params). Must return handler error, NOT raw MCP error:
147
+
148
+ 🔴 16. `sqlite_transaction_begin({})` → handler error (or success if no required params)
149
+ 🔴 17. `sqlite_transaction_status({})` → handler error (or success if no required params)
150
+ 🔴 18. `sqlite_transaction_commit({})` → handler error (or success if no required params)
151
+ 🔴 19. `sqlite_transaction_rollback({})` → handler error (or success if no required params)
152
+ 🔴 20. `sqlite_transaction_execute({})` → handler error
153
+ 🔴 21. `sqlite_transaction_savepoint({})` → handler error
154
+ 🔴 22. `sqlite_transaction_release({})` → handler error
155
+ 🔴 23. `sqlite_transaction_rollback_to({})` → handler error
156
+
157
+ ---
158
+
159
+ ## Post-Test Procedures
160
+
161
+ 1. **Triage findings**: Create implementation plan if issues found
162
+ 2. **Scope of fixes**: Handler code, server-instructions, test database, this prompt
163
+ 3. **Validate**: Instruct the user to run the test suite (Vitest/Playwright), lint, and typecheck. Do NOT run them yourself.
164
+ 4. **Commit**: Stage and commit — do NOT push
165
+ 5. **Live re-test**: After server rebuild
166
+ 6. **Final summary**: After testing/re-testing
167
+
168
+ ---
169
+
170
+ ## Troubleshooting
171
+
172
+ ### Database is locked / file in use
173
+
174
+ 1. Check for Node.js processes: `Get-CimInstance Win32_Process -Filter "Name = 'node.exe'"`
175
+ 2. WAL/journal files are normal
176
+
177
+ ### Reset script fails
178
+
179
+ 1. Run with `-Verbose`: `.\reset-database.ps1 -Verbose`
@@ -0,0 +1,130 @@
1
+ # db-mcp Tool Group Testing: [vector-read]
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): All 7 vector-read tools are fully WASM-compatible. No items to skip or adjust.
11
+
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.
13
+
14
+ **Step 2:** Please conduct an exhaustive test of the **vector-read** 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.
17
+
18
+ **Note** If temp tables are present from a previous test pass, it's because the database is locked. Ignore them.
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.
25
+
26
+ ## Test Database Schema
27
+
28
+ | Table | Rows | Columns | JSON Columns |
29
+ | ----------------- | ---- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
30
+ | test_products | 16 | id, name, description, price, category, created_at | — |
31
+ | test_orders | 20 | id, product_id (FK), customer_name, quantity, total_price, order_date, status | — |
32
+ | test_jsonb_docs | 6 | id, doc, metadata, tags, created_at | **doc**, **metadata** (nested), **tags** (array) |
33
+ | test_articles | 8 | id, title, body, author, category, published_at | — |
34
+ | test_users | 9 | id, username, email, phone, bio, created_at | — |
35
+ | test_measurements | 200 | id, sensor_id, temperature, humidity, pressure, measured_at | — |
36
+ | test_embeddings | 20 | id, content, category, embedding | **embedding** (8-dim float array); category values: database, fitness, food, tech, travel |
37
+ | test_locations | 15 | id, name, city, latitude, longitude, type | — |
38
+ | test_categories | 17 | id, name, path, level | — |
39
+ | test_events | 100 | id, event_type, user_id (INT, 8 values), payload, event_date | **payload** (JSON) |
40
+
41
+ ## Testing Requirements
42
+
43
+ > [!CAUTION]
44
+ > **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**.
45
+
46
+ 1. Use existing `test_*` tables for read operations
47
+ 2. **Error path testing**: For **every** tool, test (a) domain error and (b) Zod validation error (`{}`). Both must return `{success: false, error: "..."}`.
48
+ 3. **Output schema testing**: For tools with `outputSchema`, confirm valid calls return structured JSON.
49
+
50
+ ## Structured Error Response Pattern
51
+
52
+ ```json
53
+ { "success": false, "error": "Human-readable error message" }
54
+ ```
55
+
56
+ | Type | Source | What you see | Verdict |
57
+ | -------------------- | ------------------------------------------------------------------ | ----------------------------------------------------------- | ------------------ |
58
+ | **Handler error** ✅ | Handler catches error and returns `{success: false, error: "..."}` | Parseable JSON object with `success` and `error` fields | Correct |
59
+ | **MCP error** ❌ | Uncaught throw propagates to MCP framework | Raw text error string, `isError: true` — no `success` field | Bug — report as ❌ |
60
+
61
+ ### Zod Validation Errors
62
+
63
+ **Zod refinement leak pattern:** `.partial()` does NOT strip `.min(N)` / `.max(N)` refinements. **Fix:** Remove refinements from schema, validate inside handler.
64
+
65
+ ### Output Schema Validation Errors
66
+
67
+ If valid inputs return raw MCP `-32602` mentioning "output schema", report as ❌.
68
+
69
+ ---
70
+
71
+ ## Group Focus: vector-read
72
+
73
+ > **Instructions**: Execute every numbered checklist item with the exact inputs shown. Compare responses against the expected results. Report any deviation.
74
+
75
+ > **Note:** Vector tools use pure JS computations (cosine, euclidean, dot product) with JSON-stored vectors — no native SQLite extension required. All 11 tools work identically in both WASM and Native modes.
76
+
77
+ ### vector-read Group Tools (7)
78
+
79
+ 1. sqlite_vector_search
80
+ 2. sqlite_vector_get
81
+ 3. sqlite_vector_count
82
+ 4. sqlite_vector_stats
83
+ 5. sqlite_vector_dimensions
84
+ 6. sqlite_vector_distance
85
+ 7. sqlite_vector_normalize
86
+
87
+ **Test data:** `test_embeddings` (20 rows, 8-dim vectors, categories: tech, database, food, fitness, travel). Row 1: content="Machine learning fundamentals", embedding=[0.12, 0.45, -0.23, 0.78, 0.34, -0.56, 0.89, 0.01].
88
+
89
+ **Checklist:**
90
+
91
+ 1. `sqlite_vector_count({table: "test_embeddings"})` → `{count: 20}`
92
+ 2. `sqlite_vector_dimensions({table: "test_embeddings", vectorColumn: "embedding"})` → `{dimensions: 8}`
93
+ 3. `sqlite_vector_get({table: "test_embeddings", idColumn: "id", vectorColumn: "embedding", id: 1})` → verify content="Machine learning fundamentals", category="tech", embedding has 8 dimensions
94
+ 4. `sqlite_vector_search({table: "test_embeddings", vectorColumn: "embedding", queryVector: [0.12, 0.45, -0.23, 0.78, 0.34, -0.56, 0.89, 0.01], metric: "cosine", limit: 3})` → top result should be row 1 (exact match, \_similarity ≈ 1)
95
+ 5. `sqlite_vector_search({table: "test_embeddings", vectorColumn: "embedding", queryVector: [0.12, 0.45, -0.23, 0.78, 0.34, -0.56, 0.89, 0.01], metric: "cosine", limit: 3, whereClause: "category = 'database'"})` → only database category results
96
+ 6. `sqlite_vector_distance({vector1: [1, 0, 0], vector2: [0, 1, 0], metric: "cosine"})` → distance ≈ 1.0 (orthogonal vectors)
97
+ 7. `sqlite_vector_distance({vector1: [3, 4], vector2: [0, 0], metric: "euclidean"})` → distance = 5.0
98
+ 8. `sqlite_vector_normalize({vector: [3, 4]})` → `{normalized: [0.6, 0.8], originalMagnitude: 5}`
99
+ 9. `sqlite_vector_stats({table: "test_embeddings", vectorColumn: "embedding"})` → verify min/max/avg magnitude
100
+
101
+ **Code mode testing:**
102
+
103
+ 10. `sqlite_execute_code({code: "const result = await sqlite.vector.count({table: 'test_embeddings'}); return result;"})` → `{count: 20}`
104
+ 11. `sqlite_execute_code({code: "const result = await sqlite.vector.distance({vector1: [3, 4], vector2: [0, 0], metric: 'euclidean'}); return result;"})` → distance = 5.0
105
+
106
+ **Error path testing:**
107
+
108
+ 🔴 12. `sqlite_vector_search({table: "nonexistent_table_xyz", vectorColumn: "embedding", queryVector: [1,2,3], metric: "cosine"})` → structured error
109
+ 🔴 13. `sqlite_vector_distance({vector1: [1, 2, 3], vector2: [1, 2], metric: "cosine"})` → error about dimension mismatch
110
+
111
+ **Zod validation sweep** — call each tool with `{}` (empty params). Must return handler error, NOT raw MCP error:
112
+
113
+ 🔴 14. `sqlite_vector_search({})` → handler error
114
+ 🔴 15. `sqlite_vector_get({})` → handler error
115
+ 🔴 16. `sqlite_vector_count({})` → handler error
116
+ 🔴 17. `sqlite_vector_stats({})` → handler error
117
+ 🔴 18. `sqlite_vector_dimensions({})` → handler error
118
+ 🔴 19. `sqlite_vector_normalize({})` → handler error
119
+ 🔴 20. `sqlite_vector_distance({})` → handler error
120
+
121
+ ---
122
+
123
+ ## Post-Test Procedures
124
+
125
+ 1. **Triage findings**: Create implementation plan if issues found
126
+ 2. **Scope of fixes**: Handler code, server-instructions, test database, this prompt
127
+ 3. **Validate**: Instruct the user to run the test suite (Vitest/Playwright), lint, and typecheck. Do NOT run them yourself.
128
+ 4. **Commit**: Stage and commit — do NOT push
129
+ 5. **Live re-test**: After server rebuild
130
+ 6. **Final summary**: After testing/re-testing
@@ -0,0 +1,115 @@
1
+ # db-mcp Tool Group Testing: [vector-write]
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): All 4 vector-write tools are fully WASM-compatible. No items to skip or adjust.
11
+
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.
13
+
14
+ **Step 2:** Please conduct an exhaustive test of the **vector-write** 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.
17
+
18
+ **Note** If temp tables are present from a previous test pass, it's because the database is locked. Ignore them.
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.
25
+
26
+ ## Test Database Schema
27
+
28
+ | Table | Rows | Columns | JSON Columns |
29
+ | ----------------- | ---- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
30
+ | test_products | 16 | id, name, description, price, category, created_at | — |
31
+ | test_orders | 20 | id, product_id (FK), customer_name, quantity, total_price, order_date, status | — |
32
+ | test_jsonb_docs | 6 | id, doc, metadata, tags, created_at | **doc**, **metadata** (nested), **tags** (array) |
33
+ | test_articles | 8 | id, title, body, author, category, published_at | — |
34
+ | test_users | 9 | id, username, email, phone, bio, created_at | — |
35
+ | test_measurements | 200 | id, sensor_id, temperature, humidity, pressure, measured_at | — |
36
+ | test_embeddings | 20 | id, content, category, embedding | **embedding** (8-dim float array); category values: database, fitness, food, tech, travel |
37
+ | test_locations | 15 | id, name, city, latitude, longitude, type | — |
38
+ | test_categories | 17 | id, name, path, level | — |
39
+ | test_events | 100 | id, event_type, user_id (INT, 8 values), payload, event_date | **payload** (JSON) |
40
+
41
+ ## Testing Requirements
42
+
43
+ > [!CAUTION]
44
+ > **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**.
45
+
46
+ 1. Use existing `test_*` tables for read operations
47
+ 2. Create temporary tables with `temp_*` prefix for write operations
48
+ 3. **Error path testing**: For **every** tool, test (a) domain error and (b) Zod validation error (`{}`). Both must return `{success: false, error: "..."}`.
49
+ 4. **Output schema testing**: For tools with `outputSchema`, confirm valid calls return structured JSON.
50
+
51
+ ## Structured Error Response Pattern
52
+
53
+ ```json
54
+ { "success": false, "error": "Human-readable error message" }
55
+ ```
56
+
57
+ | Type | Source | What you see | Verdict |
58
+ | -------------------- | ------------------------------------------------------------------ | ----------------------------------------------------------- | ------------------ |
59
+ | **Handler error** ✅ | Handler catches error and returns `{success: false, error: "..."}` | Parseable JSON object with `success` and `error` fields | Correct |
60
+ | **MCP error** ❌ | Uncaught throw propagates to MCP framework | Raw text error string, `isError: true` — no `success` field | Bug — report as ❌ |
61
+
62
+ ### Zod Validation Errors
63
+
64
+ **Zod refinement leak pattern:** `.partial()` does NOT strip `.min(N)` / `.max(N)` refinements. **Fix:** Remove refinements from schema, validate inside handler.
65
+
66
+ ### Output Schema Validation Errors
67
+
68
+ If valid inputs return raw MCP `-32602` mentioning "output schema", report as ❌.
69
+
70
+ ---
71
+
72
+ ## Group Focus: vector-write
73
+
74
+ > **Instructions**: Execute every numbered checklist item with the exact inputs shown. Compare responses against the expected results. Report any deviation.
75
+
76
+ ### vector-write Group Tools (4)
77
+
78
+ 1. sqlite_vector_create_table
79
+ 2. sqlite_vector_store
80
+ 3. sqlite_vector_batch_store
81
+ 4. sqlite_vector_delete
82
+
83
+ **Checklist:**
84
+
85
+ **Write operations (use temp tables):**
86
+
87
+ 1. `sqlite_vector_create_table({tableName: "temp_vector_test", dimensions: 8, additionalColumns: [{name: "content", type: "TEXT"}, {name: "category", type: "TEXT"}]})` → success
88
+ 2. `sqlite_vector_store({table: "temp_vector_test", idColumn: "id", vectorColumn: "vector", id: 1, vector: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]})` → success
89
+ 3. `sqlite_vector_batch_store({table: "temp_vector_test", idColumn: "id", vectorColumn: "vector", items: [{id: 2, vector: [0.11, 0.22, 0.33, 0.44, 0.55, 0.66, 0.77, 0.88]}, {id: 3, vector: [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2]}]})` → `{stored: 2}`
90
+ 4. Verify rows stored: `sqlite_vector_count({table: "temp_vector_test"})` → `{count: 3}` (use the direct tool or code mode)
91
+ 5. `sqlite_vector_delete({table: "temp_vector_test", idColumn: "id", ids: [1]})` → success
92
+ 6. Verify deletion: `sqlite_vector_count({table: "temp_vector_test"})` → `{count: 2}`
93
+ 7. Cleanup: `sqlite_drop_table({table: "temp_vector_test"})` (using core tool)
94
+
95
+ **Error path testing:**
96
+
97
+ 🔴 8. `sqlite_vector_store({table: "nonexistent_table_xyz", idColumn: "id", vectorColumn: "vec", id: 1, vector: [1,2,3]})` → structured error
98
+
99
+ **Zod validation sweep** — call each tool with `{}` (empty params). Must return handler error, NOT raw MCP error:
100
+
101
+ 🔴 9. `sqlite_vector_create_table({})` → handler error
102
+ 🔴 10. `sqlite_vector_store({})` → handler error
103
+ 🔴 11. `sqlite_vector_batch_store({})` → handler error
104
+ 🔴 12. `sqlite_vector_delete({})` → handler error
105
+
106
+ ---
107
+
108
+ ## Post-Test Procedures
109
+
110
+ 1. **Triage findings**: Create implementation plan if issues found
111
+ 2. **Scope of fixes**: Handler code, server-instructions, test database, this prompt
112
+ 3. **Validate**: Instruct the user to run the test suite (Vitest/Playwright), lint, and typecheck. Do NOT run them yourself.
113
+ 4. **Commit**: Stage and commit — do NOT push
114
+ 5. **Live re-test**: After server rebuild
115
+ 6. **Final summary**: After testing/re-testing