The memory your LLM pretends to have.
ctx is a self-hosted knowledge store for LLM agents. Your agent saves what it learns as small blocks; ctx finds them again by meaning, by wording and by time — and keeps cross-linking them in the background while nobody is asking.
What it does
Store a finding once, get it back when it matters. A query runs semantic search, English and German fulltext and trigram matching side by side and fuses the rankings. Then time weighs in: every block carries the dates it talks about and the date it was written, so “the meeting on Tuesday” is found by either.
Dream Mode runs as a continuous background loop. It discovers relations between blocks, marks information that newer blocks supersede and promotes what holds up — the store organises itself instead of silting up.
Agents reach ctx over MCP, a CLI or plain HTTP. An embedded web UI covers settings, the knowledge graph, the corpus and chat. Multiple tenants are isolated down to the single block.
How it works
Four ways in, one Go daemon, PostgreSQL 18 with pgvector underneath. The diagram follows a block from storing to retrieval, through the topic map and the Dream loop.
What is inside
- 4-way rank fusion
- Semantic, English fulltext, German fulltext and trigram rankings merged by reciprocal-rank fusion, weighted per block type.
- Cyclic temporal gravity
- Seven cycles, each with its own Gaussian decay. Queries like “every Tuesday” or “at Christmas” activate the cycle they name.
- Dream Mode
- Autonomous cross-referencing and supersede detection with parallel, race-safe workers.
- Block types
- A declarative registry decides per type how blocks are retrieved, deduplicated, dreamed over and digested — reloadable without a restart.
- Multi-tenancy
- Tenant, scope and block isolation with grants, quotas and self-service onboarding.
- Issues and forge sync
- A per-project issue corpus with a kanban board, validated status transitions and two-way GitHub sync.
- Sealed secrets
- Provider credentials encrypted with AES-256-GCM; outbound calls gated by trust and sensitivity.
- Any model backend
- OpenAI-compatible APIs, Ollama or the Anthropic Messages API. Runs on CPU; a GPU shortens chat latency.
Install
Download the binary for your platform, check that this repository’s release workflow built it, then install it:
f=ctx-$(uname -s | tr A-Z a-z)-$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
tmp=$(mktemp -d)
curl -fsSL "https://github.com/GottZ/ctx/releases/latest/download/$f" -o "$tmp/$f" \
&& gh attestation verify "$tmp/$f" -R GottZ/ctx \
&& install -m 0755 "$tmp/$f" /usr/local/bin/ctx
Or build it with Go:
go install github.com/GottZ/ctx/cmd/ctx@latest
Then point the CLI at your server. ctx init asks for the URL and an API key, checks both before saving anything, and sets up the Claude Code hooks:
ctx init
The server itself — the Go daemon plus PostgreSQL 18 with pgvector — starts with docker compose up -d ctx. Every release ships signed build provenance; see the latest release.
How an agent uses it
Five primitives. The same operations exist as MCP tools, so agents in Claude Code or claude.ai call them without shell quoting.
| To | Run |
|---|---|
| Answer from stored knowledge | ctx query "question" |
| Save a finding | ctx save <category> <title> - <content> |
| Replace a block | ctx save with the same category and title |
| Browse without an LLM call | ctx search [category] [query:text] |
| Open one block | ctx get <block-id> |
Documentation
- Architecture retrieval pipeline, temporal model, Dream Mode, block types, backend pool
- Operations setup, environment, backups, upgrades and migrations
- HTTP API endpoints, graph, settings, backends
- MCP reference every tool, its parameters and its answers
- CLI reference every
ctxsubcommand - Multi-tenancy tenants, scopes, grants, quotas
- Security admin tier, sealed secrets, egress gating
- Using ctx effectively memory drift and agent discipline
Get involved
- Ask or give feedback
- Questions go to Q&A, feature ideas and design feedback to Ideas, everything else to Discussions.
- Report a bug
- Open an issue with the version (
ctx version), how ctx runs, and the exact commands and output. Open bugs are listed under the bug label. - Report a vulnerability
- Privately, through a GitHub security advisory — never in a public issue. The security policy says what to include and what happens next.
- Contribute code
- The contributing guide covers forking, the git hooks, tests, commit messages, the coding standards CI enforces and how review works; build and test details are in the development docs. Issues labelled good first issue are a place to start.
Built with AI agents
ctx is built by AI agents working against a published calibration: a map of 22 ways LLMs fail at long-running work — memory drift, unattributed certainty, median-user caution — each with real examples. Read the warnings, or the long history of the project in the ctx compendium.