@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
@@ -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 the session-injected `agent_id` for project-scoped calls, 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`).
@@ -1,19 +1,16 @@
1
1
  # Knowledge Base / RAG workflow
2
2
 
3
- As of 2026-05-07, **knowledge-base ingestion on cloud Meko is a UI-only activity**. The MCP ingestion tools exist but are gated off on cloud and rely on an S3-only worker that has no mechanism to read user-supplied buckets. `knowledgebase_search` is the only KB tool agents can rely on today.
4
-
5
- This page tells you which tool to reach for, what's usable where, and where the current gaps are tracked.
3
+ `knowledgebase_search` is the only KB tool exposed via MCP. Index
4
+ creation and ingestion happen out of band — through the **Meko UI**
5
+ (`cloud.mekodata.ai`).
6
6
 
7
7
  ## Decision table
8
8
 
9
9
  | Situation | Use this | Why |
10
10
  |---|---|---|
11
- | Search an existing KB | `knowledgebase_search` | The one KB tool that works on cloud Free Tier and prod today |
12
- | Add documents to a KB on cloud | **Meko UI** — Datapack → Actions menu → **Add Knowledge** | File-upload dialog (PDF/TXT/MD/JSON/MP4, 5MB each, 10/batch). The MCP ingestion path is not usable on cloud |
13
- | Create a new vector index (self-hosted / paid) | `knowledgebase_trigger_index_creation` | Only works when the ingestion worker has IAM access to the S3 bucket you pass |
14
- | Add a source to an existing index (self-hosted / paid) | `knowledgebase_add_source_to_index` | Same caveat as above |
15
- | Poll a build (self-hosted / paid) | `knowledgebase_check_index_status` | Gated on cloud Free Tier |
16
- | Anything that needs KB lifecycle management (list, delete, rename) | **UI** | No MCP tools for KB lifecycle |
11
+ | Search an existing KB | `knowledgebase_search` | The one KB tool exposed via MCP |
12
+ | Add documents to a KB | **Meko UI** — Datapack → Actions → **Add Knowledge** | File-upload dialog (PDF/TXT/MD/JSON/MP4, 5 MB each, 10/batch). No MCP equivalent |
13
+ | Anything else (list / delete / rename / re-index) | **UI** | No MCP tools for KB lifecycle |
17
14
 
18
15
  ## knowledgebase_search — the one you'll actually call
19
16
 
@@ -27,60 +24,16 @@ knowledgebase_search(
27
24
  limit=10)
28
25
  ```
29
26
 
30
- Required: `scope`, `query`, `agent_id`, `conversation_id`, `datapack_id`. Unlike the memory tools, `datapack_id` has no default here — you must pass it explicitly. `agent_id` is **ignored for filtering** on this tool (KB results are team-shared on the datapack), but you still pass it — your session's value is fine.
31
-
32
- Response shape (verified 2026-05-07 against prod):
33
- ```
34
- {"results": [], "count": 0}
35
- ```
36
-
37
- On a populated KB each result carries chunk content and similarity scores. On an empty or nonexistent KB you get an empty array and `count: 0` — not an error.
38
-
39
- ## MCP ingestion tools — what actually happens when you call them
40
-
41
- This applies to `knowledgebase_trigger_index_creation` and `knowledgebase_add_source_to_index`. Understanding the two-layer architecture is the only way to predict whether a call will succeed.
42
-
43
- **MCP layer (`src/tools.py`):** takes `source_uris`, splits on `,`, passes each string to `dist_rag.create_source(<uri>)` with **zero validation**. No scheme check, no reachability probe. Returns `"build_triggered"` immediately.
44
-
45
- **Worker layer (`yugabyte-db/python/ai/rag_agent/rag_pipeline/aws_source_processor.py`):** only handles `s3://` URIs. Any other scheme raises `ValueError("Invalid source URI")` inside the worker — **async, never surfaced to the MCP caller**. The S3 crawler is instantiated with no credentials; it relies on boto3's default chain (env vars, IAM role, `~/.aws/credentials` on the worker host). So the worker can only read buckets its own AWS identity has access to.
46
-
47
- **Implication:** pointing the MCP tool at a user-owned S3 bucket from cloud will return `"build_triggered"` and silently stall at INIT forever. There is no way for the user to supply AWS credentials through the MCP tool.
48
-
49
- ## Free-Tier cloud gating (verified 2026-05-07 against `https://mcp.mekodata.ai/mcp`)
50
-
51
- | Tool | Verbatim response |
52
- |---|---|
53
- | `knowledgebase_trigger_index_creation` | `{"error": "not_available", "detail": "Vector index creation is not available on the free tier."}` |
54
- | `knowledgebase_add_source_to_index` | Same as above |
55
- | `knowledgebase_check_index_status` | `{"error": "not_available", "detail": "Index status check is not available on the free tier."}` |
56
- | `knowledgebase_search` | Works: `{"results": [], "count": 0}` |
57
-
58
- `{"error": "not_available"}` is a server-side tier block. Don't retry.
59
-
60
- ## UI ingestion (cloud Meko) — what the user sees
61
-
62
- From `cloud.mekodata.ai`:
63
-
64
- 1. Open a datapack (`/datapacks/<name>`).
65
- 2. Click **Actions** → **Add Knowledge**.
66
- 3. Drag-and-drop or browse for files. Supported: PDF, TXT, MD, JSON, MP4. Per-file limit 5 MB. Up to 10 files per batch.
67
- 4. The UI handles upload, storage, and index build. The user does not pick a bucket or provide credentials.
68
- 5. Search results from `knowledgebase_search` become available once indexing completes.
69
-
70
- If a user asks you "how do I add a document to my knowledge base?", point them at this flow. Do not suggest `knowledgebase_trigger_index_creation` with an S3 URI — on cloud that path does not work.
27
+ Required: `scope`, `query`, `agent_id`, `conversation_id`, `datapack_id`.
28
+ Unlike the memory tools, `datapack_id` has no default here — you must
29
+ pass it explicitly. `agent_id` is **ignored for filtering** on this
30
+ tool (KB results are team-shared on the datapack), but you still pass
31
+ it — your session's value is fine.
71
32
 
