All docs

MCP knowledge tools

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

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

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

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.