ContextHub

ContextHub

AI memory orchestration server that provides persistent, encrypted context with semantic search and intelligent injection for coding agents via MCP.

Category
Visit Server

README

ContextHub

AI Memory Layer for Developers โ€” Persistent context, semantic search, and intelligent context injection for every AI agent in your repositories.

<p align="center"> <img src="https://img.shields.io/badge/Version-1.0.0-blue.svg" alt="Version"> <img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License"> <img src="https://img.shields.io/badge/TypeScript-5.0+-yellow.svg" alt="TypeScript"> <img src="https://img.shields.io/badge/Node-18+-orange.svg" alt="Node"> <img src="https://img.shields.io/badge/Security-Hardened-brightgreen.svg" alt="Security"> <img src="https://img.shields.io/badge/Encryption-AES--256--GCM-blueviolet.svg" alt="Encryption"> </p>


What is ContextHub?

ContextHub is a local-first, privacy-focused AI memory and context orchestration layer that gives coding agents persistent memory across sessions. It understands your codebase, provides intelligent context injection to any AI agent, and keeps all your data encrypted and private.

Key Features

  • โšก Token & Cost Optimizer โ€” Saves 70%-90% context window and API costs via smart session compression and dynamic RRF filtering
  • ๐Ÿง  Persistent Memory โ€” Saves conversations, decisions, and learnings across sessions
  • ๐Ÿ” Semantic Search โ€” Natural language queries across all your memories with offline-verified local bigram embeddings
  • ๐Ÿ“Š Code Intelligence โ€” Analyzes repo structure, dependencies, and transitive God-nodes
  • ๐Ÿ”Œ MCP-Compatible โ€” Works natively with Cursor, Claude Code, Windsurf, and any stdio MCP client
  • ๐Ÿ”’ Encrypted Storage โ€” Bank-grade AES-256-GCM encryption at rest with per-repo unique salt
  • ๐Ÿ›ก๏ธ Auto-Redaction โ€” API keys, tokens, private keys, and passwords detected and redacted before write
  • ๐ŸŒ Local Dashboard โ€” Interactive web dashboard to visually explore memory timelines and codebase topology
  • ๐ŸŒฟ Git Integration โ€” Automatically maps memories to branches, authors, commit hashes, and file diffs
  • ๐Ÿ“‚ Multi-Root Support โ€” Standard multi-root workspace configs limit file indexing strictly to active folders
  • ๐Ÿ“š Docs Ingest โ€” Ingest markdown directories and PDFs directly into semantic memory
  • ๐Ÿง  DeepSync โ€” One command to scan your entire repo (code + docs + git) and build a complete knowledge graph with auto-updates
  • ๐ŸŒ Local-First โ€” Zero telemetry and zero external network calls. Your code and memories never leave your workstation

Quick Start

You can set up ContextHub either Globally (for all your coding repositories) or as a Single-Repo local setup (isolated to this project only).

Option A: Single Repository Setup (Recommended)

Add ContextHub as a local dependency inside this specific project:

# 1. Install locally in the project root
npm install --save-dev @imayuur/contexthub

# 2. Run the local setup
npx contexthub setup

Option B: Global Installation (Universal)

Install globally to make the contexthub command globally accessible anywhere on your system:

# 1. Install globally
npm install -g @imayuur/contexthub

# 2. Run setup in the project root
contexthub setup

Option C: Instant Execution (No Install)

Run instantly via npx without storing any packages locally or globally:

npx @imayuur/contexthub setup

That's it! ContextHub will:

  1. Initialize encrypted storage in .contexthub/
  2. Generate encryption key (.contexthub/.keyfile, owner-only 0600 permissions)
  3. Generate auth token (.contexthub/.auth-token)
  4. Start the MCP server in the background with PID tracking

For AI Agents

Configure your AI agent to connect to ContextHub as an MCP server via stdio transport. The agent will automatically:

  • Fetch relevant context before responding
  • Save interactions as encrypted memories
  • Query the knowledge graph and repo intelligence

๐Ÿง  DeepSync โ€” One Command, Total Repo Awareness

npx @imayuur/contexthub deepsync

DeepSync performs a deep scan of your entire repository in one shot:

  • ๐Ÿ“‚ Code Analysis โ€” Parses all source files across 15+ languages, indexes symbols and import relationships
  • ๐Ÿ“„ Documentation โ€” Ingests all markdown files into searchable, semantic memory
  • ๐Ÿ”€ Git Mining โ€” Analyzes commit history, identifies hot files and recent focus areas
  • ๐Ÿ”ข Embeddings โ€” Generates vector embeddings for semantic search across all memories
  • ๐Ÿ“Š Report โ€” Writes a rich DEEPSYNC.md summary to .contexthub/

After the initial scan, ContextHub auto-updates incrementally on every ensure_session call โ€” only changed files are re-analyzed. Zero manual effort.


Usage Examples

CLI Commands

# Memory operations
contexthub memory --list
contexthub memory --add "Handle race condition in auth module"
contexthub memory --search "authentication bug"
contexthub memory --list --type bugfix

