These are the HTTP doors for the Knowledge Base shelf.Documentation Index
Fetch the complete documentation index at: https://docs.memorycrystal.ai/llms.txt
Use this file to discover all available pages before exploring further.
What this means in practice
Important endpoint families include:- list/create knowledge bases
- patch knowledge-base metadata and scope policy
- import chunks
- query a knowledge base
- backfill or maintenance-related KB flows
How it actually works
Key repo surfaces:convex/crystal/knowledgeHttp.tsconvex/crystal/knowledgeBases.tspackages/mcp-server/README.md
Endpoint Reference
List Knowledge Bases
GET /api/knowledge-bases
Retrieve all knowledge bases for the authenticated user.
This endpoint is agent/scope aware when you pass query parameters like:
agentIdscope
Create Knowledge Base
POST /api/knowledge-bases
Create a new knowledge base.
Request:
Import Chunks
POST /api/knowledge-bases/:knowledgeBaseId/import
Bulk-import document chunks into a knowledge base.
Request:
- Each chunk is embedded using the same model as memories (text-embedding-3-small)
- Duplicate chunks are deduplicated within the batch
- Deduplication uses SHA256 hash of content
- Failed chunks are logged but don’t block the import
Patch Knowledge Base
PATCH /api/knowledge-bases/:knowledgeBaseId
Update metadata and visibility policy.
Example:
Query Knowledge Base
POST /api/knowledge-bases/:knowledgeBaseId/query
Vector search a knowledge base by semantic query.
Request:
Chunk-level peer scope filter (new in 0.7.15). Both the
queryKnowledgeBase action and the internal KB-chunk reader 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 and return no chunks.query(required): The semantic query stringlimit(optional): Maximum results to return (default: 10, max: 50)threshold(optional): Minimum relevance score 0–1 (default: 0.0, all results)agentId(optional): Agent visibility contextchannel(optional): Channel/scope context
Usage Patterns
Example 1: Import API Documentation
Example 2: Query Documentation Before Response
In an agent workflow:Scope and Tenancy
Knowledge bases are:- Per-user — isolated by userId from authentication token
- Agent/scope aware — visibility can differ for peer-scoped vs shared-main agent lanes
- Persistent — survive session restarts
Shared-main KB pattern
To make one training KB available to many agents/chats under one key:- set
scopeto something likepeer-team:main - set
peerScopePolicyto"permissive" - include all allowed agent IDs in
agentIds
- keep
agentIds: ["coach"] - do not move them to a shared
:mainscope
Common mistakes
- documenting KB endpoints without mentioning their relationship to the MCP KB tools
- assuming imported data is the same as conversational memory
- ignoring scope and tenancy when describing KB behavior
Source of truth
Primary files behind this page:convex/crystal/knowledgeHttp.tsconvex/crystal/knowledgeBases.tspackages/mcp-server/README.md