@yugabytedb/meko-mcp 1.2.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 (44) hide show
  1. package/README.md +28 -19
  2. package/assets/hooks-handlers/before-submit-prompt.sh +2 -2
  3. package/assets/hooks-handlers/lib/capture.js +209 -144
  4. package/assets/hooks-handlers/lib/checkpoint-timer.js +23 -11
  5. package/assets/hooks-handlers/session-start.sh +6 -2
  6. package/assets/scripts/meko-statusline.sh +119 -0
  7. package/assets/scripts/package-desktop-skill.sh +27 -24
  8. package/assets/skills/meko-mcp-tools/SKILL.md +42 -50
  9. package/assets/skills/meko-mcp-tools/references/_sections.md +1 -1
  10. package/assets/skills/meko-mcp-tools/references/tools-cookbook.md +75 -150
  11. package/assets/skills/meko-mcp-tools/references/tools-datapack-workflow.md +30 -36
  12. package/assets/skills/meko-mcp-tools/references/tools-known-limitations.md +6 -22
  13. package/assets/skills/meko-mcp-tools/references/tools-memory-vs-conversation.md +9 -8
  14. package/assets/skills/meko-mcp-tools/references/tools-overview.md +35 -42
  15. package/assets/skills/meko-mcp-tools/references/tools-rag-workflow.md +28 -92
  16. package/assets/skills/meko-mcp-tools/references/tools-scope-permissions.md +5 -9
  17. package/assets/skills/meko-mcp-tools/references/tools-troubleshooting.md +1 -81
  18. package/assets/skills/meko-mcp-tools-desktop/SKILL.md +100 -107
  19. package/assets/skills/meko-mcp-tools-desktop/desktop/README.md +41 -11
  20. package/assets/skills/meko-mcp-tools-desktop/references/_sections.md +1 -1
  21. package/assets/skills/meko-mcp-tools-desktop/references/tools-cookbook.md +71 -150
  22. package/assets/skills/meko-mcp-tools-desktop/references/tools-known-limitations.md +12 -18
  23. package/assets/skills/meko-mcp-tools-desktop/references/tools-memory-vs-conversation.md +12 -15
  24. package/assets/skills/meko-mcp-tools-desktop/references/tools-overview.md +35 -42
  25. package/assets/skills/meko-mcp-tools-desktop/references/tools-rag-workflow.md +28 -92
  26. package/assets/skills/meko-mcp-tools-desktop/references/tools-scope-permissions.md +5 -9
  27. package/assets/skills/meko-mcp-tools-desktop/references/tools-troubleshooting.md +1 -81
  28. package/assets/skills/meko-select-datapack-desktop/SKILL.md +198 -0
  29. package/assets/skills/meko-select-datapack-desktop/references/cookbook.md +121 -0
  30. package/assets/skills/meko-select-datapack-desktop/references/troubleshooting.md +66 -0
  31. package/bin/create-meko-setup.mjs +29 -0
  32. package/lib/clients/claude-code.mjs +133 -6
  33. package/lib/clients/claude-desktop.mjs +37 -12
  34. package/lib/clients/codex.mjs +306 -5
  35. package/lib/clients/common.mjs +41 -1
  36. package/lib/clients/cursor.mjs +75 -19
  37. package/lib/config.mjs +26 -0
  38. package/lib/installer.mjs +24 -0
  39. package/lib/mcp-transport.mjs +5 -0
  40. package/lib/validate.mjs +0 -1
  41. package/package.json +1 -1
  42. package/scripts/bundle-assets.mjs +8 -0
  43. package/assets/skills/meko-mcp-tools/references/tools-db-query-patterns.md +0 -38
  44. package/assets/skills/meko-mcp-tools/references/tools-write-guardrails.md +0 -30
@@ -3,97 +3,6 @@
3
3
  Every tool example below shows the correct parameters, expected response, and common errors. Use `scope="read"` for reads and `scope="write"` for writes — never `"all"` or any other value.
4
4
 
5
5
  > **Note on `agent_id` in the examples below.** The string `"agent"` appears in these examples as a placeholder shorthand; it is NOT a required constant. Substitute **your** client's bucket: for Claude Desktop, the bare client name `claude_desktop`; for Claude Code/Cursor, `<client>:<repo-basename>` (e.g. `claude_code:meko-mcp-server`). For genuinely cross-project facts (user identity, global preferences) write/read with `agent_id="meko_agent"` — the common bucket the server stores empty/missing values into. See `tools-agent-id-conventions.md`.
