mindwtr-mcp 0.9.10

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 (3) hide show
  1. package/README.md +484 -0
  2. package/dist/index.js +91163 -0
  3. package/package.json +54 -0
package/README.md ADDED
@@ -0,0 +1,484 @@
1
+ # Mindwtr MCP Server
2
+
3
+ Local MCP server for Mindwtr. Connect MCP clients (Claude Desktop, etc.) to your local Mindwtr SQLite database.
4
+
5
+ This is a **local stdio** server (no HTTP). MCP clients launch it as a subprocess and talk over JSON‑RPC on stdin/stdout.
6
+
7
+ ---
8
+
9
+ ## App Binaries vs. MCP Helper
10
+
11
+ The desktop and mobile app binaries include the Mindwtr app, but they do **not** currently include a desktop start/stop toggle or a standalone `mindwtr-mcp` command on your `PATH`.
12
+
13
+ You do **not** need to run the whole app from source to use MCP. You can use the normal desktop app binary for your tasks, then run this separate MCP helper from the repository with Bun, or build the helper once and run it with Node. Point the helper at the desktop app's local `mindwtr.db`.
14
+
15
+ On desktop, the app shows the exact local data path in **Settings -> Sync -> Local Data**. Mobile binaries do not expose a local MCP server surface.
16
+
17
+ ---
18
+
19
+ ## Requirements
20
+
21
+ - Node.js 18+ (for the MCP client that spawns the server)
22
+ - npm package installs use better-sqlite3, a native SQLite addon. If no prebuilt binary is available for your platform, npm needs a working C/C++ build toolchain and Python for node-gyp.
23
+ - Bun (recommended for development in this repo)
24
+ - A local Mindwtr database (`mindwtr.db`)
25
+
26
+ Default database locations:
27
+ - Linux: `~/.local/share/mindwtr/mindwtr.db`
28
+ - macOS: `~/Library/Application Support/mindwtr/mindwtr.db`
29
+ - Windows: `%APPDATA%\mindwtr\mindwtr.db`
30
+
31
+ Additional macOS path for sandboxed builds:
32
+ - `~/Library/Containers/tech.dongdongbh.mindwtr/Data/Library/Application Support/mindwtr/mindwtr.db`
33
+
34
+ If `mindwtr.db` is missing but `data.json` exists in the same desktop data folder, the MCP server will bootstrap a fresh SQLite database from that local data snapshot on first start.
35
+ Desktop Settings → Sync → Local Data shows the exact storage location used by the app.
36
+
37
+ You can override with:
38
+ - `--db /path/to/mindwtr.db`
39
+ - `MINDWTR_DB_PATH=/path/to/mindwtr.db`
40
+ - `MINDWTR_DB=/path/to/mindwtr.db`
41
+
42
+ ---
43
+
44
+ ## Start / Stop
45
+
46
+ ### Run from npm
47
+
48
+ After installing the published package, run it directly:
49
+
50
+ ```bash
51
+ mindwtr-mcp --db "/path/to/mindwtr.db"
52
+ ```
53
+
54
+ Or let an MCP client launch it through npx:
55
+
56
+ ```json
57
+ {
58
+ "mcpServers": {
59
+ "mindwtr": {
60
+ "command": "npx",
61
+ "args": [
62
+ "-y",
63
+ "mindwtr-mcp",
64
+ "--db",
65
+ "/home/dd/.local/share/mindwtr/mindwtr.db"
66
+ ]
67
+ }
68
+ }
69
+ }
70
+ ```
71
+
72
+ The npm package is read-only by default. Add `--write` only when you explicitly want add/update/complete/delete tools enabled.
73
+
74
+ ### Run directly from the repo
75
+
76
+ ```bash
77
+ # from repo root (read-only by default)
78
+ bun run mindwtr:mcp -- --db "/path/to/mindwtr.db"
79
+ ```
80
+
81
+ Enable writes (required for add/update/complete/delete tools):
82
+
83
+ ```bash
84
+ bun run mindwtr:mcp -- --db "/path/to/mindwtr.db" --write
85
+ ```
86
+
87
+ Stop:
88
+ - Press `Ctrl+C` in the terminal.
89
+
90
+ ### Keep-alive behavior (why it sometimes exits)
91
+
92
+ The MCP server is **stdio‑based**. It stays alive as long as stdin is open.
93
+ If your shell/client closes stdin, the process exits.
94
+
95
+ To force an immediate exit when stdin closes (no keep-alive), pass `--nowait`:
96
+
97
+ ```bash
98
+ bun run mindwtr:mcp -- --db "/path/to/mindwtr.db" --nowait
99
+ ```
100
+
101
+ Note: When an MCP client launches the server, it keeps stdin open, so the server should remain connected.
102
+
103
+ ### Run without the helper script
104
+
105
+ ```bash
106
+ bun run --filter mindwtr-mcp dev -- --db "/path/to/mindwtr.db"
107
+ ```
108
+
109
+ Stop:
110
+ - Press `Ctrl+C` in the terminal.
111
+
112
+ ### Build and run the binary entry (Node)
113
+
114
+ ```bash
115
+ # from repo root
116
+ bun run --filter mindwtr-mcp build
117
+ node apps/mcp-server/dist/index.js --db "/path/to/mindwtr.db"
118
+ ```
119
+
120
+ Stop:
121
+ - Press `Ctrl+C` in the terminal.
122
+
123
+ ---
124
+
125
+ ## Why `mindwtr-mcp` is “command not found”
126
+
127
+ `mindwtr-mcp` is the package binary. It exists after installing the npm package globally, after an MCP client launches it through `npx`, or after you build the source package and run it with Node.
128
+
129
+ Use one of these source-tree options instead:
130
+
131
+ ```bash
132
+ # ✅ works immediately
133
+ bun run mindwtr:mcp -- --db "/path/to/mindwtr.db"
134
+
135
+ # ✅ build then run
136
+ bun run --filter mindwtr-mcp build
137
+ node apps/mcp-server/dist/index.js --db "/path/to/mindwtr.db"
138
+ ```
139
+
140
+ ### Optional: create a global `mindwtr-mcp` command
141
+
142
+ If you want a real `mindwtr-mcp` command on your PATH, create a tiny wrapper:
143
+
144
+ ```bash
145
+ cat > ~/bin/mindwtr-mcp <<'EOF'
146
+ #!/usr/bin/env bash
147
+ set -euo pipefail
148
+ cd /absolute/path/to/Mindwtr
149
+ exec bun run mindwtr:mcp -- "$@"
150
+ EOF
151
+ chmod +x ~/bin/mindwtr-mcp
152
+ ```
153
+
154
+ Then use:
155
+
156
+ ```bash
157
+ mindwtr-mcp --db "/path/to/mindwtr.db"
158
+ ```
159
+
160
+ ### Desktop app toggle?
161
+
162
+ Not yet. Start/stop is still manual.
163
+
164
+ ---
165
+
166
+ ## MCP Client Configuration
167
+
168
+ MCP clients run the server as a subprocess. You point them to **the command** and pass args/env.
169
+
170
+ **Important:** Do NOT use `bun run mindwtr:mcp` for MCP clients. The `bun run` wrapper outputs shell messages to stdout (e.g., `$ bun run --filter...`) which breaks the JSON-RPC protocol. Always run bun directly on the source file.
171
+
172
+ ### Example (generic MCP config)
173
+
174
+ ```json
175
+ {
176
+ "mcpServers": {
177
+ "mindwtr": {
178
+ "command": "bun",
179
+ "args": [
180
+ "/absolute/path/to/Mindwtr/apps/mcp-server/src/index.ts",
181
+ "--db",
182
+ "/home/dd/.local/share/mindwtr/mindwtr.db"
183
+ ]
184
+ }
185
+ }
186
+ }
187
+ ```
188
+
189
+ Add `--write` to the args if you want to enable **add/update/complete/delete** tools.
190
+
191
+ If your client doesn't support Bun, build first and use Node:
192
+
193
+ ```bash
194
+ # Build once
195
+ cd /path/to/Mindwtr && bun run --filter mindwtr-mcp build
196
+ ```
197
+
198
+ ```json
199
+ {
200
+ "mcpServers": {
201
+ "mindwtr": {
202
+ "command": "node",
203
+ "args": [
204
+ "/absolute/path/to/Mindwtr/apps/mcp-server/dist/index.js",
205
+ "--db",
206
+ "/home/dd/.local/share/mindwtr/mindwtr.db"
207
+ ]
208
+ }
209
+ }
210
+ }
211
+ ```
212
+
213
+ Add `--write` to the args if you want to enable **add/update/complete/delete** tools.
214
+
215
+ ### Claude Desktop
216
+
217
+ Claude Desktop supports MCP (stdio). Add a server entry in its MCP configuration.
218
+
219
+ Typical config file locations:
220
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
221
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
222
+
223
+ After editing, fully quit and relaunch Claude Desktop.
224
+
225
+ ### Claude Code (CLI)
226
+
227
+ Add a server via the CLI:
228
+
229
+ ```bash
230
+ claude mcp add mindwtr -- \
231
+ bun /path/to/Mindwtr/apps/mcp-server/src/index.ts --db "/path/to/mindwtr.db" --write
232
+ ```
233
+
234
+ Or edit `~/.claude.json` directly:
235
+
236
+ ```json
237
+ {
238
+ "projects": {
239
+ "/path/to/your/project": {
240
+ "mcpServers": {
241
+ "mindwtr": {
242
+ "type": "stdio",
243
+ "command": "bun",
244
+ "args": [
245
+ "/absolute/path/to/Mindwtr/apps/mcp-server/src/index.ts",
246
+ "--db",
247
+ "/home/dd/.local/share/mindwtr/mindwtr.db",
248
+ "--write"
249
+ ]
250
+ }
251
+ }
252
+ }
253
+ }
254
+ }
255
+ ```
256
+
257
+ Then restart the Claude Code session and run `/mcp` to verify it's connected.
258
+
259
+ ### OpenAI Codex (config.toml)
260
+
261
+ Codex stores MCP config in `~/.codex/config.toml`. Add:
262
+
263
+ ```toml
264
+ [mcp_servers.mindwtr]
265
+ command = "bun"
266
+ args = ["/absolute/path/to/Mindwtr/apps/mcp-server/src/index.ts", "--db", "/path/to/mindwtr.db", "--write"]
267
+
268
+ # Optional: pass env vars to the server
269
+ [mcp_servers.mindwtr.env]
270
+ MINDWTR_DB_PATH = "/path/to/mindwtr.db"
271
+ ```
272
+
273
+ Restart Codex after saving.
274
+
275
+ ### Gemini CLI
276
+
277
+ Gemini CLI uses a JSON `settings.json` with `mcpServers`, either:
278
+ - User scope: `~/.gemini/settings.json`
279
+ - Project scope: `.gemini/settings.json` in your repo
280
+
281
+ You can add Mindwtr MCP two ways:
282
+
283
+ **1) CLI (recommended):**
284
+
285
+ ```bash
286
+ gemini mcp add mindwtr \
287
+ bun /absolute/path/to/Mindwtr/apps/mcp-server/src/index.ts \
288
+ --db "/path/to/mindwtr.db" --write
289
+ ```
290
+
291
+ **2) Edit settings.json manually:**
292
+
293
+ ```json
294
+ {
295
+ "mcpServers": {
296
+ "mindwtr": {
297
+ "command": "bun",
298
+ "args": ["/absolute/path/to/Mindwtr/apps/mcp-server/src/index.ts", "--db", "/path/to/mindwtr.db", "--write"]
299
+ }
300
+ }
301
+ }
302
+ ```
303
+
304
+ Restart the Gemini CLI session after saving.
305
+
306
+ ### Other MCP clients
307
+
308
+ Any MCP-compatible client can work as long as it can launch a **stdio** server with the command + args above.
309
+
310
+ ---
311
+
312
+ ## Migration: tool rename (`mindwtr.*` → `mindwtr_*`)
313
+
314
+ > **Breaking change** (introduced in this release): all tool names have changed from dot-notation (`mindwtr.list_tasks`) to underscore-notation (`mindwtr_list_tasks`) to comply with MCP client validation rules (e.g. Claude Desktop).
315
+
316
+ **Old → new mapping:**
317
+
318
+ | Old name | New name |
319
+ | ------------------------- | -------------------------- |
320
+ | `mindwtr.list_tasks` | `mindwtr_list_tasks` |
321
+ | `mindwtr.list_projects` | `mindwtr_list_projects` |
322
+ | `mindwtr.get_project` | `mindwtr_get_project` |
323
+ | `mindwtr.get_task` | `mindwtr_get_task` |
324
+ | `mindwtr.list_areas` | `mindwtr_list_areas` |
325
+ | `mindwtr.add_task` | `mindwtr_add_task` |
326
+ | `mindwtr.update_task` | `mindwtr_update_task` |
327
+ | `mindwtr.complete_task` | `mindwtr_complete_task` |
328
+ | `mindwtr.delete_task` | `mindwtr_delete_task` |
329
+ | `mindwtr.restore_task` | `mindwtr_restore_task` |
330
+ | `mindwtr.add_project` | `mindwtr_add_project` |
331
+ | `mindwtr.update_project` | `mindwtr_update_project` |
332
+ | `mindwtr.delete_project` | `mindwtr_delete_project` |
333
+ | `mindwtr.add_area` | `mindwtr_add_area` |
334
+ | `mindwtr.update_area` | `mindwtr_update_area` |
335
+ | `mindwtr.delete_area` | `mindwtr_delete_area` |
336
+
337
+ **Upgrade action:** find and replace `mindwtr.` with `mindwtr_` in any MCP client configs, system prompts, scripts, or automations that reference these tool names. No other changes are required.
338
+
339
+ ---
340
+
341
+ ## Tools
342
+
343
+ - `mindwtr_list_tasks`
344
+ - Input: `{ status?, projectId?, includeDeleted?, limit?, offset?, search?, dueDateFrom?, dueDateTo?, sortBy?, sortOrder? }`
345
+ - `mindwtr_list_projects`
346
+ - Input: `{}`
347
+ - `mindwtr_get_project`
348
+ - Input: `{ id, includeDeleted? }`
349
+ - `mindwtr_list_sections`
350
+ - Input: `{ projectId?, includeDeleted? }`
351
+ - `mindwtr_get_section`
352
+ - Input: `{ id, includeDeleted? }`
353
+ - `mindwtr_list_areas`
354
+ - Input: `{}`
355
+ - `mindwtr_list_people`
356
+ - Input: `{ includeDeleted? }`
357
+ - `mindwtr_get_person`
358
+ - Input: `{ id, includeDeleted? }`
359
+ - `mindwtr_get_task`
360
+ - Input: `{ id, includeDeleted? }`
361
+ - `mindwtr_add_task` **(requires `--write`)**
362
+ - Input: `{ title? | quickAdd?, status?, projectId?, sectionId?, dueDate?, startTime?, contexts?, tags?, description?, priority?, timeEstimate? }`
363
+ - `mindwtr_update_task` **(requires `--write`)**
364
+ - Input: `{ id, title?, status?, projectId?, sectionId?, dueDate?, startTime?, contexts?, tags?, description?, priority?, timeEstimate?, reviewAt?, isFocusedToday? }`
365
+ - `mindwtr_complete_task` **(requires `--write`)**
366
+ - Input: `{ id }`
367
+ - `mindwtr_delete_task` **(requires `--write`)**
368
+ - Input: `{ id }`
369
+ - `mindwtr_restore_task` **(requires `--write`)**
370
+ - Input: `{ id }`
371
+ - `mindwtr_add_project` **(requires `--write`)**
372
+ - Input: `{ title, color?, status?, areaId?, isSequential?, isFocused?, dueDate?, reviewAt?, supportNotes? }`
373
+ - `mindwtr_update_project` **(requires `--write`)**
374
+ - Input: `{ id, title?, color?, status?, areaId?, isSequential?, isFocused?, dueDate?, reviewAt?, supportNotes? }`
375
+ - `mindwtr_delete_project` **(requires `--write`)**
376
+ - Input: `{ id }`
377
+ - `mindwtr_add_section` **(requires `--write`)**
378
+ - Input: `{ projectId, title, description?, order?, isCollapsed? }`
379
+ - `mindwtr_update_section` **(requires `--write`)**
380
+ - Input: `{ id, title?, description?, order?, isCollapsed? }`
381
+ - `mindwtr_delete_section` **(requires `--write`)**
382
+ - Input: `{ id }`
383
+ - `mindwtr_add_area` **(requires `--write`)**
384
+ - Input: `{ name, color?, icon? }`
385
+ - `mindwtr_update_area` **(requires `--write`)**
386
+ - Input: `{ id, name?, color?, icon? }`
387
+ - `mindwtr_delete_area` **(requires `--write`)**
388
+ - Input: `{ id }`
389
+ - `mindwtr_add_person` **(requires `--write`)**
390
+ - Input: `{ name, note?, referenceLink? }`
391
+ - `mindwtr_update_person` **(requires `--write`)**
392
+ - Input: `{ id, name?, note?, referenceLink? }`
393
+ - `mindwtr_rename_person` **(requires `--write`)**
394
+ - Input: `{ id, name, updateTasks? }`
395
+ - `mindwtr_delete_person` **(requires `--write`)**
396
+ - Input: `{ id }`
397
+
398
+ All tools return JSON text payloads with the resulting task, project, section, area, person, or collection payload.
399
+
400
+ ---
401
+
402
+ ## Testing
403
+
404
+ ### Quick smoke test (CLI)
405
+
406
+ 1) Start the server (read‑only):
407
+ ```bash
408
+ bun run mindwtr:mcp -- --db "/home/dd/.local/share/mindwtr/mindwtr.db"
409
+ ```
410
+
411
+ 2) Connect via your MCP client and run:
412
+ - `mindwtr_list_tasks` (limit 5)
413
+
414
+ If you want to test writes, restart with `--write`:
415
+ ```bash
416
+ bun run mindwtr:mcp -- --db "/home/dd/.local/share/mindwtr/mindwtr.db" --write
417
+ ```
418
+
419
+ Then test:
420
+ - `mindwtr_add_task` (quickAdd: "Test task @home /due:tomorrow")
421
+ - `mindwtr_complete_task` (use returned task id)
422
+ - `mindwtr_update_task` (e.g. set status or dueDate)
423
+ - `mindwtr_delete_task` (use returned task id)
424
+ - `mindwtr_get_task` (use returned task id)
425
+ - `mindwtr_restore_task` (after delete, restore the task)
426
+ - `mindwtr_list_projects`
427
+ - `mindwtr_get_project` (use returned project id)
428
+ - `mindwtr_list_areas`
429
+ - `mindwtr_list_people`
430
+ - `mindwtr_add_project`
431
+ - `mindwtr_update_project`
432
+ - `mindwtr_delete_project`
433
+ - `mindwtr_add_area`
434
+ - `mindwtr_update_area`
435
+ - `mindwtr_delete_area`
436
+ - `mindwtr_add_person`
437
+ - `mindwtr_update_person`
438
+ - `mindwtr_rename_person`
439
+ - `mindwtr_get_person` (use returned person id)
440
+ - `mindwtr_delete_person`
441
+ - `mindwtr_list_tasks` with `dueDateFrom`, `dueDateTo`, `sortBy`, `sortOrder`
442
+
443
+ If the list returns tasks and add/complete works, the server is healthy.
444
+
445
+ ### Stdio JSON-RPC E2E (transport validation)
446
+
447
+ Use any MCP client or a small script to send:
448
+ - `initialize`
449
+ - `notifications/initialized`
450
+ - `tools/list`
451
+ - `tools/call` (e.g. `mindwtr_list_projects` or `mindwtr_list_tasks`)
452
+
453
+ If these succeed, the stdio transport is working end-to-end.
454
+
455
+ ### Claude Code sanity check
456
+
457
+ 1) Add the server:
458
+ ```bash
459
+ claude mcp add mindwtr -- \
460
+ bun /path/to/Mindwtr/apps/mcp-server/src/index.ts --db "/path/to/mindwtr.db" --write
461
+ ```
462
+ 2) Restart Claude Code, run `/mcp`, and verify **mindwtr** is connected.
463
+ 3) Ask the model to call:
464
+ - `mindwtr_list_tasks` (limit 5)
465
+ - `mindwtr_add_task` (quickAdd: "Test MCP @home /due:tomorrow")
466
+ - `mindwtr_complete_task` (use returned id)
467
+
468
+ ---
469
+
470
+ ## Safety & Concurrency
471
+
472
+ - The server uses **SQLite WAL mode**. Read-only tools can run while the desktop app is open.
473
+ - Write tools fail fast on SQLite writer locks, then retry the whole Mindwtr write operation. Each retry reloads current data before applying the requested change, so a delayed MCP write does not keep working from a stale pre-lock snapshot.
474
+ - Writes are **disabled by default**. Use `--write` to enable edits.
475
+ - Write operations go through the shared **@mindwtr/core** store to enforce business rules (both Bun and Node).
476
+ - SQL is reserved for read-heavy paths (list/search) where performance matters.
477
+ - Do not point a separate container/server deployment at the same local storage or sync data while the desktop app is also writing. That creates independent writers outside the local SQLite coordination path and is unsupported.
478
+
479
+ ---
480
+
481
+ ## Notes
482
+
483
+ - This MCP server targets the SQLite database used by the desktop app, with mutations routed through `@mindwtr/core`.
484
+ - Keep an eye on schema changes across app versions (update queries if needed).