72
- ## Tracked gaps
73
-
74
- - **Upstream GitHub**: [yugabyte/meko-mcp-server#89](https://github.com/yugabyte/meko-mcp-server/issues/89) — disable or gate KB ingestion tools on cloud until the S3 path works end-to-end; return a clearer error than "not_available"; validate schemes at MCP-call time.
75
- - **Upstream Jira**: MEKO-96 (same issue, cross-linked).
76
-
77
- When either lands, the free-tier-gate responses above will change and this page should be revisited.
78
-
79
- ## Response-shape reference (for agents that need to parse)
80
-
81
- ### knowledgebase_search
33
+ ## Response shape
82
34
 
83
35
  Populated KB:
36
+
84
37
  ```
85
38
  {
86
39
  "results": [
@@ -97,38 +50,21 @@ Populated KB:
97
50
  }
98
51
  ```
99
52
 
100
- Empty or nonexistent KB: `{"results": [], "count": 0}` (no error).
101
-
102
- ### knowledgebase_trigger_index_creation (when not gated)
103
-
104
- Success shape:
105
- ```
106
- {
107
- "source_ids": ["<uuid>", ...],
108
- "index_id": "<uuid>",
109
- "index_name": "<name>",
110
- "status": "build_triggered",
111
- "message": "N source(s) registered, index '...' initialised, and build triggered."
112
- }
113
- ```
114
-
115
- Do NOT retry this on failure. Each call creates a new index.
116
-
117
- ### knowledgebase_add_source_to_index (when not gated)
118
-
119
- The historical `r_index_name` vs `r_index_id` parameter-mismatch bug is fixed on main (`src/tools.py` resolves `index_name → index_id` via `SELECT id FROM dist_rag.vector_indexes WHERE index_name = %s` before calling the dist_rag function). If `index_name` doesn't exist you get `{"error": "index_not_found", "detail": "No vector index found with name '...'"}`.
120
-
121
- Param is `source_uri` (URI string like `s3://bucket/path/`), **not** `source_id` as older docs may claim.
53
+ Empty or nonexistent KB: `{"results": [], "count": 0}` (no error,
54
+ just an empty array).
122
55
 
123
- ### knowledgebase_check_index_status (when not gated)
56
+ ## UI ingestion — what the user sees
124
57
 
125
- Returns `pipeline_details` (per-document status) and `pipeline_stats` (aggregated). Check `completion_rate_percent` in `pipeline_stats` and `document_status` in `pipeline_details`.
126
-
127
- Stuck at INIT for >5 minutes under self-hosted usually means the worker couldn't reach the bucket — check AWS credentials on the worker host, not the MCP server.
128
-
129
- ## Prerequisites (self-hosted)
58
+ From `cloud.mekodata.ai`:
130
59
 
131
- - `dist_rag` PostgreSQL extension enabled on the target YugabyteDB database
132
- - Ingestion workers running (`yugabyte-db/python/ai/rag_agent/`)
133
- - AWS credentials on the worker host for any S3 bucket you intend to ingest from
134
- - `datapack_id` passed on every call when targeting a non-default datapack
60
+ 1. Open a datapack (`/datapacks/<name>`).
61
+ 2. Click **Actions** → **Add Knowledge**.
62
+ 3. Drag-and-drop or browse for files. Supported: PDF, TXT, MD, JSON,
63
+ MP4. Per-file limit 5 MB. Up to 10 files per batch.
64
+ 4. The UI handles upload, storage, and index build. The user does not
65
+ pick a bucket or provide credentials.
66
+ 5. Search results from `knowledgebase_search` become available once
67
+ indexing completes.
68
+
69
+ If a user asks you "how do I add a document to my knowledge base?",
70
+ point them at this flow.
@@ -1,6 +1,6 @@
1
1
  # Scope Permission Hierarchy and Per-Tool Requirements
2
2
 
3
- **WRONG:** `db_run_write_query(scope="read", ...)` → PermissionError: requires 'write' or higher.
3
+ **WRONG:** `memory_add(scope="read", ...)` → PermissionError: requires 'write' or higher.
4
4
  **WRONG:** `memory_delete_all(scope="write", ...)` → PermissionError: requires 'admin'.
5
5
 
6
6
  ## Scope Hierarchy
@@ -17,13 +17,11 @@ Higher scopes include lower scopes. An unrecognized scope string always fails.
17
17
 
18
18
  ## Per-Tool Requirements
19
19
 
20
- ### read scope (11 tools)
20
+ ### read scope (9 tools)
21
21
 
22
22
  | Tool | Group |
23
23
  |------|-------|
24
- | `db_summarize_database` | Database |
25
- | `db_run_read_only_query` | Database |
26
- | `knowledgebase_check_index_status` | RAG |
24
+ | `knowledgebase_search` | RAG |
27
25
  | `memory_search` | Memory |
28
26
  | `memory_get_by_id` | Memory |
29
27
  | `memory_get_all` | Memory |
@@ -33,13 +31,10 @@ Higher scopes include lower scopes. An unrecognized scope string always fails.
33
31
  | `datapack_list` | Datapack |
34
32
  | `datapack_describe` | Datapack |
35
33
 
36
- ### write scope (11 tools)
34
+ ### write scope (9 tools)
37
35
 
38
36
  | Tool | Group |
39
37
  |------|-------|
40
- | `db_run_write_query` | Database |
41
- | `knowledgebase_trigger_index_creation` | RAG |
42
- | `knowledgebase_add_source_to_index` | RAG |
43
38
  | `memory_add` | Memory |
44
39
  | `memory_update` | Memory |
45
40
  | `memory_delete_by_id` | Memory |
@@ -48,6 +43,7 @@ Higher scopes include lower scopes. An unrecognized scope string always fails.
48
43
  | `conversation_update` | Conversation |
49
44
  | `datapack_create` | Datapack |
50
45
  | `datapack_update` | Datapack |
46
+ | `track_token_usage` | Observability |
51
47
 
52
48
  ### admin scope (3 tools — destructive, irreversible)
53
49
 
@@ -13,7 +13,7 @@ These patterns are extracted from real agent sessions. Follow them to avoid wast
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,73 +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
29
  ## Scope parameter errors
92
30
 
93
31
  **Error:** `Insufficient scope: 'all'. This tool requires 'read' or higher.`
@@ -124,21 +62,6 @@ Pre-existing data may be tagged `"agent"`, `"claude_code"`, `"cursor:<slug>"`, o
124
62
 
125
63
  ---
126
64
 
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
65
  ## Safe-to-retry vs not
143
66
 
144
67
  | Tool | Safe to retry? | Why |
@@ -147,9 +70,6 @@ Pre-existing data may be tagged `"agent"`, `"claude_code"`, `"cursor:<slug>"`, o
147
70
  | `memory_add` | Yes (once) | Mem0 has dedup logic |
148
71
  | `memory_update` | Yes (once) | Overwrites same ID |
149
72
  | `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
73
  | `conversation_create` | **No** | Creates duplicate conversations |
154
74
  | `conversation_add_message` with `seed` | Yes | Seed-based dedup prevents duplicates |
155
75
  | `conversation_add_message` without `seed` | **No** | Creates duplicate messages |