ctxnest
CtxNest is a local-first, centralized context engine providing AI agents with 42 tools to manage versioned markdown knowledge across projects and a personal knowledge base, optimized for context window economy.
File Reading
read_file/read_files/read_file_by_path— Read single, batch (up to 200), or path-based filesread_file_outline— Headings-only outline without loading full contentread_section/read_file_lines— Read a single heading's body or a specific line rangedescribe_file— File metadata (tags, size, history, backlinks) without loading content
File Writing
create_file/create_files— Create single or batch (up to 200) filesupdate_file/update_file_section— Full replace or surgical per-heading update (auto-commits to git)delete_file/delete_files— Delete single or batch (up to 500) filesmove_file— Rename or relocate a filejournal_append— Append a timestamped entry to today's journal
Search & Discovery
search— FTS5 full-text search with inline excerpts and highlightsbundle_search— Search and concatenate results into a token-budgeted XML/Markdown blobregex_search/grep_in_file— Cross-file or within-file regex searchfind_related— Files sharing tags, ranked by overlapwhats_new— Files created/modified since a checkpointproject_map— Compact indented outline of an entire project or knowledge base
Tagging & Favorites
add_tags/remove_tags/list_tags— Manage tagsset_favorite— Mark/unmark favoritessuggest_tags— Propose tags based on corpus (no LLM required)tag_search_results— Bulk-apply tags to all files matching a query
Folders & Projects
list_files/list_folders— List files or folders with filterscreate_folder/delete_folder— Create (nested) or recursively delete foldersregister_project/list_projects— Register external repos and list all projectsstats— Aggregate counts, top tags, per-project breakdown
Versioning & Integrity
get_history/get_diff/restore_file— Git history, diffs, and rollbackcommit_backup— Commit and push a project to gitdiff_against_disk/refresh_index— Detect and reconcile drift from external edits
Web Clipping
clip_url— Fetch a page, extract content via Readability, and store as Markdown (supports auth-walled pages with cookie/token retry)
All file-returning tools include est_tokens and size_bytes; list/search tools inline tags and excerpts to minimize round-trips.
CtxNest is a local-first Model Context Protocol (MCP) server that gives your AI coding agents — Claude Code, Cursor, Gemini, Antigravity — a persistent memory and a controlled command surface.
Instead of agents losing context between sessions or inventing their own shell commands, CtxNest provides:
Brain: A git-backed markdown vault with FTS5 search and surgical section edits.
Hands: A sandboxed command engine defined by you in
ctxnest.json.Eyes: A feedback loop that journals results back into the brain.
Badges & Launches
The Unique Value
Most AI tools trap context inside their own chat window. CtxNest 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
ctxnest.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.
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.
3. Deterministic Context Retrieval
SQLite FTS5 Power: Instead of unpredictable vector-based RAG, CtxNest 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, CtxNest 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.
Architecture: Brain → Hands → Eyes
CtxNest 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
ctxnest.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.
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.Journaling:
journal_appendcreates a timestamped record of decisions and results.
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 CtxNest Solution
Journaling: As Claude Code works, it calls
journal_appendto log its decisions and the "why" behind the code.Persistence: Those logs are saved in your local CtxNest brain, not the chat window.
Seamless Handoff: When you open Cursor, it immediately sees the recent journal entries and architectural state via the CtxNest MCP.
Zero Re-explanation: Cursor "wakes up" with the exact same context Claude had.
How CtxNest Compares
CtxNest doesn't try to replace your favorite agent; it gives it a better body.
Capability | Standard AI Agents | CtxNest + Hands |
Context Persistence | Volatile / Session-bound | Local SSD (SQLite FTS5) |
Command Surface | Hardcoded by tool vendor | User-defined JSON contract |
Execution Security | Implicit / Opaque | Explicit Sandbox (No-shell, strict env) |
Agent Handoff | Manual copy-paste | Automated cross-agent state |
Storage & Sync | Cloud-managed | Local-first / Git-synchronized |
Quick Start (5-Minute Trial)
1. Run the MCP Server (No Install)
The fastest way to try CtxNest is via npx. Add this to your MCP client configuration (e.g., mcpServers.json):
{
"mcpServers": {
"ctxnest": {
"command": "npx",
"args": ["-y", "ctxnest-mcp"],
"env": {
"CTXNEST_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/ctxnest/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.
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 CtxNest 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.
CtxNest 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.
Features Breakdown
Brain
Global vault with two-way git sync.
46 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.
Hands
Project-specific
ctxnest.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 4core tools.Form-based
ctxnest.jsoneditor with live validation.Real-time status bar streaming git activity over WebSockets.
Deleting a project file in CtxNest only un-indexes it from the AI's memory. Your physical source code is never touched.
Contributing
CtxNest 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/ctxnest'
If you have feedback or need assistance with the MCP directory API, please join our Discord server