kontexta
Kontexta is a local-first MCP server that gives AI coding agents a persistent, git-backed knowledge vault, a sandboxed command engine, and a feedback/journaling loop for cross-agent collaboration and context-aware workflows.
π§ Brain β Knowledge Management
Create, read, update, delete, move, and batch-manage Markdown files in a git-backed vault (up to 500 files per call)
Surgical section editing (
read_section,update_file_section) to modify a single heading without touching the restFull-text search (SQLite FTS5), regex search,
grep-in-file, file outline inspection, and partial line readsTagging (add, remove, suggest, bulk-apply), favorites, folder management, and rich file metadata
Web clipping β fetch external URLs, extract main content via Readability, save as markdown (
clip_url)Vault overview, stats dashboard, recency feed (
whats_new), and index health diagnostics (diff_against_disk,refresh_index)Token-aware responses with
est_tokensandsize_byteson every tool call
π Git Integration
Commit and push KB data to a remote backup (
commit_backup)View file history, diff between commits, and restore files to any previous version
π€ Project & Agent Management
Register projects to link a local codebase to the KB and index its markdown files
Onboard AI agents (Claude, Cursor, Gemini, etc.) by injecting standardized workflow rules into
CLAUDE.md,.cursor/rules,AGENTS.md, etc.Switch agents mid-project without losing context; share knowledge across agents and projects
ποΈ Hands β Sandboxed Command Execution
Define per-project shell commands in
kontexta.jsonwith explicit boundaries, locked working directory, and hard timeoutsCommands validated against ReDoS-proof regex and run with stripped PATH
Optional human-in-the-loop approval for high-risk commands via single-use cryptographic tokens
ποΈ Eyes β Feedback & Journaling Loop
Automatically logs all MCP tool calls to a per-project event log
journal_noteandjournal_intentrecord decisions and topic pivotsdistill_journalconsolidates raw events into searchable markdown summaries for compounding intelligenceJournal status checks, retention policies, and archival via
housekeep_journal
π₯οΈ Dashboard
Web UI (via Docker) with a tool catalogue,
kontexta.jsoneditor, and real-time git activity stream, protected by a master password
Provides an optional Docker-based web UI for visual knowledge base management.
Allows pushing knowledge base changes to a remote Git repository via the commit_backup tool.
Supports GitHub Copilot by injecting agent rules and providing MCP tools for knowledge management.
Kontexta is a local-first Model Context Protocol (MCP) server that gives your AI coding agents β Claude Code, Cursor, Cline, GitHub Copilot, Gemini, Antigravity β a persistent memory and a controlled command surface. Learn more at kontexta.dev
Instead of agents losing context between sessions or inventing their own shell commands, Kontexta provides:
Brain: A git-backed markdown vault with FTS5 search and surgical section edits.
Hands: A sandboxed command engine defined by you in
kontexta.json.Eyes: A feedback loop that journals results back into the brain.
The Unique Value
Most AI tools trap context inside their own chat window. Kontexta moves that context to your own SSD, providing six core advantages:
1. Cross-Agent Handoff
Switch agents mid-project: Claude Code journals a decision; Cursor reads it 5 minutes later.
Unified command surface: Author your
kontexta.jsononce; every agent uses the same validated tools and approval gates.Multi-agent collaboration: Different agents working on different tasks contribute to the same indexed knowledge base.
Zero-touch onboarding:
register_project+onboard_agentinjects a fenced, version-stamped workflow rules block intoCLAUDE.md/AGENTS.md/GEMINI.md/.cursor/rules/.continue/rules/.clinerules/.github/copilot-instructions.mdso every new conversation β on any agent β wakes up already knowing how to use kontexta.
2. Cross-Project Awareness
Global reach: An agent working in Project A can instantly search and read the documentation, context, and states of Project B.
Shared standards: Solve a problem once, document it, and let your agent apply that solution across all your other projects automatically.
Heads-up on sensitivity: Because the vault is global, every registered project is readable by any agent session you start. If you mix client work with personal projects, keep sensitive material in a separate vault (
KONTEXTA_DATA_DIR) rather than registering it alongside everything else.
3. Deterministic Context Retrieval
SQLite FTS5 Power: Instead of unpredictable vector-based RAG, Kontexta uses high-performance full-text indexing for deterministic, local-first context discovery.
Reliable Discovery: Fast, exact keyword and regex-based search ensures you find what you're looking for without the "hallucination" risk of third-party embedding providers.
4. Token-Optimized Context Economy
Surgical fetching: Instead of indiscriminately dumping whole directories into the LLM's context window, Kontexta provides tools to fetch specific file outlines, sections, or targeted search excerpts.
Budget awareness: Every tool response includes
est_tokensso agents can smartly budget what they pull into memory.
5. Separation of Code and Context
The "Context.md" Killer: Stop littering your source tree with
CONTEXT.mdorAI_NOTES.mdfiles that clutter your PRs and get stale.Global Knowledge Vault: Keep your main codebase pristine. Architectural decisions, agent journals, and cross-project standards live in a separate, dedicated global vault accessible by any agent instance.
6. Compounding Intelligence
Continuous learning: Through the "Eyes" and journaling system, your AI agents document their decisions, successes, and mistakes.
Smarter next time: A problem solved today is saved in the Brain, meaning tomorrow's session starts with the benefit of yesterday's experience.
Related MCP server: MindOS
Architecture: Brain β Hands β Eyes
Kontexta builds a closed feedback loop that makes every turn smarter than the last.
1. Brain β The Context Engine
A markdown knowledge vault optimized for context-window economy.
FTS5 Search: Instant local keyword search.
Surgical Edits: Tools for reading and updating specific markdown sections without pulling entire files.
Token-Aware: Every response includes
est_tokensandsize_bytesso agents can budget their context.
2. Hands β The Command Engine
A project-defined command surface that replaces "unrestricted shell access" with a sandboxed contract.
Explicit boundaries: You declare exactly what an agent can do via
kontexta.json. There is no unrestricted shell access.Sandboxed: Locked working directory, clean environment, and ring-buffered output.
Human-in-the-loop: High-risk commands can require a cryptographic one-time token, pausing execution until you explicitly approve it.
The sandbox enforcesyour contract β it doesn't infer risk on its own. A command only requires approval if you mark it high-risk in kontexta.json; anything else runs unattended within the sandbox. Treat kontexta.json like a permissions file: the security posture is exactly as careful as your authorship of it.
3. Eyes β The Feedback Engine
Closes the loop by capturing Hands' output and journaling learnings back into the Brain.
Live Observation: Tools like
whats_newanddiff_against_disklet agents see what actually changed.Automatic journaling: Every MCP tool call is captured to a per-project, append-only event log (Layer 1). The
distill_journaltool β or the lenient-mode auto-fallback β collapses raw events into per-topic markdown summaries (Layer 2) indexed alongside the rest of the knowledge base.journal_noteandjournal_intentlet agents enrich the log with decisions and topic pivots. Phase 2 also addshousekeep_journal(retention/archival),distill_journal_commit_upgrades(closes the subagent dispatch loop), strict mode (configurable per project β blocks read tools when backlog exists), and an opt-in WebUI scheduler that runs mechanical distillation on a 15-minute clock when the dashboard is installed. Learn more about Journaling modes and configuration in docs/JOURNAL.md.
How it Works in Practice
Imagine you are switching from Claude Code to Cursor mid-way through a feature.
The Problem: The "Context Gap"
Claude Code knows why you chose that specific library.
Cursor doesn't. You have to copy-paste or re-explain everything.
CONTEXT.md files help, but they get stale, they clutter your PRs, and they don't capture live decisions.
The Kontexta Solution
Journaling: As Claude Code works, kontexta automatically captures every tool invocation and decision to a structured event log.
Persistence: Those logs are saved in your local Kontexta brain, not the chat window. The
distill_journaltool consolidates raw events into per-topic markdown entries that are searchable alongside your knowledge base.Seamless Handoff: When you open Cursor, it immediately sees the recent journal entries and architectural state via the Kontexta MCP.
Zero Re-explanation: Cursor "wakes up" with the exact same context Claude had.
How Kontexta Compares
Kontexta doesn't try to replace your favorite agent or memory library β it sits in a different spot. Here's an honest read of where it overlaps and where it doesn't:
Capability |
| Vendor memory (Cursor rules, Claude Projects) | mem0 | Zep | Kontexta |
Setup cost | None β just a file | None β built in | SDK integration in your app | SDK + service | MCP server + |
Cross-agent portability | Per-agent flavored files drift apart | Locked to one vendor | App-level, not agent-level | App-level, not agent-level | Same MCP surface for Claude Code, Cursor, Cline, GitHub Copilot, Gemini, Antigravity |
Retrieval model | Whole file dumped into context | Whole file / vendor-managed | Vector + graph (semantic) | Temporal knowledge graph (semantic) | Deterministic FTS5 + regex; surgical section reads |
Token accounting | None | None | None exposed to agent | None exposed to agent | Every response carries |
Command execution | N/A | Vendor-defined tools | N/A (memory only) | N/A (memory only) | Sandboxed |
Storage | Repo file (clutters PRs) | Vendor cloud | Self-host or hosted, vector DB | Self-host or hosted | Local SQLite, git-synced markdown vault |
Best at | Static project conventions | Zero-config personal memory | Semantic recall inside one app | Long-running conversational memory | Multi-agent handoff + governed local execution |
Honest tradeoffs:
If you only use one agent and one project,
CLAUDE.mdor vendor memory is simpler β reach for Kontexta when you're switching agents or coordinating across projects.mem0 and Zep do semantic recall that FTS5 doesn't; Kontexta trades fuzzy matching for determinism and local-only operation.
Kontexta's
Handssandbox has no equivalent in the memory tools above β that's the unique surface, not the memory itself.
Quick Start (5-Minute Trial)
1. Run the MCP Server (No Install)
The fastest way to try Kontexta is via npx. Add this to your MCP client configuration (e.g., mcpServers.json):
{
"mcpServers": {
"kxta": {
"command": "npx",
"args": ["-y", "kontexta-mcp"],
"env": {
// Optional: defaults to your OS-standard data directory
// "KONTEXTA_DATA_DIR": "/absolute/path/to/your/knowledge-vault"
}
}
}
}2. Run the Dashboard (Docker)
For the full "Obsidian-meets-Terminal" UI, download the compose file, edit your volume mounts and environment variables (e.g., project paths), and run:
curl -fsSL https://raw.githubusercontent.com/safiyu/kontexta/main/docker-compose.hub.yml -o docker-compose.yml
# Important: Open docker-compose.yml and edit the volumes section
# to mount your projects directory so the agent can see them.
docker compose up -dThe UI lands at http://localhost:3000.
To run on a custom port:
HOST_PORT=8080 docker compose up -dThe WebSocket file-watcher shares this same port (upgrade path /_kontexta_ws) β no second port to manage.
You can also specify where data and projects live on the host:
DATA_DIR=/absolute/path/to/kontexta-data \
PROJECT_DIR=/absolute/path/to/your/projects \
HOST_PORT=8080 \
docker compose up -dNote: PROJECT_DIR should be an absolute host path and is mounted to the same absolute path inside the container so file paths remain consistent between your host and the in-container MCP tools.
The compose file includes a startup check that fails fast if PROJECT_DIR is not set, preventing accidental runs without a mounted projects directory.
Security & Network Exposure
Kontexta's dashboard is designed for local-first use β running on localhost or on a trusted machine you control. The threat model is:
Default safe: A master password protects the UI. Sessions are HMAC-signed cookies, passwords are scrypt-hashed.
IP bypass is opt-in per IP. During setup you can allowlist IPs (e.g.
127.0.0.1) to skip the login prompt from trusted addresses.Reverse-proxy mode is opt-in. If you put Kontexta behind nginx, Caddy, or Cloudflare Tunnel, enable "Trust
X-Forwarded-Forheaders" during setup. Without this flag, those headers are ignored β so a LAN attacker cannot spoof an allowlisted IP.kontexta.jsonis your responsibility. The Hands engine executes shell commands you declare in this file. The sandbox limits where and how those commands run (path traversal blocked, ReDoS-proof regex, locked CWD, stripped PATH), but the what is whatever you wrote. Review anykontexta.jsonyou didn't author yourself β same caution you'd apply to a Makefile, GitHub Actions workflow, or shell snippet from the internet.
Do not expose the dashboard to the public internet without a trusted reverse proxy in front. The auth layer is sufficient for localhost and LAN use; it is not hardened against direct internet exposure (no rate limiting, no brute-force lockout, no MFA).
Demo & Walkthrough
In this demo:
System audit and web clipping.
Local RAG and context gathering.
The Brain/Hands/Eyes loop in action.
No-install demo: Try the MCP endpoints interactively right from your browser on the Glama Kontexta page.
Project Status & Transparency
Why the high version number on a fresh repository? If you look at the commit history, you might wonder how a repository with so few commits reached its current major version.
Kontexta wasn't built over a weekend. It began over a year ago as a private, monolithic toolchain used to manage complex, multi-agent coding workflows. The versioning reflects its true architectural maturity.
Recently, I undertook a major effort to industrialize and modularize this engine, restructuring it into the three core pillars you see today: Brain, Hands, and Eyes. This process involved decoupling the core from private infrastructure and moving to a clean, open-source monorepo. The condensed git history is the result of this clean extractionβleaving behind internal legacy commits to publish only the battle-tested, production-ready framework available today.
Roadmap
What's deliberately deferred and what triggers will pull it forward lives in docs/ROADMAP.md. Notable open items: per-call project resolution in journaling, server-side LLM upgrade for the WebUI scheduler, and Layer 3 (embeddings + graph + semantic clustering).
Features Breakdown
Brain
Global vault with two-way git sync.
54 MCP tools tuned for context economy.
Batch operations (up to 500 files/call), grep, and regex support.
Web clipping with auth-wall detection.
Full git-backed versioning:
get_history,get_diff,restore_file.Agent context rules onboarding:
register_projectdetects existingCLAUDE.md/AGENTS.md/GEMINI.md/.cursor/rules/*.mdc/.continue/rules/*.md/.clinerules/.github/copilot-instructions.mdand recommends a follow-up. Theonboard_agenttool injects an idempotent, version-fenced workflow rules block (or scaffolds one for the right agent) so every new conversation starts already aware of kontexta's conventions.
Hands
Project-specific
kontexta.jsontools map.Strict sandbox: realpath-verified CWD, stripped
PATH, and hard timeouts.ReDoS-proof parameter validation via
re2.CSPRNG-bound confirmation tokens for high-risk commands.
Dashboard
Built-in
/docspage with a searchable catalogue of all 54 core tools.Form-based
kontexta.jsoneditor with live validation.Real-time status bar streaming git activity over WebSockets.
Deleting a project file in Kontexta only un-indexes it from the AI's memory. Your physical source code is never touched.
Contributing
Kontexta is a project for developers, by developers. If you'd like to contribute new tools, improve the core engine, or refine the dashboard, please see our CONTRIBUTING.md for architecture guidelines and local setup instructions.
Built with care for the future of agentic coding. License: Apache-2.0
Maintenance
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/safiyu/kontexta'
If you have feedback or need assistance with the MCP directory API, please join our Discord server