@yugabytedb/meko-mcp 1.2.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +59 -25
  2. package/assets/hooks-handlers/before-submit-prompt.sh +2 -2
  3. package/assets/hooks-handlers/codex-session-end.sh +78 -0
  4. package/assets/hooks-handlers/lib/capture.js +366 -152
  5. package/assets/hooks-handlers/lib/checkpoint-timer.js +67 -13
  6. package/assets/hooks-handlers/session-end.sh +10 -0
  7. package/assets/hooks-handlers/session-start.sh +14 -3
  8. package/assets/hooks-handlers/test_checkpoint_timer.sh +162 -0
  9. package/assets/scripts/meko-statusline.sh +119 -0
  10. package/assets/scripts/package-desktop-skill.sh +64 -30
  11. package/assets/skills/meko-mcp-tools/SKILL.md +84 -86
  12. package/assets/skills/meko-mcp-tools/references/_sections.md +2 -4
  13. package/assets/skills/meko-mcp-tools/references/tools-agent-id-conventions.md +29 -25
  14. package/assets/skills/meko-mcp-tools/references/tools-conversation-dedup.md +5 -7
  15. package/assets/skills/meko-mcp-tools/references/tools-conversation-reasoning.md +50 -0
  16. package/assets/skills/meko-mcp-tools/references/tools-cookbook.md +126 -184
  17. package/assets/skills/meko-mcp-tools/references/tools-datapack-workflow.md +31 -37
  18. package/assets/skills/meko-mcp-tools/references/tools-known-limitations.md +10 -26
  19. package/assets/skills/meko-mcp-tools/references/tools-memory-vs-conversation.md +26 -30
  20. package/assets/skills/meko-mcp-tools/references/tools-overview.md +60 -66
  21. package/assets/skills/meko-mcp-tools/references/tools-rag-workflow.md +28 -93
  22. package/assets/skills/meko-mcp-tools/references/tools-troubleshooting.md +5 -99
  23. package/assets/skills/meko-mcp-tools/references/tools-user-id-conventions.md +9 -8
  24. package/assets/skills/meko-mcp-tools-desktop/SKILL.md +138 -138
  25. package/assets/skills/meko-mcp-tools-desktop/desktop/README.md +46 -16
  26. package/assets/skills/meko-mcp-tools-desktop/references/_sections.md +2 -2
  27. package/assets/skills/meko-mcp-tools-desktop/references/tools-agent-id-conventions.md +28 -24
  28. package/assets/skills/meko-mcp-tools-desktop/references/tools-conversation-reasoning.md +50 -0
  29. package/assets/skills/meko-mcp-tools-desktop/references/tools-cookbook.md +120 -174
  30. package/assets/skills/meko-mcp-tools-desktop/references/tools-known-limitations.md +16 -22
  31. package/assets/skills/meko-mcp-tools-desktop/references/tools-memory-vs-conversation.md +28 -34
  32. package/assets/skills/meko-mcp-tools-desktop/references/tools-overview.md +60 -66
  33. package/assets/skills/meko-mcp-tools-desktop/references/tools-rag-workflow.md +28 -93
  34. package/assets/skills/meko-mcp-tools-desktop/references/tools-troubleshooting.md +4 -98
  35. package/assets/skills/meko-select-datapack-desktop/SKILL.md +208 -0
  36. package/assets/skills/meko-select-datapack-desktop/references/cookbook.md +121 -0
  37. package/assets/skills/meko-select-datapack-desktop/references/role-display-future.md +41 -0
  38. package/assets/skills/meko-select-datapack-desktop/references/troubleshooting.md +66 -0
  39. package/bin/create-meko-setup.mjs +74 -6
  40. package/lib/clients/claude-code.mjs +137 -6
  41. package/lib/clients/claude-desktop.mjs +51 -12
  42. package/lib/clients/codex.mjs +329 -13
  43. package/lib/clients/common.mjs +43 -1
  44. package/lib/clients/cursor.mjs +82 -21
  45. package/lib/config.mjs +26 -0
  46. package/lib/detect.mjs +7 -2
  47. package/lib/installer.mjs +24 -0
  48. package/lib/mcp-transport.mjs +5 -0
  49. package/lib/prompt.mjs +1 -1
  50. package/lib/url-selection.mjs +55 -0
  51. package/lib/validate.mjs +0 -1
  52. package/package.json +1 -1
  53. package/scripts/bundle-assets.mjs +8 -0
  54. package/assets/skills/meko-mcp-tools/references/tools-db-query-patterns.md +0 -38
  55. package/assets/skills/meko-mcp-tools/references/tools-scope-permissions.md +0 -75
  56. package/assets/skills/meko-mcp-tools/references/tools-write-guardrails.md +0 -30
  57. package/assets/skills/meko-mcp-tools-desktop/references/tools-scope-permissions.md +0 -75
