Skip to main content
Glama

ContextHub

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


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).

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

  • Web Dashboard for memory visualization

  • Comprehensive test suite

  • ๐Ÿง  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


A
license - permissive license
-
quality - not tested
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

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/iMayuuR/contexthub'

If you have feedback or need assistance with the MCP directory API, please join our Discord server