6
- >
7
- > **Note on availability on Cloud.** The `db_*` tools and the three KB ingestion tools (`knowledgebase_trigger_index_creation`, `knowledgebase_add_source_to_index`, `knowledgebase_check_index_status`) return `{"error": "not_available"}` on Cloud Meko today. This cookbook keeps their examples for reference but you can't call them from a Cloud client.
8
-
9
- ---
10
-
11
- ## Database Tools
12
-
13
- ### db_summarize_database
14
-
15
- **When to use:** First thing in a session to understand what's in the database. Prefer this over writing your own `information_schema` query.
16
-
17
- ```
18
- db_summarize_database(scope="read", schema="public")
19
- ```
20
-
21
- **Response:**
22
- ```json
23
- [
24
- {
25
- "table_name": "customers",
26
- "schema": [
27
- {"column_name": "id", "data_type": "uuid"},
28
- {"column_name": "name", "data_type": "text"}
29
- ],
30
- "row_count": 1523
31
- }
32
- ]
33
- ```
34
-
35
- **With datapack:**
36
- ```
37
- db_summarize_database(scope="read", schema="public", datapack_id="dp-uuid-123")
38
- ```
39
-
40
- **Common errors:**
41
- - `Insufficient scope: 'all'` — Use `scope="read"`, not `"all"`
42
- - Empty result — The schema may not exist, try `schema="public"`
43
-
44
- ---
45
-
46
- ### db_run_read_only_query
47
-
48
- **When to use:** Any SELECT query. Always add `LIMIT` on exploratory queries.
49
-
50
- ```
51
- db_run_read_only_query(scope="read", query="SELECT id, name FROM customers LIMIT 10")
52
- ```
53
-
54
- **Response:** JSON array of row objects.
55
- ```json
56
- [{"id": "abc-123", "name": "Alice"}, {"id": "def-456", "name": "Bob"}]
57
- ```
58
-
59
- **Best practices:**
60
- - Always use `LIMIT` on unfamiliar tables to avoid flooding context
61
- - Select specific columns rather than `SELECT *` to keep responses small
62
- - For non-public schemas: `SELECT * FROM analytics."monthly_revenue" LIMIT 5`
63
- - Escape single quotes in values: `WHERE name = 'O''Brien'`
64
-
65
- **Common errors:**
66
- - `cannot execute INSERT in a read-only transaction` — Use `db_run_write_query` for writes
67
- - `permission denied for table X` — MCP user lacks access to this table (server-side config issue, not fixable via MCP)
68
- - `connection already closed` — Retry once. If persistent, the DB pool is unhealthy.
69
-
70
- ---
71
-
72
- ### db_run_write_query
73
-
74
- **When to use:** INSERT, UPDATE, DELETE, CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX.
75
-
76
- ```
77
- db_run_write_query(scope="write", query="INSERT INTO customers (id, name) VALUES ('abc-123', 'Alice')")
78
- ```
79
-
80
- **Response:**
81
- ```json
82
- {"rows_affected": 1}
83
- ```
84
-
85
- **One statement per call.** This is wrong:
86
- ```
87
- db_run_write_query(scope="write", query="CREATE TABLE a (id INT); CREATE TABLE b (id INT);")
88
- ```
89
- Split into two separate calls.
90
-
91
- **Bulk inserts:** Maximum 1000 rows per INSERT VALUES. For more, use `INSERT ... SELECT` or batch into multiple calls.
92
-
93
- **Common errors:**
94
- - `Multi-statement queries not allowed` — Send one statement per call
95
- - `DROP SCHEMA is not allowed` — See `tools-write-guardrails.md` for blocked operations
96
- - `'dict' object has no attribute 'guardrail_config'` — Known server bug in some deployments. Write operations may be unavailable.
97
6
 
98
7
  ---
99
8
 
@@ -103,11 +12,11 @@ Split into two separate calls.
103
12
 
104
13
  ### memory_add
105
14
 
106
- **When to use:** Store facts, preferences, user profile info, org conventions, corrections, learnings. Use proactively — don't wait for the user to ask.
15
+ **When to use:** NOT for facts the user states — those are captured when you post the turn with `conversation_add_message` and the server extracts them. Reserve `memory_add` for the three cases per-turn capture can't reach: (1) the user explicitly says "remember this"; (2) a durable fact only in your output or a tool result, never in a user turn; (3) overwriting a negated/corrected fact (pair with `memory_delete_by_id`, since extraction is additive).
107
16
 
108
17
  ```
109
- memory_add(scope="write", agent_id="agent",
110
- text="User Amiram is VP of Product at YugabyteDB. Prefers concise responses.")
18
+ memory_add(scope="write", agent_id="claude_desktop",
19
+ text="Remember: deploy scripts must be run from the repo root, never a subdir.")
111
20
  ```
112
21
 
113
22
  **Response:**
@@ -122,9 +31,8 @@ memory_add(scope="write", agent_id="agent", user_id="amiram",
122
31
  ```
123
32
 
124
33
  **What NOT to store via memory_add:**
125
- - CSV rows or tabular data (use `db_run_write_query` instead)
126
34
  - Full conversations (use `conversation_create` + `conversation_add_message`)
127
- - Large documents (use knowledge base ingestion)
35
+ - Large documents (use the UI's Datapack → Actions → Add Knowledge upload flow)
128
36
 
129
37
  **Common errors:**
130
38
  - `syntax error at or near "-"` — legacy error from the pre-multi-tenancy schema when `agent_id` became part of a PostgreSQL identifier. No longer applies on Cloud (agent_id is a TEXT column value, any string is accepted). If you hit it on a deployment that still uses the old schema, use underscores instead of hyphens.
@@ -225,11 +133,14 @@ conversation_create(scope="write", agent_id="agent", user_id="amiram",
225
133
 
226
134
  **When to use:** Add a user/assistant exchange to an existing conversation. **All fields must be verbatim** — never summarize or rephrase.
227
135
 
136
+ Pass `index_for_search=True` on substantive turns so this conversation is embedded into the shared conversation-history cache (searchable later via `conversation_search` / `contextual_prominence_search`). This isn't limited to WorkbenchLM — pass it for agent-harness conversations too.
137
+
228
138
  ```
229
139
  conversation_add_message(scope="write", conversation_id="conv-uuid-123", agent_id="agent",
230
140
  input="Why is the auth middleware returning 401?",
231
141
  output="The token validation is checking the wrong issuer claim...",
232
- reasoning="Checked the middleware source, found issuer mismatch between config and JWT...")
142
+ reasoning="Checked the middleware source, found issuer mismatch between config and JWT...",
143
+ index_for_search=True)
233
144
  ```
234
145
 
235
146
  **With dedup seed (use when client hooks also write to Langfuse):**
@@ -237,7 +148,8 @@ conversation_add_message(scope="write", conversation_id="conv-uuid-123", agent_i
237
148
  conversation_add_message(scope="write", conversation_id="conv-uuid-123", agent_id="agent",
238
149
  input="Why is the auth middleware returning 401?",
239
150
  output="The token validation is checking the wrong issuer claim...",
240
- seed="conv-uuid-123:agent:Why is the auth middleware returning 401?")
151
+ seed="conv-uuid-123:agent:Why is the auth middleware returning 401?",
152
+ index_for_search=True)
241
153
  ```
242
154
 
