SochDB for Coding Agents
SochDB is an agent-native database. Instead of stitching together a vector store, a relational database, and a hand-rolled prompt packer, an agent gets one embedded-or-served engine that does vector search (HNSW), SQL, key-value, graph and temporal edges, semantic cache, and token-budgeted agent memory — all with ACID transactions.
This guide shows two ways to put SochDB in front of a coding agent or LLM:
- The
sochdb-mcpserver — a Model Context Protocol server that exposes SochDB's tools and resources to clients like Claude Desktop, Cursor, and Goose over stdio. - The SochDB Agent Skill — a portable instruction bundle that teaches an agent how to install, connect, store, and retrieve with SochDB through the SDK.
This page targets core engine 2.0.3 (the sochdb-mcp binary). The language
SDKs version independently: Python 0.5.9, Node.js 0.5.3, Go 0.4.5.
The sochdb-mcp server is part of the core engine and is
AGPL-3.0-or-later (commercial licensing available). The language SDKs
(Python, Node.js, Go) are Apache-2.0. The Agent Skill bundle shipped with
these docs is Apache-2.0.
What the MCP server is
sochdb-mcp is a small, framework-free Model Context Protocol
server. It speaks JSON-RPC with Content-Length framing over stdio and makes
direct embedded calls into SochDB — there is no separate database process or
network hop. When the server starts it opens an on-disk SochDB at the path you
give it (default ./sochdb_data) and serves tools and resources from that store.
- Protocol version:
2024-11-05. - Transport: stdio. All logs go to stderr; stdout is reserved for the protocol stream.
- Capabilities advertised on
initialize:toolsandresources. There are no MCPprompts.
The bundled mcp.json manifest and the server's README.md document an older,
dot-named catalog (sochdb.query, memory.search_episodes). Those are
stale. The tools the server actually exposes use underscores
(sochdb_query, memory_search_episodes, ...). The lists below are the real,
shipped names taken from the server source.
Build and run the server
Build the standalone binary from the SochDB workspace:
cargo build --release --package sochdb-mcp
# -> target/release/sochdb-mcp
Run it against a database directory (it is created if it does not exist):
sochdb-mcp --db ./agent_db
The only flag is --db <path> (default ./sochdb_data). For verbose logging to
stderr, set RUST_LOG:
RUST_LOG=sochdb_mcp=debug sochdb-mcp --db ./agent_db
You can smoke-test the protocol by piping a single JSON-RPC request to stdin:
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | sochdb-mcp --db ./test_data
Because the server opens the database in-process, point each MCP client at its
own --db directory unless you intentionally want them to share one. The
store is a local file/directory, so the same single-writer rules apply as for any
embedded SochDB connection.
Wire it into your client
Every config below points the client at the compiled sochdb-mcp binary and a
data directory. Use absolute paths — MCP clients do not resolve relative
paths against your shell's working directory.
- Claude Desktop
- Cursor
- Goose
Add a sochdb entry to claude_desktop_config.json (under
~/Library/Application Support/Claude/ on macOS):
{
"mcpServers": {
"sochdb": {
"command": "/absolute/path/to/target/release/sochdb-mcp",
"args": ["--db", "/absolute/path/to/agent_db"],
"env": { "RUST_LOG": "info" }
}
}
}
Restart Claude Desktop. The sochdb_* tools and sochdb:// resources appear in
the client.
Add the same server block to .cursor/mcp.json in your project (the env key is
optional):
{
"mcpServers": {
"sochdb": {
"command": "/absolute/path/to/target/release/sochdb-mcp",
"args": ["--db", "/absolute/path/to/agent_db"]
}
}
}
Goose uses a flat stdio extension entry:
{
"name": "sochdb",
"type": "stdio",
"command": "/absolute/path/to/target/release/sochdb-mcp",
"args": ["--db", "/absolute/path/to/agent_db"],
"timeout": 300,
"env": {}
}
The sample files shipped in the sochdb-mcp/ directory
(mcp-claude-desktop.json, mcp-cursor.json, mcp-goose.json) hardcode an
absolute path from the author's machine. Copy the shape, then replace command
and the --db argument with paths on your system.
Tools the server exposes
All tools default to compact TOON output and can
return JSON when you pass format: "json".
Core database tools
| Tool | Purpose | Key args |
|---|---|---|
sochdb_context_query | Fetch AI-optimized context with token budgeting; sections packed in priority order | sections[], token_budget (default 4096), format, truncation |
sochdb_query | Run a SochQL query through a hardened, prefix-bounded parser | query, format, limit (default 100) |
sochdb_get | Get the value at a path | path |
sochdb_put | Set the value at a path (commits and double-fsyncs) | path, value |
sochdb_delete | Delete the value at a path | path |
sochdb_list_tables | List tables with semantic metadata | include_metadata (default true) |
sochdb_describe | Detailed schema for one table | table |
sochdb_query parses queries through a hardened parser that enforces
prefix-bounded scans and table-name validation. This keeps a tool call from
walking the whole database or reaching another tenant's keys.
Memory tools
These operate over SochDB's episode / entity / event schema — the same data the Agent Memory SDK writes.
| Tool | Purpose | Key args |
|---|---|---|
memory_search_episodes | Similarity search over episodes | query, k (default 5), episode_type, entity_id |
memory_get_episode_timeline | Event timeline for one episode | episode_id, max_events (default 50), role, include_metrics |
memory_search_entities | Search entities | query, k (default 10), kind |
memory_get_entity_facts | Facts about an entity | entity_id, include_episodes (default true), max_episodes (default 5) |
memory_build_context | One-shot, token-budgeted context packing for a goal | goal, token_budget (default 4096), session_id, episode_id, entity_ids[], include_schema |
Log tools
| Tool | Purpose | Key args |
|---|---|---|
logs_tail | Last N rows of a log table, most recent first | table, limit (default 20), where, columns[] |
logs_timeline | Events in a time range for an entity | entity_id, from_ts, to_ts (microseconds since epoch), limit (default 100), table (default events) |
Agentic search tools
SochDB's agentic search exposes three line-oriented tools backed by an in-memory corpus with a trigram index, giving sublinear, line-anchored hits — handy when an agent is grepping over ingested documents.
| Tool | Purpose | Key args |
|---|---|---|
sochdb_grep | Indexed grep with line-anchored hits | pattern, scope (doc-id prefix filter), limit (default 50) |
sochdb_peek | Read a line range from a document | doc_id, start_line, end_line |
sochdb_expand | Expand plus/minus N lines around a hit | doc_id, line, window (default 5) |
A semantic-search Cargo feature plus the env var SOCHDB_SEMANTIC_SEARCH=1
will load an embedding model (AllMiniLML6V2). Even when enabled, the actual
vector search path is currently disabled in code (embeddings are generated but
the vector backend is not wired in yet), so memory_search_* falls back to a
keyword / text scan. Treat memory search as lexical for now.
Resources and views
The server also exposes SochDB content as MCP resources, so a client can read schema and pre-shaped views without issuing a tool call.
resources/listenumerates every table assochdb://tables/<name>, annotated with semantic metadata:role,primaryKey,clusterKey,tsColumn,backedByVectorIndex, andembeddingDimension.resources/readserves two URI shapes:sochdb://tables/<name>— a table's rows and schema.sochdb://views/<name>— a predefined view.
The predefined views are:
| View URI | What it shows |
|---|---|
sochdb://views/conversation_view | Conversation history |
sochdb://views/tool_calls_view | Tool-call records |
sochdb://views/error_view | Errors |
sochdb://views/episode_summary_view | Episode summaries |
sochdb://views/entity_directory_view | Entity directory |
Resource output is text/x-toon by default, or application/json when the
client requests format=json. Well-known memory tables (episodes, events,
entities) carry richer metadata — for example, episodes and entities
advertise backedByVectorIndex=true with embeddingDimension=1536.
A typical agent loop over MCP
Once the server is registered, an agent works with SochDB entirely through tool calls. A common pattern:
- Discover the schema —
sochdb_list_tables(or readsochdb://tables/<name>resources). - Store facts —
sochdb_putfor KV state, or write episodes via the Agent Memory SDK somemory_search_episodescan find them later. - Retrieve under a budget —
sochdb_context_queryormemory_build_contextto pack relevant context into the prompt within atoken_budget. - Search code/docs —
sochdb_grepto find hits, thensochdb_peek/sochdb_expandto pull just the surrounding lines.
A minimal memory_build_context request looks like this:
{
"jsonrpc": "2.0",
"id": 7,
"method": "tools/call",
"params": {
"name": "memory_build_context",
"arguments": {
"goal": "What does the user prefer for code style?",
"token_budget": 2048,
"include_schema": false
}
}
}
The SochDB Agent Skill
Not every agent runs MCP. For agents that call the SDK directly (or for clients that load skills rather than tools), SochDB ships an Agent Skill — a single instruction file that teaches an agent the full install → connect → store → retrieve workflow with correct, current API names.
The bundle lives with these docs at
/agent-skill/SKILL.md. It covers:
- When to use SochDB — agent memory, vector/semantic search, RAG storage, or one local store for structured data plus embeddings plus chat history.
- Install —
pip install sochdb,npm install @sochdb/sochdb,go get github.com/sochdb/sochdb-go,cargo add sochdb. - Connect — embedded (a filesystem path) vs. server (gRPC
host:port, default50051). - Core operations — KV plus transactions, the KV-backed SQL subset, vector search, and the headline agent memory API.
- MCP wiring — the same
sochdb-mcpsetup and underscore tool names described above. - Guardrails — use exact API names;
scan_prefixneeds a>= 2-byte prefix; and an honest list of features that are not fully shipped.
To use it, drop SKILL.md into your agent's skills/instructions directory (for
example, an Anthropic Skill bundle, a Cursor rules file, or a system-prompt
include). The file is self-contained and version-stamped.
The skill encodes the same non-negotiable facts as this site — versions, the split license, underscore MCP tool names, and the "do not over-claim" guardrails. If you fork it, update both together so an agent never learns a stale API name.
Honest limits to teach your agent
So your agent does not promise features that are not shipped, keep these straight:
- MCP tool names use underscores (
sochdb_query, notsochdb.query). The dot-named catalog inmcp.json/ README is stale. MultiShardHnswIndexis a Python-only convenience (a threaded scatter-gather wrapper in the native package), not a core-engine or server feature.- Semantic vector search in the MCP server is not yet wired — memory search falls back to lexical scan (see the caution above).
- At-rest encryption (AES-256-GCM-SIV) exists as a library API but is not wired to a server CLI flag yet.
- The Postgres-wire endpoint has no auth (cleartext, simple-query, loopback only) — never expose it.
Next steps
- MCP integration recipe — a step-by-step
walkthrough of running
sochdb-mcpand connecting each client. - Agent Memory — write episodes and
entities that the
memory_*MCP tools retrieve. - Token-Aware Context Query — the budgeting that
sochdb_context_queryandmemory_build_contextuse. - Python SDK — the flagship SDK an agent calls directly.
- Deploying to Production — run the gRPC server when an agent needs a shared, served database.