Shared agent context
A user has many agents — some local (Claude Code, OpenCode, Codex), some in the cloud, some in third-party services. They each benefit from sharing the same core materials: the project’s decisions, conventions, constraints, and identifiers. PerSQL Context is one store all of them read and write.
It is the cross-agent extension of Agent memory: durable, structured facts plus a lightweight entity graph, recalled lexically (FTS5, BM25, porter-stemmed). No vectors — agents retrieve by exact tokens, the way they already grep a codebase. The LLM runs on the write path (extracting a raw dump into clean rows), so reads stay cheap and exact.
From the SDK (cloud / programmatic agents)
Section titled “From the SDK (cloud / programmatic agents)”import { PerSQL } from "@persql/sdk";import { context } from "@persql/context";
const persql = new PerSQL({ token: process.env.PERSQL_TOKEN! });const ctx = context(persql.database("acme/team-context"), { source: "my-agent" });
await ctx.init();
await ctx.remember({ topic: "billing", body: "Acme prefers net-30 invoicing", tags: ["billing", "invoice"],});
const hits = await ctx.recall("invoice OR payment"); // BM25-ranked, AI-freeawait ctx.link("api worker", "depends_on", "billing meter");const graph = await ctx.neighbors("api worker", { depth: 1 });Bring your own LLM for the raw-dump path:
const ctx = context(db, { extract: async (raw) => myLlm.extract(raw) });await ctx.rememberRaw("a long conversation or doc…");From a coding agent (the Context MCP)
Section titled “From a coding agent (the Context MCP)”Claude Code, OpenCode, and Codex all speak MCP. One command wires any of them to the same store:
npm install -g @persql/clipersql login # or set PERSQL_TOKEN=psql_live_...persql mcp # stdio MCP server -> context.persql.compersql mcp resolves the store from your git remote (per-repo) — or
--scope user for a store that follows you everywhere — and injects it into
every call. Point your tool at it:
// Claude Code: claude mcp add persql-context -- persql mcp// OpenCode (opencode.json):{ "mcp": { "persql-context": { "type": "local", "command": ["persql", "mcp"] } } }// Codex (~/.codex/config.toml):// [mcp_servers.persql-context]// command = "persql"// args = ["mcp"]Tools: recall, remember, remember_raw, recent, by_tag, link,
neighbors, forget. Extraction (remember_raw) runs server-side and is
metered as AI tokens; everything else is plain SQL — rows read and written.
No vector database
Section titled “No vector database”FTS5 gives lexical, BM25-ranked recall — what most coding agents actually issue. If a workload needs semantic similarity, layer a vector service over these rows and keep the structured source of truth here.
What it costs
Section titled “What it costs”Context is rows like any other — metered on rows read, rows written, and storage, with no per-store or per-memory fee. Reads are plain SQL; only the raw-dump extraction spends AI tokens, and only on write.