agentId, channel, KB scope, and peer policy, then searches chunks in that KB. Returned chunks can include compact graph context when includeGraphContext is enabled.
What this means in practice
When you have organized information into a knowledge base (via import or chunking), usecrystal_query_knowledge_base to:
- Retrieve relevant information by semantic meaning (not just keyword match)
- Scope queries to a specific knowledge base
- Filter by agent or channel if the knowledge base supports it
- Limit results to reduce noise and context overhead
- private KBs can stay peer-scoped for coach/client isolation
- shared training KBs can live at
scope: "...:main"withpeerScopePolicy: "permissive" - the backend now supports querying those shared-main KBs from peer-scoped coach sessions when the agent is allowed
Parameters
Returns
Examples
Basic query by name:When to use vs alternatives
Error handling
Source of truth
mcp-server/src/tools/query-knowledge-base.ts— tool definition and HTTP handlerconvex/crystal/knowledgeBases.ts— backend query logicapps/web/app/(dashboard)/knowledge-bases/— KB management UI
Notes
Chunk-level peer scope filter (new in 0.7.15)
Both thequeryKnowledgeBase action and the internal getKBMemoriesInternal path now apply a chunk-level peer scope filter that mirrors the KB-level visibility guard. A permissive shared KB will return its parent-scoped chunks plus chunks explicitly scoped to the requesting peer; cross-peer chunks are dropped. Trailing-colon channels (e.g. peer-coach:) fail closed.
Source-role ranking
Direct KB query searches only the selected KB, but the KB’ssourceRole is still returned so agents can interpret why the source was retrieved. Broad recall also uses that role as a ranking signal; for example a voice_style KB can outrank social artifacts for voice or phrasing questions.