243
155
  ---
@@ -278,11 +190,11 @@ conversation_delete(scope="admin", conversation_id="conv-uuid-123", agent_id="ag
278
190
 
279
191
  ---
280
192
 
281
- ## RAG / Knowledge Base Tools
193
+ ## Knowledge Base Tools
282
194
 
283
- **On cloud Meko today, KB ingestion is a UI-only activity.** Users upload files via the datapack's Actions → **Add Knowledge** dialog (PDF/TXT/MD/JSON/MP4, 5MB each, 10/batch). The three ingestion-side MCP tools below are Free-Tier-gated on cloud and brittle even when ungated. `knowledgebase_search` is the one KB tool to reach for.
195
+ **KB ingestion is a UI-only activity.** Users upload files via the datapack's Actions → **Add Knowledge** dialog (PDF/TXT/MD/JSON/MP4, 5MB each, 10/batch). `knowledgebase_search` is the one KB tool exposed via MCP.
284
196
 
285
- See `tools-rag-workflow.md` for the decision table and why.
197
+ See `tools-rag-workflow.md` for the decision table.
286
198
 
287
199
  ### knowledgebase_search
288
200
 
@@ -309,73 +221,82 @@ Populated KBs return results with chunk content and similarity scores. An empty/
309
221
 
310
222
  ---
311
223
 
312
- ### knowledgebase_trigger_index_creation
224
+ ## Artifact Tools
225
+
226
+ ### artifact_put
313
227
 
314
- **When to use:** Self-hosted deployments where the ingestion worker has IAM access to the target S3 bucket. **Not available on cloud Free Tier** (returns `{"error": "not_available", "detail": "Vector index creation is not available on the free tier."}`).
228
+ **When to use:** An agent has generated a file (report, CSV, PDF, code output, image) and wants to persist it in Meko for later retrieval or cross-agent sharing. Files < 1 MB are stored inline in the DB; files ≥ 1 MB go to the datapack's S3 bucket. Idempotent — uploading the same bytes twice returns the same `content_hash`.
315
229
 
316
230
  ```
317
- knowledgebase_trigger_index_creation(
231
+ artifact_put(
318
232
  scope="write",
233
+ filename="analysis_report.csv",
234
+ content_type="text/csv",
235
+ content_base64="<base64-encoded bytes>",
319
236
  conversation_id="<uuid from conversation_create>",
320
- source_uris="s3://my-bucket/docs/,s3://my-bucket/reports/",
321
- index_name="company_docs")
237
+ agent_id="claude_desktop"
238
+ )
322
239
  ```
323
240
 
324
- **Optional parameters:**
325
- - `ai_provider="OPENAI"` (default)
326
- - `embedding_model="text-embedding-3-large"` (default)
327
- - `embedding_dimensions=1536` (default)
328
- - `chunk_size=1024` (default)
329
- - `chunk_overlap=256` (default)
330
- - `datapack_id=None`
331
-
332
- **Success response:**
241
+ **Response:**
333
242
  ```json
334
- {"source_ids": ["<uuid>", ...], "index_id": "<uuid>", "index_name": "company_docs",
335
- "status": "build_triggered", "message": "... registered, index '...' initialised, and build triggered."}
243
+ {
244
+ "artifact_id": "550e8400-e29b-41d4-a716-446655440000",
245
+ "content_hash": "a665a45920422f9d417e4867efdc4fb8a5f1f89ea5b8440b1ad4c4c6b8a7e4d3",
246
+ "filename": "analysis_report.csv",
247
+ "content_type": "text/csv",
248
+ "size_bytes": 4096,
249
+ "stored_in": "db"
250
+ }
336
251
  ```
337
252
 
338
- **Critical caveats:**
339
- - URIs must start with `s3://`. The worker (`aws_source_processor.py:86-117`) rejects any other scheme with `ValueError("Invalid source URI")` — async, not surfaced through the MCP response.
340
- - The worker uses the boto3 default credential chain (env vars, IAM role, `~/.aws/credentials` on the worker host). There is no way for the user to pass AWS credentials through the MCP tool. If the worker's identity can't read the bucket, the build stalls at INIT.
341
- - Each call creates a new index. Do NOT retry on failure — you'll get duplicate indexes.
342
- - Tracked as a gap: [yugabyte/meko-mcp-server#89](https://github.com/yugabyte/meko-mcp-server/issues/89) / MEKO-96.
253
+ Save the `content_hash` — it's the retrieval key for `artifact_get`.
254
+
255
+ **Common errors:**
256
+ - `invalid_base64` — `content_base64` is not valid base64.
257
+ - `artifact_too_large` — file exceeds 5 MiB (default). Set `MEKO_MAX_ARTIFACT_UPLOAD_BYTES` to raise the limit.
343
258
 
344
259
  ---
345
260
 
346
- ### knowledgebase_check_index_status
261
+ ### artifact_get
347
262
 
348
- **When to use:** Poll a self-hosted build for completion. **Not available on cloud Free Tier** (returns `{"error": "not_available"}`).
263
+ **When to use:** Retrieve a file previously uploaded with `artifact_put`.
349
264
 
265
+ **Small files (< 1 MB) — content returned inline:**
350
266
  ```
351
- knowledgebase_check_index_status(
267
+ artifact_get(
352
268
  scope="read",
269
+ content_hash="a665a45920422f9d417e4867efdc4fb8a5f1f89ea5b8440b1ad4c4c6b8a7e4d3",
353
270
  conversation_id="<uuid from conversation_create>",
354
- index_name="company_docs",
355
- datapack_id=None)
271
+ agent_id="claude_desktop"
272
+ )
356
273
  ```
357
274
 
358
- Check `completion_rate_percent` in `pipeline_stats` and `document_status` in `pipeline_details`. If documents stay at `INIT` for >5 minutes, the worker probably can't reach the bucket. Stop polling after 3 consecutive no-progress checks.
359
-
360
- ---
361
-
362
- ### knowledgebase_add_source_to_index
363
-
364
- **When to use:** Grow an existing index with a new source URI (self-hosted / paid). **Not available on cloud Free Tier** (same "Vector index creation is not available" gate as `trigger_index_creation`).
365
-
366
- ```
367
- knowledgebase_add_source_to_index(
368
- scope="write",
369
- conversation_id="<uuid from conversation_create>",
370
- index_name="company_docs",
371
- source_uri="s3://my-bucket/new-docs/")
275
+ **Response (inline):**
276
+ ```json
277
+ {
278
+ "content_hash": "a665a45920422f9d417e4867efdc4fb8...",
279
+ "filename": "analysis_report.csv",
280
+ "stored_in": "db",
281
+ "content_base64": "<base64-encoded bytes>"
282
+ }
372
283
  ```
373
284
 
374
- Param is **`source_uri`** (URI string), not `source_id` — older docs had this wrong.
285
+ **Large files (≥ 1 MB) — written to local disk:**
286
+ ```json
287
+ {
288
+ "content_hash": "a665a45920422f9d417e4867efdc4fb8...",
289
+ "filename": "dataset.parquet",
290
+ "stored_in": "s3",
291
+ "local_path": "/Users/you/.meko/artifacts/a665a4.../dataset.parquet"
292
+ }
293
+ ```
375
294
 
376
- The historical `r_index_name` vs `r_index_id` parameter-mismatch bug (reported in 2026-03) is **fixed** on main. The tool now resolves `index_name → index_id` internally via `SELECT id FROM dist_rag.vector_indexes WHERE index_name = %s` before calling the dist_rag function. If the name doesn't exist you get `{"error": "index_not_found", "detail": "No vector index found with name '...'"}`.
295
+ For large files use `local_path` to read the file. S3 URLs are never exposed.
377
296
 
378
- Same S3-only / worker-credentials caveats as `trigger_index_creation` apply.
297
+ **Common errors:**
298
+ - `ARTIFACT_NOT_FOUND` — no artifact with that hash in this datapack.
299
+ - `ARTIFACT_EXPIRED` — free-tier TTL has elapsed (30 days of no access).
379
300
 
380
301
  ---
381
302
 
@@ -385,22 +306,22 @@ Same S3-only / worker-credentials caveats as `trigger_index_creation` apply.
385
306
 
386
307
  ```
387
308
  datapack_create(scope="write", name="analytics_prod")
388
- datapack_list(scope="read")
389
- datapack_describe(scope="read", name="analytics_prod", include_status=True)
309
+ datapack_list(scope="read") # returns datapack_id for each datapack
310
+ datapack_describe(scope="read", datapack_id="<uuid>", include_status=True)
390
311
  ```
391
312
 
392
313
  ### datapack_update / datapack_delete
393
314
 
394
315
  ```
395
- datapack_update(scope="write", name="analytics_prod", connection_string="postgresql://...")
396
- datapack_delete(scope="admin", name="analytics_prod") # Irreversible!
316
+ datapack_update(scope="write", datapack_id="<uuid>", connection_string="postgresql://...")
317
+ datapack_delete(scope="admin", datapack_id="<uuid>") # Irreversible!
397
318
  ```
398
319
 
399
320
  ### Agent and knowledge-base management (NOT MCP — control-plane only)
400
321
 
401
322
  Agent and KB lifecycle does not ship as MCP tools. If the user asks to create/list/delete agents or KB sources, don't invent a tool call — point them at the control plane:
402
323
 
403
- - REST: `POST/GET/DELETE /datapacks/:name/agents` (agents), `POST/GET/DELETE /datapacks/:name/knowledge-bases` (KB sources).
324
+ - REST: `POST/GET/DELETE /datapacks/:datapack_id/agents` (agents), `POST/GET/DELETE /datapacks/:datapack_id/knowledge-bases` (KB sources).
404
325
  - Or the Meko UI at `app.mekodev.com` → Datapacks → agents / knowledge-bases.
405
326
 
406
- To build a RAG index from inside a session (which IS MCP-exposed), use `knowledgebase_trigger_index_creation` / `knowledgebase_add_source_to_index` / `knowledgebase_check_index_status` — those operate on `dist_rag` tables inside the datapack's database.
327
+ KB ingestion specifically lives in the UI today: Datapack → Actions → **Add Knowledge** (PDF/TXT/MD/JSON/MP4, 5 MB each, 10/batch). Agents querying a populated index use `knowledgebase_search` — see `tools-rag-workflow.md`.
@@ -10,15 +10,15 @@ There are no MCP tools to:
10
10
  - Clear stuck work queue entries
11
11
  - Reset a failed pipeline
12
12
 
13
- KB-source deletion happens via the Meko control plane (REST: `DELETE /datapacks/:name/knowledge-bases`, or the UI), which removes the registration from the Meko API — but does **not** touch the actual `dist_rag` index, source records, or vector data in the datapack's database.
13
+ KB-source deletion happens via the Meko control plane (REST: `DELETE /datapacks/:datapack_id/knowledge-bases`, or the UI), which removes the registration from the Meko API — but does **not** touch the actual `dist_rag` index, source records, or vector data in the datapack's database.
14
14
 
15
15
  **Workaround:** For stuck or failed indexes, create a new index with a different name. Stale indexes remain in the database until manually cleaned up by an admin.
16
16
 
17
- ## No MCP tool to query a built RAG index
17
+ ## RAG ingestion is UI-only
18
18
 
19
- The RAG tools (`knowledgebase_trigger_index_creation`, `knowledgebase_add_source_to_index`, `knowledgebase_check_index_status`) handle index **creation and monitoring** only.
19
+ KB ingestion (creating an index, adding sources, polling build status) is not exposed via MCP. Documents go in through the Cloud UI's **Add Knowledge** flow (Datapack → Actions → Add Knowledge) — PDF/TXT/MD/JSON/MP4 up to 5 MB each, 10 per batch.
20
20
 
21
- To actually **query** a built index on Cloud, use `knowledgebase_search` — it returns both uploaded documents (UI "Add Knowledge" flow) and memories the user promoted from the Learnings tab. The `db_run_read_only_query` direct-DB path is Free-Tier-gated on Cloud.
21
+ To **query** a built index, use `knowledgebase_search` — it returns both uploaded documents and memories the user promoted from the Learnings tab.
22
22
 
23
23
  ## Memory tools unreliable for structured/tabular data
24
24
 
@@ -32,7 +32,7 @@ It works **poorly** for:
32
32
  - Data dictionaries — only partial information extracted
33
33
  - Structured schemas — relationships between fields lost
34
34
 
35
- **On Cloud, structured data is not MCP-supported today.** `db_run_write_query` / `db_run_read_only_query` / `db_summarize_database` all return `{"error": "not_available", "detail": "Free Tier: DB Tools access is not enabled. coming soon."}`. The options are:
35
+ **Structured data is not natively supported via MCP.** The options are:
36
36
 
37
37
  1. **Write a single narrative summary** as a memory — one call, not row-by-row:
38
38
  ```
@@ -42,25 +42,19 @@ It works **poorly** for:
42
42
  text="Customer Complaints dataset has fields: Complaint ID (int PK), Date Submitted (date), Product (text, e.g. Mortgage/Credit Card), Sub-product (text), Issue (text), Company Response (text), State (text, 2-letter code), ZIP Code (text)")
43
43
  ```
44
44
  2. **Upload the schema doc** through the Cloud UI's **Add Knowledge** flow (Datapack → Actions → Add Knowledge). Accepts PDF/TXT/MD/JSON — convert CSV to MD or JSON first. That makes it queryable via `knowledgebase_search`.
45
- 3. **Tell the user** that structured-data storage via MCP isn't a Cloud feature today and let them decide how to proceed.
45
+ 3. **Tell the user** that structured-data storage via MCP isn't supported and let them decide how to proceed.
46
46
 
47
47
  Never ingest CSV row-by-row into memory — each row becomes a fragmented fact with lost context.
48
48
 
49
- ## MCP user permission gaps
49
+ ## Activation is model-judged on Desktop (no hooks)
50
50
 
51
- The MCP database user may not have read access to all tables within a datapack, particularly:
52
- - Data tables created by the provisioning system
53
- - Tables in non-public schemas
51
+ Claude Desktop has no lifecycle hooks, so this skill activates only when the model judges it relevant from the skill's `description`. Reliable triggers: recall questions ("what do you know about me"), explicit save requests ("remember this"), and mentions of memory/Meko/datapacks. **Best-effort** triggers: task-shaped prompts where a durable fact appears only in passing ("I'm evaluating pnpm; I already use Turborepo") — the skill may not fire and the turn goes uncaptured. Also, when the model resolves a tool directly via tool search it may call `memory_add`/`memory_search` without reading this skill at all.
54
52
 
55
- If `db_run_read_only_query` returns "permission denied", this is a server-side configuration issue. Use `db_summarize_database` to see which tables are accessible.
53
+ The skill description is tuned to its 1024-char ceiling; broadening it further does not close the task-shaped-prompt gap (empirically confirmed in Phase-9 testing). Mitigations, in order of leverage:
56
54
 
57
- ## Currently broken tools
58
-
59
- **`db_run_write_query`** — May fail with `'dict' object has no attribute 'guardrail_config'` in some deployments. When this happens, all write operations are blocked for the session.
60
-
61
- **Knowledge-base ingestion tools on cloud Meko** (`knowledgebase_trigger_index_creation`, `knowledgebase_add_source_to_index`, `knowledgebase_check_index_status`) return `{"error": "not_available"}` on Free Tier. Even when ungated, the async worker only reads `s3://` URIs and uses its own boto3 credential chain — it cannot read buckets the user provides credentials for. Tracked: [yugabyte/meko-mcp-server#89](https://github.com/yugabyte/meko-mcp-server/issues/89) / MEKO-96. Use the Meko UI's **Add Knowledge** file-upload dialog for ingestion on cloud. `knowledgebase_search` works on cloud today.
62
-
63
- (Historical note: `knowledgebase_add_source_to_index` used to have a `r_index_name` vs `r_index_id` SQL-signature bug. That specific bug was fixed on main in commit `3ae724a` — the tool now resolves `index_name → index_id` internally.)
55
+ 1. **Personal-preferences snippet** (always-on) — paste the snippet from the Desktop setup README's "Make Desktop proactive" step into Claude's profile preferences; it is injected into every conversation regardless of prompt shape. This is the only true fix for task-shaped misses.
56
+ 2. **Server-side guidance** — the `agent_id` tool docstrings and the server's connect-time instructions name `claude_desktop` as this client's bucket, so even a skill-less tool-search call avoids the wrong-bucket (`claude_code`) write.
57
+ 3. Nothing is lost when the *user* explicitly recalls or saves — only passive capture of in-passing facts is best-effort.
64
58
 
65
59
  ## No conversation search
66
60
 
@@ -111,41 +111,38 @@ For a true fan-out across other clients' buckets (e.g. also see what was written
111
111
 
112
112
  **WRONG:** Using `memory_add` to ingest CSV rows, data dictionaries, or tabular schemas — Mem0 extracts individual facts and may drop columns, rows, or structural relationships.
113
113
 
114
- On Cloud Meko today the `db_run_write_query` path isn't available (returns `{"error": "not_available"}`), so there's no MCP-side "just put it in a database table" option. Workarounds:
114
+ There is no MCP-side "just put it in a database table" option — raw SQL access isn't part of the MCP surface. Workarounds:
115
115
 
116
116
  1. **Write a single narrative summary** as a memory: `"The Customer Complaints dataset has fields: Complaint ID (int), Date Submitted (date), Product (text), Sub-product (text), Issue (text)..."` — one call, not row-by-row.
117
117
  2. **Suggest the user upload the file** via the Cloud UI's Add Knowledge flow if it's a document (CSV files aren't in the supported list — PDF/TXT/MD/JSON/MP4 are; for CSV, convert to MD or JSON first).
118
118
  3. **Never ingest CSV row-by-row** into memory — each row becomes a fragmented fact with lost context.
119
119
 
120
- ## Proactive Memory Storage
120
+ ## Memory Storage: capture the turn, don't proactively memory_add
121
121
 
122
- Don't wait for the user to say "remember this." Store context proactively when you detect:
122
+ Do **not** proactively `memory_add` facts the user states. On Claude Desktop, post each substantive turn with `conversation_add_message` and the server extracts durable memories from it automatically — personal info, team conventions, domain knowledge, and corrections the user states are all captured that way. A separate `memory_add` just duplicates what extraction produces.
123
123
 
124
- - **Personal info** → `memory_add`: "User is VP of Product, prefers concise responses"
125
- - **Team conventions** → `memory_add`: "Team uses Python for backend, Go for infrastructure"
126
- - **Domain knowledge** → `memory_add`: "Meko traces are decision traces that capture how and why decisions were made"
127
- - **Corrections** → `memory_add`: "User corrected: always use 'resilience' instead of 'high availability'"
124
+ Explicit `memory_add` is reserved for the three cases per-turn capture can't reach:
125
+
126
+ - **Explicit request** → the user says "remember this" / "save this."
127
+ - **Output-only / tool-derived fact** → a durable fact only in your output or a tool result, never in a user turn (extraction reads the user side of the turn).
128
+ - **Overwriting correction** → a prior fact was negated and the stale memory must not survive. Extraction is additive, so `memory_search` for the old memory and `memory_update` / `memory_delete_by_id`.
128
129
 
129
130
  Use `memory_search` at the start of sessions to recall what you already know before asking the user to repeat themselves.
130
131
 
131
132
  ## Using Both Together
132
133
 
133
- A common pattern: store the full conversation (preserves structure) AND extract key facts with `memory_add` (enables semantic search later).
134
+ Posting the turn does both jobs: it preserves the full conversation (structure) and feeds the extractor (searchable memory). Add an explicit `memory_add` only for the three cases above.
134
135
 
135
136
  ## Key Retrieval Difference
136
137
 
137
138
  - `memory_search`: **semantic similarity** across all memories via pgvector. Returns relevant facts regardless of when stored.
138
139
  - `conversation_get`: **ordered list of message turns** for a specific conversation. No semantic search. Requires `conversation_id`.
139
140
 
140
- ## Automatic Conversation Capture
141
-
142
- The Meko plugin captures conversations automatically via three mechanisms:
141
+ ## Conversation Capture (Desktop: agent-driven)
143
142
 
144
- 1. **Periodic checkpoint (~10 min)** — Agent-driven via CronCreate, uses `conversation_add_message` MCP tool directly
145
- 2. **PreCompact hook** — Shell script that fires before Claude Code's auto-compaction, captures via MCP JSON-RPC
146
- 3. **SessionEnd hook** — Shell script that fires at session termination, captures final exchanges
143
+ Claude Desktop has **no capture hooks** — you are the capture mechanism. Post each substantive turn with `conversation_add_message`, and the server extracts memories from the posted turns automatically (extraction runs inside `conversation_add_message`). Coding clients like Claude Code get the same effect from SessionStart / PreCompact / SessionEnd hooks; on Desktop it's your responsibility per turn.
147
144
 
148
- ### What gets captured
145
+ ### What to capture
149
146
 
150
147
  The full transcript including:
151
148
  - **User prompts** — verbatim text (the `input` field)
@@ -1,62 +1,40 @@
1
1
  # Complete Tool Catalog and Decision Tree
2
2
 
3
- **26 tools on cloud Meko** (verified against `https://mcp.mekodata.ai/mcp` on 2026-05-07). Earlier counts of 25 or 31 in other docs are stale. Grouped: Memory (8), Conversation (6), Knowledge Base (4), Datapack (5), Database (3).
4
-
5
- ## Cloud Free-Tier gating at a glance
6
-
7
- Some tools return `{"error": "not_available", "detail": "..."}` on cloud Free Tier. This is a server-side tier block — don't retry.
8
-
9
- - **Gated on Free Tier**: `db_summarize_database`, `db_run_read_only_query`, `db_run_write_query`, `knowledgebase_trigger_index_creation`, `knowledgebase_add_source_to_index`, `knowledgebase_check_index_status`
10
- - **Works on Free Tier**: all memory tools, all conversation tools, `knowledgebase_search`, all datapack tools, `flush_pending_memory_candidates`
3
+ **22 tools on Cloud Meko** (verified against `https://mcp.mekodata.ai/mcp`). Grouped: Memory (8), Conversation (6), Knowledge Base (1), Datapack (5), Artifacts (2), Observability (1).
11
4
 
12
5
  ## Quick health check before using tools
13
6
 
14
7
  Before starting a session, verify that the Meko MCP tools are working:
15
8
 
16
9
  1. `memory_search(scope="read", query="test", agent_id="<your-session-agent-id>", conversation_id="<session-conversation-id>")` — Confirms memory subsystem is up. Use the `agent_id` and `conversation_id` from the SessionStart `additionalContext`. May fail with "connection already closed" — see `tools-troubleshooting.md`.
17
- 2. `datapack_list(scope="read")` — Confirms Meko API connectivity
18
- 3. `db_summarize_database(scope="read")` — *Optional, paid-tier only.* On free-tier datapacks this returns `{"error": "not_available"}`. The old "use this for `agent_id` discovery" protocol is retired — use your client's bucket (`claude_desktop` for Claude Desktop) or `meko_agent` for the common bucket.
10
+ 2. `datapack_list(scope="read")` — Confirms Meko API connectivity. Returns the datapacks your token has access to.
19
11
 
20
12
  ## Decision tree: which tool do I need?
21
13
 
22
14
  ```
23
15
  User wants to...
24
- ├── Query or explore the database?
25
- │ ├── See what tables exist? ---------> db_summarize_database (read)
26
- │ ├── Run a SELECT / read query? -----> db_run_read_only_query (read)
27
- │ └── INSERT / UPDATE / DELETE? -------> db_run_write_query (write)
28
- ├── Query or build a knowledge base (RAG)?
29
- │ ├── Search chunks in an existing KB? -> knowledgebase_search (read) — WORKS on cloud today
30
- │ ├── Create a new index from sources? -> knowledgebase_trigger_index_creation (write) — Free-Tier gated, self-hosted only
31
- │ ├── Add source to existing index? ---> knowledgebase_add_source_to_index (write) — Free-Tier gated
32
- │ └── Check build progress? -----------> knowledgebase_check_index_status (read) — Free-Tier gated
16
+ ├── Search a knowledge base? ---------------> knowledgebase_search (read)
17
+ ├── Add documents to a knowledge base? -----> point user at Meko UI: Datapack → Actions → Add Knowledge
18
+ │ (no MCP tool — Cloud uses UI ingestion only)
33
19
  ├── Store or recall information?
34
20
  │ ├── Store a fact/preference/entity? -----------> memory_add (write)
35
21
  │ ├── Store a full conversation (multi-turn)? ---> conversation_create + conversation_add_message (write)
36
22
  │ ├── Search past knowledge? --------------------> memory_search (read)
37
23
  │ └── Retrieve a past conversation? -------------> conversation_get (read)
24
+ ├── Persist or retrieve a file?
25
+ │ ├── Upload a generated file (report, CSV, PDF)? -> artifact_put (write)
26
+ │ └── Retrieve a previously uploaded file? -------> artifact_get (read)
38
27
  └── Manage datapacks?
39
- └── CRUD datapack? -> datapack_create/list/describe/update/delete
28
+ └── CRUD datapack? --------------------> datapack_create/list/describe/update/delete
40
29
  ```
41
30
 
42
31
  Agent / knowledge-base lifecycle is managed **outside** the MCP surface — typically in the Meko control-plane UI — and is not exposed as tools here.
43
32
 
44
- ## Database Tools (3)
45
-
46
- | Tool | Scope | Purpose |
47
- |------|-------|---------|
48
- | `db_summarize_database(scope, schema="public", datapack_id=None)` | read | List tables with column schemas and row counts |
49
- | `db_run_read_only_query(scope, query, datapack_id=None)` | read | Run SELECT, returns JSON. Uses `BEGIN READ ONLY` + `ROLLBACK` |
50
- | `db_run_write_query(scope, query, datapack_id=None)` | write | Execute INSERT/UPDATE/DELETE/CREATE TABLE. Guardrail-validated. Auto-committed |
51
-
52
- ## RAG / Knowledge Base Tools (4)
33
+ ## Knowledge Base Tools (1)
53
34
 
54
35
  | Tool | Scope | Purpose |
55
36
  |------|-------|---------|
56
- | `knowledgebase_search(scope, query, agent_id, conversation_id, datapack_id, limit=10)` | read | Semantic search across KB chunks. `datapack_id` is REQUIRED (no default). Works on cloud today. |
57
- | `knowledgebase_trigger_index_creation(scope, conversation_id, source_uris, index_name, ai_provider="OPENAI", embedding_model="text-embedding-3-large", embedding_dimensions=1536, chunk_size=1024, chunk_overlap=256, datapack_id=None)` | write | Register sources + init vector index + trigger build. **S3-only worker + no user creds; Free-Tier gated on cloud.** See `tools-rag-workflow.md`. |
58
- | `knowledgebase_add_source_to_index(scope, conversation_id, index_name, source_uri, chunk_size=1024, chunk_overlap=256, datapack_id=None)` | write | Add a new source (URI, not id) to an existing index. Free-Tier gated on cloud. |
59
- | `knowledgebase_check_index_status(scope, conversation_id, index_name, datapack_id=None)` | read | Check build progress via `dist_rag.vector_index_pipeline_details`. Free-Tier gated on cloud. |
37
+ | `knowledgebase_search(scope, query, agent_id, conversation_id, datapack_id, limit=10)` | read | Semantic search across KB chunks. `datapack_id` is REQUIRED (no default). |
60
38
 
61
39
  ## Memory Tools (8)
62
40
 
@@ -69,7 +47,7 @@ Agent / knowledge-base lifecycle is managed **outside** the MCP surface — typi
69
47
  | `memory_update(scope, memory_id, text, agent_id, conversation_id, datapack_id=None)` | write | Overwrite memory text |
70
48
  | `memory_delete_by_id(scope, memory_id, agent_id, conversation_id, datapack_id=None)` | write | Delete a single memory |
71
49
  | `memory_delete_all(scope, agent_id, conversation_id, user_id=None, app_id=None, run_id=None, datapack_id=None)` | admin | Delete all memories for agent (destructive) |
72
- | `flush_pending_memory_candidates(scope, agent_id)` | read | Desktop-skill helper: returns an instruction payload telling the agent to scan recent user turns and `memory_add` unsaved facts. No server-side DB write. |
50
+ | `flush_pending_memory_candidates(scope, agent_id)` | read | **Deprecated.** Superseded by automatic extraction from posted turns — post substantive turns with `conversation_add_message` and the server extracts memories from them. Now returns a `deprecated` payload pointing at `conversation_add_message`; kept one release for backward compatibility. |
73
51
 
74
52
  ## Conversation Tools (6)
75
53
 
@@ -88,9 +66,24 @@ Agent / knowledge-base lifecycle is managed **outside** the MCP surface — typi
88
66
  |------|-------|---------|
89
67
  | `datapack_create(scope, name)` | write | Create new datapack |
90
68
  | `datapack_list(scope)` | read | List all datapacks |
91
- | `datapack_describe(scope, name, include_status=False)` | read | Describe datapack |
92
- | `datapack_update(scope, name, connection_string)` | write | Update connection string |
93
- | `datapack_delete(scope, name)` | admin | Delete datapack (irreversible) |
69
+ | `datapack_describe(scope, datapack_id, include_status=False)` | read | Describe datapack by UUID |
70
+ | `datapack_update(scope, datapack_id, connection_string)` | write | Update connection string |
71
+ | `datapack_delete(scope, datapack_id)` | admin | Delete datapack by UUID (irreversible) |
72
+
73
+ ## Artifact Tools (2)
74
+
75
+ Content-addressed blob store scoped to a datapack. Files < 1 MB go inline in the DB; files ≥ 1 MB go to S3. Identity is SHA-256 — uploading the same bytes twice returns the same `content_hash`. Free-tier artifacts expire after 30 days of inactivity; pro-tier artifacts have no TTL.
76
+
77
+ | Tool | Scope | Purpose |
78
+ |------|-------|---------|
79
+ | `artifact_put(scope, filename, content_base64, content_type, conversation_id, datapack_id=None, agent_id=None)` | write | Upload a file to the datapack. Returns `{artifact_id, content_hash, filename, size_bytes, stored_in}`. Max 5 MiB (configurable via `MEKO_MAX_ARTIFACT_UPLOAD_BYTES`). |
80
+ | `artifact_get(scope, content_hash, conversation_id, datapack_id=None, agent_id=None)` | read | Retrieve a file by SHA-256 hash. Small files return `content_base64` inline; large files (S3) are written to `~/.meko/artifacts/<hash>/<filename>` and `local_path` is returned. |
81
+
82
+ ## Observability Tools (1)
83
+
84
+ | Tool | Scope | Purpose |
85
+ |------|-------|---------|
86
+ | `track_token_usage(scope, conversation_id, name, input_tokens=0, output_tokens=0, total_tokens=None, model=None, message_id=None, datapack_id=None)` | write | Record an LLM-cost GENERATION observation on the conversation's trace. Primarily called by first-party Meko services (e.g. inference_gateway) that know their LLM's exact token counts. Most end-agents (Cursor, Claude Desktop) don't have those counts at the MCP call layer, so this tool is rarely useful for third-party agents. |
94
87
 
95
88
  ## Platform capabilities NOT exposed via MCP
96
89
 
@@ -98,15 +91,15 @@ Some things the Meko platform can do are not wired into the MCP tool surface tod
98
91
 
99
92
  | Capability | Where it lives | How to reach it |
100
93
  |---|---|---|
101
- | Create / list / delete **agents** within a datapack | `yugabyte/meko` API server | REST: `POST/GET/DELETE /datapacks/:name/agents` (`POST/GET/DELETE /agents/:agent` for targeted deletes), or the Meko control-plane UI |
102
- | Add / list / delete **knowledge-base sources** on a datapack | `yugabyte/meko` API server | REST: `POST/GET/DELETE /datapacks/:name/knowledge-bases`, plus `upload-url`, `upload-complete`, `create`, `status` subroutes. Also available in the Meko UI. |
103
- | Langfuse project-key generation | `yugabyte/meko` API server | REST: `POST /datapacks/:name/langfuse/project-keys` |
94
+ | Create / list / delete **agents** within a datapack | `yugabyte/meko` API server | REST: `POST/GET/DELETE /datapacks/:datapack_id/agents` (`POST/GET/DELETE /agents/:agent` for targeted deletes), or the Meko control-plane UI |
95
+ | Add / list / delete **knowledge-base sources** on a datapack | `yugabyte/meko` API server | REST: `POST/GET/DELETE /datapacks/:datapack_id/knowledge-bases`, plus `upload-url`, `upload-complete`, `create`, `status` subroutes. Also available in the Meko UI. |
96
+ | Langfuse project-key generation | `yugabyte/meko` API server | REST: `POST /datapacks/:datapack_id/langfuse/project-keys` |
104
97
  | Account / billing / tier management | Meko UI only | Not available via MCP or public REST |
105
98
 
106
99
  The MCP-exposed `datapack_create` / `datapack_list` / `datapack_describe` / `datapack_update` / `datapack_delete` tools above are a deliberate subset — the common CRUD that an agent reasonably needs mid-conversation. Anything involving agent or KB lifecycle is control-plane territory.
107
100
 
108
- For knowledge-base content on cloud today, the canonical path is **UI upload**: Datapack → Actions → **Add Knowledge** (PDF/TXT/MD/JSON/MP4, 5MB each, 10/batch). `knowledgebase_search` queries the resulting index from MCP. The MCP ingestion tools (`knowledgebase_trigger_index_creation`, `knowledgebase_add_source_to_index`, `knowledgebase_check_index_status`) exist but are Free-Tier gated and rely on an S3-only worker with no user-supplied credentials — see `tools-rag-workflow.md` for the full picture. Tracked upstream as [#89](https://github.com/yugabyte/meko-mcp-server/issues/89) / MEKO-96.
101
+ For knowledge-base content on Cloud, the canonical path is **UI upload**: Datapack → Actions → **Add Knowledge** (PDF/TXT/MD/JSON/MP4, 5MB each, 10/batch). `knowledgebase_search` queries the resulting index from MCP.
109
102
 
110
103
  ## Common Parameter Patterns
111
104
 
112
- Every tool accepts `scope` as the first parameter. All DB, RAG, and memory tools accept optional `datapack_id` to target a specific datapack's database. Memory and conversation tools require `agent_id` for namespace isolation (see `tools-agent-id-conventions.md`).
105
+ Every tool accepts `scope` as the first parameter. Memory and KB tools accept optional `datapack_id` to target a specific datapack. Memory and conversation tools require `agent_id` for namespace isolation (see `tools-agent-id-conventions.md`).