# Session timeline
contexthub timeline --limit 20

# Semantic search (vector-enabled)
contexthub search --query "how to implement caching" --limit 5

# Unified RRF query (memory + graph + git)
contexthub query "auth race condition"

# Generate context bundle for agents
contexthub context --query "caching strategy"

# Watch for incremental graph updates
contexthub watch

# Launch interactive dashboard
contexthub dashboard

# DeepSync โ€” one-command repo intelligence
contexthub deepsync
contexthub deepsync --force    # force full re-scan

# Server lifecycle
contexthub start --port 3000
contexthub stop

# Ingest documentation
contexthub ingest-docs

# Health & performance
contexthub doctor
contexthub benchmark

Dashboard (Interactive Web UI)

# Launch the local dashboard (localhost only)
contexthub dashboard

# Custom port
contexthub dashboard --port 4000

Opens at http://127.0.0.1:3847. Features:

  • Memory Feed โ€” browse all encrypted memories with tags and timestamps
  • Intelligent Query โ€” unified search across memories, graph, and git
  • Topology Graph โ€” interactive force-directed Vis.js graph of your codebase dependencies
  • Click any node to inspect package workspace, dependency degree, and direct neighbors

Dashboard binds to 127.0.0.1 only โ€” never exposed to the network.


Architecture

contexthub/
โ”œโ”€โ”€ packages/              # 14 packages
โ”‚   โ”œโ”€โ”€ shared-types/      # TypeScript interfaces (Session, MemoryEntry, CodeGraph)
โ”‚   โ”œโ”€โ”€ core/              # Storage, security, RRF query, config, limits
โ”‚   โ”œโ”€โ”€ cli/               # 25 CLI commands (setup, deepsync, dashboard, watch, query, etc.)
โ”‚   โ”œโ”€โ”€ mcp-server/        # MCP protocol server (35+ tools, hardened)
โ”‚   โ”œโ”€โ”€ knowledge-graph/   # Code graph: god-nodes, communities, snapshots, reports
โ”‚   โ”œโ”€โ”€ vector-engine/     # Embeddings: local bigram TF-IDF, optional transformers
โ”‚   โ”œโ”€โ”€ repo-parser/       # Tree-sitter (TS/JS/TSX/Py) + regex 15+ languages
โ”‚   โ”œโ”€โ”€ git-integration/   # Git history & commit tracking (simple-git)
โ”‚   โ”œโ”€โ”€ docs-ingest/       # Markdown chunk + embed into vector engine
โ”‚   โ”œโ”€โ”€ plugin-pdf/        # PDF parse (optional, env flag)
โ”‚   โ”œโ”€โ”€ context-injector/  # Smart context retrieval
โ”‚   โ”œโ”€โ”€ memory-engine/     # Compact, archive, deduplication algorithms
โ”‚   โ”œโ”€โ”€ agent-connectors/  # AI agent adapters (sanitized)
โ”‚   โ””โ”€โ”€ skills/            # Built-in skills only: architect, debug, review
โ”œโ”€โ”€ scripts/               # publish-packages.js, rename-scope.js
โ”œโ”€โ”€ docs/                  # Marketing site, assets
โ”œโ”€โ”€ SECURITY.md            # ๐Ÿ”’ Full security scan report (26 findings, all fixed)
โ””โ”€โ”€ .contexthub/           # Per-repo encrypted storage (created at runtime)
    โ”œโ”€โ”€ memories.json      # ๐Ÿ” Encrypted memory storage
    โ”œโ”€โ”€ sessions.json      # ๐Ÿ” Encrypted session history
    โ”œโ”€โ”€ project-metadata.json # ๐Ÿ” Encrypted metadata
    โ”œโ”€โ”€ .keyfile           # ๐Ÿ”‘ Encryption key (mode 0600)
    โ”œโ”€โ”€ .auth-token        # ๐Ÿ”‘ MCP auth token (mode 0600)
    โ”œโ”€โ”€ server.pid         # Process ID for server management
    โ”œโ”€โ”€ graph/             # ๐Ÿ” Encrypted code knowledge graph
    โ”œโ”€โ”€ embeddings/        # Vector embeddings
    โ”œโ”€โ”€ GRAPH_REPORT.md    # Auto-generated dependency report
    โ””โ”€โ”€ DEEPSYNC.md        # ๐Ÿง  DeepSync intelligence report

How It Works

  1. Capture โ€” Interactions saved via MCP tools (no shell hooks)
  2. Sanitize โ€” All input validated, sensitive data auto-redacted
  3. Encrypt โ€” Data encrypted with AES-256-GCM before writing to disk
  4. Analyze โ€” RepoParser builds code structure understanding (sandboxed)
  5. Embed โ€” VectorEngine generates semantic embeddings
  6. Inject โ€” ContextInjector retrieves relevant context for AI queries

MCP Tools Available (35+)

Session & Memory: ensure_session, record_turn, save_session, end_session, get_project_context, save_memory, search_memory, semantic_search, search_memory_by_code, contexthub_query, get_context_bundle, explain_symbol

