MCP knowledge tools
Module: apps/mcp/src/tools/knowledge/ Scopes: knowledge:read for search_knowledge, knowledge:write for store_knowledge and supersede_knowledge.
store_knowledge
| Argument | Type | Notes | |
|---|---|---|---|
title | string, 1–200 | ||
body | string, 1–32000 | ||
tags | string[≤16]? | lowercase kebab-case enforced; mixed-case input is normalised | |
confidence | 0..100? | default 80 | |
expiresAt | ISO-8601? | must be strictly in the future | |
taskRef | `{ taskId, kind: 'references' \ | 'produced' }?` | wires a task_knowledge edge |
clientToken | uuid? | 60s idempotence key in Redis (idem:k.store:{org}:{agent}:{token}) |
Body is inserted with source='agent' and created_by_agent_id from the auth context. The embedding generation job runs out-of-band (BullMQ embeddings queue); the response carries embeddingStatus: 'pending'.
Quota: knowledge_stored is checked before insert and incremented after commit.
search_knowledge
| Argument | Type | Notes |
|---|---|---|
query | string, 1–2000 | |
limit | 1..50? | default 10 |
tags | string[≤16]? | lowercased before query |
includeSuperseded | boolean? | default false |
includeExpired | boolean? | default false |
minScore | 0..1? | filter hits with fused score below |
efSearch | 1..200? | HNSW probe width (default 64) |
Hybrid search = pgvector cosine (embedding <=> queryVec) plus tsvector @@ plainto_tsquery('simple', query) plus title ILIKE %query%, fused by RRF (k=60). Returns a snippet (240 chars centred on the first match) — fetch the full body via the task-29 resource read once it lands.
supersede_knowledge
| Argument | Type | Notes |
|---|---|---|
oldId | uuid | will be marked superseded |
newId | uuid | replacement |
Authorisation: the calling agent must own at least one of the two entries. Cross-author supersession requires a future knowledge:write_others scope (not in today's catalogue). Wraps supersedeKnowledge from @drobek/knowledge (task 21) — it handles cycle detection and updates the transitive superseded_by_id cache so search short-circuits stay correct.