AI & agents
Cogworks gives you two AI building blocks, and is deliberately clear about the boundary:
- MCP server — let AI agents read and write your data (and run admin tasks) safely.
- Vector search — store embeddings and query by similarity for semantic search / RAG.
Agents via MCP
Section titled “Agents via MCP”Cogworks speaks the Model Context Protocol out of the box, so any MCP client — Claude Desktop, Cursor, Continue, Cline — can work against your backend:
- Per-collection tools — every collection automatically exposes
list_ / get_ / create_ / update_ / delete_tools (e.g.cogworks.list_posts), plus admin/introspection tools (describe_collection,run_sql,read_logs,read_audit_log, flags, settings, jobs, …). - Scope-gated — the token’s scopes decide what an agent can touch
(
mcp:read/mcp:write/mcp:admin, and per-collection scopes). Start read-only with--read-onlyand widen deliberately. - Audited — MCP activity is subject to the same audit trail and rate limits as the rest of the API.
- Two transports — stdio (for desktop agents) and HTTP (for remote / multi-user).
cogworks mcp --token cwat_… --read-only{ "mcpServers": { "cogworks": { "command": "cogworks", "args": ["mcp", "--read-only"], "env": { "COGWORKS_MCP_TOKEN": "cwat_…" } } }}Full detail: MCP (AI agents).
Vector search (RAG)
Section titled “Vector search (RAG)”Add a vector field to any collection, write your embeddings to it, and query by
nearest neighbour:
GET /api/v1/docs?nearVector=[0.12,0.03,…]&nearVectorField=embedding&nearLimit=5vectorfield type — a fixed-dimension embedding column (1–4096 dims).nearVectorquery — cosine similarity, ranked, under the same access rules as any other read.- Swappable backend — the ranking sits behind a seam so a faster ANN index can drop in later without changing the query API.
Full detail: Vector search.
Building a RAG feature
Section titled “Building a RAG feature”The end-to-end shape, with the model living on your side:
- Define a collection with a
textfield and avectorfield (matching your embedder’s dimensions). - Embed on write — in a hook or your app, call your embedding provider and store the vector alongside the text.
- Retrieve — embed the user’s query the same way, then
nearVectorto pull the top-k most similar records (rule-filtered, so users only match what they can see). - Generate — feed those records to your LLM as context.
Agents can drive the same collections directly over MCP — so a Claude/Cursor session can search, read, and (with write scope) update your data under the rules you set.