@@ -7,13 +7,13 @@ These patterns are extracted from real agent sessions. Follow them to avoid wast
7
7
  1. **Never retry the identical failed call more than once.** If it fails twice with the same error, it's not transient — diagnose the cause.
8
8
  2. **Distinguish transient vs persistent failures.** "Connection already closed" is transient (retry once). "Permission denied" is persistent (stop, don't retry).
9
9
  3. **Don't guess parameters sequentially.** If a tool fails with one parameter format, don't try 4 variations. Check this skill's docs for the correct format first.
10
- 4. **Use your session's `agent_id` consistently.** Pass the value the SessionStart hook injected (e.g. `claude_code:<repo-basename>` for Claude Code; `claude_desktop` for Claude Desktop) on every write and every personal read. Use `agent_id="meko_agent"` deliberately on `memory_search`/`memory_get_all` only when you want the cross-project common bucket — empty string also resolves to `meko_agent`, not a cross-agent fan-out. Don't switch between forms mid-session.
10
+ 4. **Use your session's `agent_id` consistently on writes.** Pass the value the SessionStart hook injected (e.g. `claude_code:<repo-basename>` for Claude Code; `claude_desktop` for Claude Desktop) on every write so rows are attributed correctly, and on `conversation_get` (which *does* enforce it — conversations are owned by the `agent_id` that created them; a wrong value returns `agent_id_mismatch`). Memory reads (`memory_search`/`memory_get_all`) and `conversation_list` are not affected — they return all your agents' rows for this user regardless of the `agent_id` passed. Don't switch write forms mid-session.
11
11
 
12
12
  ---
13
13
 
14
14
  ## Connection errors: "connection already closed"
15
15
 
16
- **Affects:** Memory tools (`memory_add`, `memory_search`, `memory_get_all`) most frequently. DB tools less often.
16
+ **Affects:** Memory tools (`memory_add`, `memory_search`, `memory_get_all`) most frequently.
17
17
 
18
18
  **Why it happens:** The Python memory subsystem uses a connection cache that doesn't recover from dropped connections (unlike the Go API server which has retry logic with 5 retries and 3-second delays).
19
19
 
@@ -21,87 +21,11 @@ These patterns are extracted from real agent sessions. Follow them to avoid wast
21
21
 
22
22
  1. Retry the same call **once**.
23
23
  2. If it fails again, the memory subsystem is unhealthy for this session — stop trying memory calls and tell the user. Do not waste tokens re-sending the same payload.
24
- 3. Direct-SQL fallback **does not apply** on cloud Free Tier (`db_run_read_only_query` returns `{"error": "not_available", "detail": "Free Tier: DB Tools access is not enabled. coming soon."}`). On self-hosted / paid deployments where DB tools are available, inspect memory rows via the multi-tenant schema — tables are namespaced by datapack, not by agent_id. The old `{agent_id}_mem0_collection` per-agent-table layout is gone.
25
24
 
26
25
  **Anti-pattern from real sessions:** Agent called `memory_add` with 500+ tokens of text, got "connection already closed", retried the identical call 3 more times (each 500+ tokens). Wasted ~2000 tokens on guaranteed failures.
27
26
 
28
27
  ---
29
28
 
30
- ## RAG pipeline stuck at INIT
31
-
32
- **Affects:** `knowledgebase_trigger_index_creation` — the build triggers but never completes.
33
-
34
- **Symptoms:**
35
- - `knowledgebase_check_index_status` returns empty `pipeline_details` and `pipeline_stats`
36
- - Documents remain at `INIT` status indefinitely
37
- - Work queue tasks are `IN_PROGRESS` with `lease_expires_at` in the past
38
-
39
- **Diagnosis:** Query the work queue directly:
40
- ```
41
- db_run_read_only_query(scope="read",
42
- query="SELECT task_type, status, lease_expires_at FROM dist_rag.work_queue WHERE index_name = 'your_index' ORDER BY created_at DESC LIMIT 10")
43
- ```
44
-
45
- Look for tasks stuck `IN_PROGRESS` with expired leases — these indicate crashed or hung workers.
46
-
47
- **What to do:**
48
-
49
- 1. Poll status **at most 3 times** with 1-2 minute intervals
50
- 2. If no progress after 3 checks, **stop polling** — the pipeline is stuck
51
- 3. There is **no way to reset or retry stuck tasks via MCP tools**
52
- 4. Creating a new index with a different name (e.g., `_v2`) is a workaround, but if the workers themselves are down, this will also get stuck
53
- 5. Recommend the user check worker logs or restart the pipeline service
54
-
55
- **Anti-pattern from real sessions:** Agent created indexes `v1`, `v2`, `v3` — all stuck with the same symptoms. Even making the S3 bucket public didn't help. The issue was worker infrastructure, not permissions.
56
-
57
- ---
58
-
59
- ## db_run_write_query guardrail error
60
-
61
- **Error:** `'dict' object has no attribute 'guardrail_config'`
62
-
63
- **Affects:** `db_run_write_query` in some deployments.
64
-
65
- **What to do:**
66
-
67
- 1. Try the call once. If it fails with this specific error, write operations are unavailable in this deployment.
68
- 2. For reads, always use `db_run_read_only_query` (never `db_run_write_query` for SELECT).
69
- 3. Report the issue — it's a server-side bug, not a parameter problem.
70
-
71
- ---
72
-
73
- ## knowledgebase_add_source_to_index failure
74
-
75
- **Error shape:** `{"error": "not_available", "detail": "Vector index creation is not available on the free tier."}`
76
-
77
- You're on cloud Free Tier; the ingestion tools are gated off. There is no retry that will succeed. Point the user at the Meko UI's **Add Knowledge** file-upload flow (Datapack → Actions → Add Knowledge) instead.
78
-
79
- **Error shape:** `{"error": "index_not_found", "detail": "No vector index found with name '...'"}`
80
-
81
- The `index_name` doesn't exist in this datapack's `dist_rag.vector_indexes` table. Either you're targeting the wrong datapack (check `datapack_id`), or the index hasn't been created yet — call `knowledgebase_trigger_index_creation` first.
82
-
83
- **Error shape:** tool returns `"build_triggered"` but `knowledgebase_check_index_status` shows documents stuck at `INIT` for >5 minutes.
84
-
85
- Most common cause on self-hosted deployments: the worker can't reach the S3 bucket. `S3BucketCrawler()` uses boto3's default credential chain — check `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / IAM role / `~/.aws/credentials` on the worker host, not on the MCP server. Second cause: the URI isn't `s3://`-prefixed (`aws_source_processor.py` rejects other schemes with `ValueError("Invalid source URI")` async).
86
-
87
- **Historical note:** the old `r_index_name` vs `r_index_id` parameter-mismatch bug is fixed on main — the MCP tool now resolves `index_name → index_id` internally via a `SELECT id FROM dist_rag.vector_indexes WHERE index_name = %s` step. Older docs referencing this bug are stale.
88
-
89
- ---
90
-
91
- ## Scope parameter errors
92
-
93
- **Error:** `Insufficient scope: 'all'. This tool requires 'read' or higher.`
94
-
95
- The only valid scope values are: `"read"`, `"write"`, `"admin"`.
96
-
97
- - Use `"read"` for all read operations (default choice)
98
- - Use `"write"` for inserts, updates, creates, memory writes
99
- - Use `"admin"` only for destructive deletes
100
-
101
- **Never use:** `"all"`, `"readwrite"`, `"rw"`, or any other value.
102
-
103
- ---
104
-
105
29
  ## agent_id errors
106
30
 
107
31
  On the Cloud multi-tenant schema, `agent_id` is a TEXT column value — not a PostgreSQL identifier — so arbitrary strings are accepted.
@@ -114,9 +38,9 @@ If you call `memory_add` with empty / None / whitespace `agent_id`, the server d
114
38
 
115
39
  Fix: always pass a concrete non-empty `agent_id`. Fetch the value the SessionStart hook injected into `additionalContext` and pass it verbatim. Use `agent_id="meko_agent"` only when you genuinely want a fact in the cross-project pool (user identity, global preferences).
116
40
 
117
- ### "My reads return fewer results than I expected"
41
+ ### "My memory reads return fewer results than I expected"
118
42
 
119
- `memory_search` and `memory_get_all` filter strictly on your passed `agent_id`. A memory written by `claude-code:<slug-A>` is invisible to a search with `agent_id="cursor:<slug-B>"`. If you need a broader view, call repeatedly across the agent_ids you want to cover, or point the user at the UI's Memory Summary page (which shows every row regardless of agent_id).
43
+ `memory_search` and `memory_get_all` do **not** filter by `agent_id` — a single call returns all of your memories for this user across every agent, so a mismatched `agent_id` is not the cause. If results seem thin, check that you're on the right datapack (`datapack_id`), that the write actually landed (mem0 extraction is lossy — see `tools-memory-vs-conversation.md`), and that the query is semantically close to the stored text. `conversation_get`, by contrast, *is* agent-owned: pass the exact `agent_id` the conversation was created under, or you'll get `agent_id_mismatch`. `conversation_list` is not agent-filtered — it returns the datapack's conversations for your user regardless of the `agent_id` passed.
120
44
 
121
45
  ### "I'm seeing rows tagged with legacy agent_id values"
122
46
 
@@ -124,32 +48,14 @@ Pre-existing data may be tagged `"agent"`, `"claude_code"`, `"cursor:<slug>"`, o
124
48
 
125
49
  ---
126
50
 
127
- ## Permission denied on data tables
128
-
129
- **Error:** `permission denied for table customer_complaints`
130
-
131
- **Why:** The MCP database user may not have read access to all tables, particularly data tables created by the provisioning system within a datapack.
132
-
133
- **What to do:**
134
-
135
- 1. This is a server-side configuration issue — not fixable via MCP tools.
136
- 2. Don't retry. Don't try different query formulations.
137
- 3. Use `db_summarize_database` to see which tables you CAN access.
138
- 4. Report the permission gap to the Meko admin.
139
-
140
- ---
141
-
142
51
  ## Safe-to-retry vs not
143
52
 
144
53
  | Tool | Safe to retry? | Why |
145
54
  |------|---------------|-----|
146
- | All `read` scope tools | Yes | Reads are idempotent |
55
+ | All read-only tools | Yes | Reads are idempotent |
147
56
  | `memory_add` | Yes (once) | Mem0 has dedup logic |
148
57
  | `memory_update` | Yes (once) | Overwrites same ID |
149
58
  | `memory_delete_by_id` | Yes | Deleting already-deleted is a no-op |
150
- | `db_run_write_query` (INSERT) | **No** | May double-insert rows |
151
- | `db_run_write_query` (CREATE TABLE) | **No** | "Table already exists" error |
152
- | `knowledgebase_trigger_index_creation` | **No** | Creates duplicate indexes |
153
59
  | `conversation_create` | **No** | Creates duplicate conversations |
154
60
  | `conversation_add_message` with `seed` | Yes | Seed-based dedup prevents duplicates |
155
61
  | `conversation_add_message` without `seed` | **No** | Creates duplicate messages |
@@ -1,6 +1,6 @@
1
1
  # user_id — identity scoping on Cloud Meko
2
2
 
3
- On Cloud Meko, every write and every personal read carries a `user_id` that identifies **who** (the cognito account) is calling. The filter tuple for personal memories and conversations is `(datapack_id, user_id, agent_id)` — you only ever see memories your own user_id wrote (or content other team members have explicitly promoted to Shared Knowledge, which is separate — see `tools-agent-id-conventions.md`).
3
+ On Cloud Meko, every write and every personal read carries a `user_id` that identifies **who** (the cognito account) is calling. The read filter for personal **memories** is `(datapack_id, user_id)` — you see all your own memories for this user regardless of which agent wrote them (`agent_id` labels the writer but does not filter memory reads). Personal **conversation fetches** (`conversation_get`) additionally enforce `agent_id` — conversations are owned by the agent that created them; `conversation_list` does not filter by it. Either way you only ever see content your own user_id wrote (or content other team members have explicitly promoted to Shared Knowledge, which is separate — see `tools-agent-id-conventions.md`).
4
4
 
5
5
  ## The default behavior: automatic user_id from cognito
6
6
 
@@ -9,7 +9,7 @@ On Cloud, the server resolves your `user_id` automatically from the cognito acco
9
9
  This is the common case for Claude Code / Claude Desktop / Cursor:
10
10
 
11
11
  ```
12
- memory_add(scope="write",
12
+ memory_add(
13
13
  text="User prefers concise responses, no emojis.",
14
14
  agent_id="claude_code:meko-mcp-server",
15
15
  conversation_id="<session conversation_id>")
@@ -24,21 +24,21 @@ Explicit `user_id` is an **optional sub-scope** for agents that serve multiple e
24
24
 
25
25
  ```
26
26
  # Serving Alice
27
- memory_add(scope="write",
27
+ memory_add(
28
28
  text="Alice prefers email communication. Has Pro plan.",
29
29
  agent_id="support-bot",
30
30
  user_id="alice_123",
31
31
  conversation_id="<conv>")
32
32
 
33
33
  # Serving Bob — completely separate partition, same cognito account
34
- memory_add(scope="write",
34
+ memory_add(
35
35
  text="Bob prefers Slack. On Enterprise plan.",
36
36
  agent_id="support-bot",
37
37
  user_id="bob_456",
38
38
  conversation_id="<conv>")
39
39
 
40
40
  # Search only returns Alice's memories
41
- memory_search(scope="read",
41
+ memory_search(
42
42
  query="communication preference",
43
43
  agent_id="support-bot",
44
44
  user_id="alice_123",
@@ -60,11 +60,12 @@ Mixing creates invisible data.
60
60
 
61
61
  | Layer | Filter | Role of user_id |
62
62
  |---|---|---|
63
- | Personal memories (`memory_add`, `memory_search`, `memory_get_all`) | `(datapack_id, user_id, agent_id)` | Enforced on every read. One user cannot see another's un-promoted memories. |
64
- | Personal conversations (`conversation_list`, `conversation_get`) | Same tuple | Enforced. Cross-user reads require promotion. |
63
+ | Personal memories (`memory_add`, `memory_search`, `memory_get_all`) | `(datapack_id, user_id)` | Enforced on every read. `agent_id` is not applied — one user sees all their own memories across every agent, but cannot see another user's un-promoted memories. |
64
+ | Conversation listing (`conversation_list`) | `(datapack_id, user_id)` | Enforced. `agent_id` is not applied — you see all your own conversations across every agent. |
65
+ | Conversation fetch (`conversation_get`) | `(datapack_id, user_id, agent_id)` | Enforced. Agent-owned: pass the creating `agent_id` or you get `agent_id_mismatch`. Cross-user reads require promotion. |
65
66
  | Team Shared Knowledge (`knowledgebase_search`) | `(datapack_id)` only | **Not used** — `user_id` is stripped when a memory is promoted to Knowledge. All team members on the datapack see the same Shared Knowledge. |
66
67
 
67
- The "Promote to Knowledge" action in the Cloud UI is the one way personal content crosses the user_id boundary. There is no MCP tool for promotion (user-initiated via UI only).
68
+ Personal content crosses the `user_id` boundary through `memory_promote` or the Cloud UI's "Promote to Knowledge" action. The MCP path requires exact memory UUIDs, explicit user confirmation, and an owner/maintainer role; it moves the records into team-visible Shared Knowledge and evicts the private copies.
68
69
 
69
70
  ## Parameter summary
70
71