Code Graph: get_code_graph_stats, get_related_symbols, get_blast_radius, trace_code_path, update_knowledge_graph, get_god_nodes, get_graph_communities, diff_code_graph, what_changed_since_session

Repo & Git: summarize_repo, get_architecture_summary, get_related_files, get_recent_changes, get_git_summary, get_memories_for_commit

Docs & Skills: ingest_docs, search_docs, ingest_pdf, list_skills, load_skill, run_skill_command

Resources: contexthub://policy, contexthub://graph-stats, contexthub://report Prompts: summarize-session, onboard-repo, pre-commit-review

All tools are wrapped with safeHandler() โ€” errors never expose internal paths or stack traces.


Security & Privacy

ContextHub is secure by design. See SECURITY.md for the full audit report.

Protection Details
๐Ÿ” Encryption AES-256-GCM at rest for all data files
๐Ÿ›ก๏ธ Auto-Redaction API keys, tokens, passwords detected and redacted
๐Ÿšซ No Shell Hooks No .bashrc/.zshrc modification, no command capture
๐Ÿ”’ Path Safety Directory traversal and symlink attacks prevented
โœ… Input Validation All parameters validated and sanitized
๐Ÿ”‘ Auth Support Optional HMAC token authentication for MCP
๐Ÿ“ฆ Atomic Writes No data corruption on crash
๐Ÿงน Error Sanitization No internal paths or stack traces leaked
๐Ÿ  Local-First Zero telemetry, zero external calls
๐Ÿ”— 0 npm Vulnerabilities Clean dependency tree

Quick Security Setup

# Optional: Enable MCP authentication
export CONTEXTHUB_TOKEN=your-secret-token

# Optional: Provide your own encryption key
export CONTEXTHUB_KEY=your-strong-passphrase

# Optional: Enable the ingest_pdf tool (max 50 pages / 20MB per file)
export CONTEXTHUB_ENABLE_PDF=1

# Verify file permissions
ls -la .contexthub/
# Directory: drwx------ (700)
# Files:    -rw------- (600)

Memory Types

Type Description
prompt User prompt / query
response AI response / solution
summary Session summary
decision Architectural decision
architecture Design pattern / structure
bugfix Bug description & fix
manual User-added note
commit Git commit record

Skills System

ContextHub includes 3 built-in skills (no external skill loading for security):

Skill Commands Triggers
architect analyze โ€” Analyze codebase architecture architecture, design, structure
debug find-similar โ€” Find similar past bugs bug, error, fix, issue
review review-changes โ€” Review recent changes review, pr, pull request

System Limits

ContextHub enforces strict performance caps centrally to ensure agents don't freeze your system or consume unbounded tokens:

  • Memory Context Size: 50KB maximum per entry
  • Total Memories: 10,000 max entries per repo
  • Graph Display Nodes: 5,000 nodes rendered max
  • Search Query Result: 100 max entries returned
  • Repo Parser Limits: 1,000 files max, 1MB max file size
  • Memory Tags/Refs: 20 tags, 20 linked paths, 20 linked symbols

Development

Building from Source

# Clone repository
git clone https://github.com/iMayuuR/contexthub.git
cd contexthub

# Install dependencies
npm install

# Build all packages
npm run build

# Run CLI
node packages/cli/dist/index.js --help

Package Structure (14 packages)

Package Purpose
shared-types TypeScript interfaces (Session, MemoryEntry, CodeGraph)
core Storage, security, RRF query, config, contexthub-ignore, limits
cli 25 CLI commands (setup, deepsync, dashboard, watch, query, etc.)
mcp-server MCP protocol with 35+ tools, resources, prompts
knowledge-graph Graph build/patch, god-nodes, communities, reports, snapshots
vector-engine Local bigram TF-IDF embeddings, optional transformers
repo-parser Tree-sitter WASM (TS/JS/TSX/Py) + regex 15+ languages
git-integration Git operations via simple-git
docs-ingest Markdown chunk + embed into vector engine
plugin-pdf PDF text extraction (optional, env flag)
memory-engine Compact, archive, deduplication algorithms
context-injector Smart context retrieval and prompt enhancement
agent-connectors AI agent adapters (sanitized with safeSaveMemory)
skills Built-in only: architect, debug, review (allowlist)

Implementation Roadmap

All features, optimizations, and unit/integration tests are 100% complete.

Roadmap

  • [x] Web Dashboard for memory visualization
  • [x] Comprehensive test suite
  • [x] ๐Ÿง  DeepSync โ€” one-command repo intelligence with auto-sync
  • [ ] Electron desktop app with system tray
  • [ ] WebSocket transport for MCP
  • [ ] Cloud sync with E2E encryption
  • [ ] Team collaboration features

Contributing

Contributions welcome! Please read our Contributing Guide and submit PRs.

License

MIT ยฉ 2026 Mayur Dattatray Patil


<p align="center"> <strong>Built for developers who want AI that actually understands their code โ€” securely.</strong> </p>

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured