context-mcp
The context-mcp server provides persistent memory, a codebase knowledge graph, and file/git operations for AI coding assistants.
Persistent Memory & Context Management
Save, retrieve, update, and delete context entries (decisions, bugs, notes, configs) across sessions and projects.
Search entries using keyword-first with semantic fallback; auto-deduplication and compaction included.
Codebase Knowledge Graph (CodeGraph)
codegraph_build: Parse a codebase via tree-sitter AST across 16 languages to build a knowledge graph of functions, classes, imports, and call edges — no API key required.codegraph_query: Ask natural-language structural questions or look up specific nodes by name (type, location, dependencies, callers).codegraph_report: Generate a report highlighting god nodes, clusters, and surprising connections.codegraph_nodes: List all nodes of a given type (class, function, module, file, etc.).codegraph_path: Find the shortest relationship path between two concepts.codegraph_affected: Identify the blast radius if a component changes.codegraph_html: Generate interactive visualizations (force graphs, D3 trees, Mermaid diagrams, Obsidian vaults).
File & Git Operations (HTTP/online mode)
File ops:
read_file,write_file,patch_file,create_dir,list_dir,delete_file— sandboxed to the project root.Git ops:
git_status,git_diff,git_log,git_commit,git_push,git_pull,git_branch,git_stash,git_reset,git_show(requires explicit enablement).
Multi-Platform Support
Auto-configure MCP for Claude Code, Cursor, VS Code Copilot, Gemini CLI, Codex, Windsurf, Claude.ai, and ChatGPT.
Run as an HTTP server (
ctx online) with OAuth authentication for web-based AI clients.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@context-mcp Load my project context and recent decisions"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Persistent memory and codebase knowledge graph for AI coding assistants — delivered as a single MCP server.
One shared context store across Claude Code, VS Code Copilot, Google Antigravity (2.0 / IDE / CLI), Codex CLI, Hermes Agent, Claude.ai, and ChatGPT. Save context from one AI, pick it up in another.
The Problem
Every conversation with an AI assistant starts from zero. The AI re-reads files it already read yesterday, re-discovers architecture it already understood, re-derives decisions that were already made. You repeat context. You paste the same background.
This gets worse as projects grow — reading 20 files to answer "what calls this function?" burns thousands of tokens every time.
Related MCP server: GraphHub
What It Solves
Persistent memory — decisions, bugs, notes, and config saved across sessions, loaded automatically at conversation start
Shared store —
~/.context-mcp/projects/<name>/per-project on your machine; all AI tools read and write itContextGraph — build a knowledge graph of your codebase once, answer structural questions in ~500 tokens instead of ~50,000
Real measured reduction on this project: 162× fewer tokens, 99.38% reduction per conversation.
Installation
npm install -g context-mcp-serverRequires Node.js ≥ 18. Installs context-mcp, context-mcp-http, and the ctx CLI.
ContextGraph requires uv (Python runner). Memory tools work without it.
# macOS / Linux
curl -Ls https://astral.sh/uv/install.sh | sh
# Windows
winget install astral-sh.uvQuick Start
Run from your project root:
ctx install --initialThis installs Node.js + Python (ContextGraph) dependencies. Run once after installing the npm package.
Then write MCP config + AI instruction files:
ctx install --allTo install for a specific platform only:
ctx install --claude # Claude Code
ctx install --vscode # VS Code Copilot
ctx install --antigravity # Google Antigravity (2.0 / IDE / CLI)
ctx install --codex # Codex CLI
ctx install --hermes # Hermes AgentFor Codex project installs, ctx install --codex writes:
.codex/config.tomlwith[mcp_servers.context-mcp]MCP configuration.AGENTS.mdwith Context-MCP usage rules for Codex..codex/hooks/pre/post shell hook scripts for project-local Codex sessions.
For web clients (Claude.ai, ChatGPT), start the HTTP server:
ctx online # start in background, prints OAuth credentials + URL
ctx online --restart # force restart
ctx online --port 3200 # different portClaude Code plugin
This repo is also a self-hosted Claude Code plugin marketplace — an alternative to ctx install --claude that doesn't require cloning or npm-installing anything yourself:
claude plugin marketplace add vibhasdutta/context-mcp
claude plugin install context-mcp@context-mcp-marketplaceor from inside a session: /plugin marketplace add vibhasdutta/context-mcp then /plugin install context-mcp@context-mcp-marketplace. This installs the context-mcp skill, the Bash pre/post-tool-use hooks, and registers the MCP server (still launched via npx context-mcp-server@latest) — everything ctx install --claude writes into ~/.claude/, bundled as one installable unit. ctx install --initial is still required once to install the ContextGraph Python environment.
CLI Reference
Both ctx and context are aliases for the same CLI.
ctx # interactive mode (UI)
# Context
ctx list [project] # list entries by tree: graph / context / summary / plans
ctx projects # all projects with graph status + recent entries
ctx search "query" # keyword → semantic fallback search
ctx add # add entry interactively
ctx summary [project] # summarize recent entries
# Delete
ctx delete <id-prefix> # delete one entry
ctx delete project <name> # delete all entries for a project
# Server
ctx online # start HTTP server (idempotent)
ctx online --restart # force stop + restart
ctx settings # view and edit config interactively
# Install
ctx install --initial # install / update Node.js + Python deps
ctx install --all # write config + rules for all platformsSecurity
File and git tools are sandboxed to your project root. Pass rootPath when calling context.resume:
{ "action": "resume", "project": "my-app", "rootPath": "/home/user/my-app" }Any file or git operation outside that directory is rejected. Applies to all HTTP-connected clients.
Features
Memory
context.resume— loads recent entries, active plans, and graph status; registersrootPathfor sandboxingcontext.save— store context asnote(orcompactionfor session summaries); categorize with free-formtagscontext.get/context.update/context.delete— full CRUD, single or batchsearch— keyword-first, semantic fallbackplan— auto-triggered when AI makes any plan; saves a markdown summary to aplanDiryou specifyAuto-deduplication on save; auto-compact at 20 entries → stored in
summary.json
ContextGraph
Also called CodeGraph. MCP tools use the
codegraph_*prefix — both names mean the same thing.
Step 1 — Build (once per project, runs locally, no API cost):
codegraph_build(path)Parses codebase via tree-sitter AST (16 languages, regex fallback). Extracts functions, classes, imports, call edges, and inheritance. Every node carries a full enriched schema: signature, params, return_type, docstring, side_effect, exported, complexity, last_modified. PageRank scores all nodes by connectivity. Metadata saved to <project>/codegraph-cache/.
Step 2 — Query (instant, forever):
codegraph_arch(path, limit?) → module map: every file, its exports, its imports
codegraph_query(path, question?, node?) → structural question OR single-node lookup (or both)
codegraph_nodes(path, type, token_budget?) → all nodes of a type, sorted by PageRank
codegraph_filter(path, node_type?, exported?, → predicate filter: side_effect, return_type,
side_effect?, return_type?, called_by?, called_by, file_pattern — rank-sorted output
calls?, file_pattern?, token_budget?)
codegraph_report(path) → god nodes, clusters, surprising connections
codegraph_affected(path, node, depth?) → BFS blast radius — what breaks if you change X?codegraph_query accepts question (natural language), node (exact/partial name), or both. codegraph_filter answers property questions ("which functions have side effects?", "all exported async handlers") without reading any files. Pass token_budget to any tool to get the highest-rank results within a token limit.
What's in each node (v1.2+):
Field | Example |
|
|
|
|
|
|
|
|
| first comment or JSDoc string |
| PageRank score — higher = more connected |
| parent class / interface names |
Step 3 — Visualize (auto-generated on every build):
codegraph_html(path, formats?) → regenerate visualizations on demandEvery codegraph_build automatically writes to <project>/codegraph-cache/:
graph.html— interactive vis.js force graph (dark theme, search, community toggle)tree.html— D3 collapsible file hierarchycallflow.html— Mermaid architecture diagrams per communitygraph.graphml— Gephi / yEd exportobsidian/— per-node.mdvault with[[wikilinks]]
File & Git Tools
Available to HTTP-connected clients (Claude.ai, ChatGPT). Local AI clients use their native IDE tools.
read_file,write_file,patch_file,create_dir,list_dir,delete_filegit_status,git_diff,git_log,git_add,git_commit,git_push,git_pull,git_branch,git_stash,git_reset,git_show
Enable git tools with --access-git flag or access_git: true in config.
Server Flags
context-mcp [--data-dir <path>]
context-mcp-http [--port <number>] [--host <string>] [--access-git] [--data-dir <path>]Default port: 3100. Default data dir: ~/.context-mcp.
Config Reference
~/.context-mcp/contextconfig.json — auto-created on first run:
Field | Default | Description |
|
| OAuth client ID |
| auto-generated | OAuth signing secret |
|
| HTTP server port |
|
| HTTP bind host |
|
| Enable git tools for HTTP clients |
|
| Public URL for |
|
| OAuth redirect URI whitelist |
|
| Extra CORS origins |
Edit with ctx settings.
License
MIT
Available Tools
5 toolscodegraph_buildA
Scan a project directory and build the knowledge graph from code files. Uses tree-sitter AST (with regex fallback) for all code files. Fast, local, no API key needed. Run once per project; rebuild whenever code changes.
Inputs: path (required), cluster.
codegraph_nodesB
List all nodes of a given type in the graph.
Inputs: path (required), type (required), limit.
codegraph_pathC
Find the shortest relationship path between two concepts in the graph.
Inputs: path (required), from (required), to (required).
codegraph_queryA
Ask a structural question about the codebase OR look up a specific node by name — or both in one call. Pass question for natural-language traversal: what calls X, what does module Y depend on. Pass node for fast single-node lookup: returns type, file, depends_on, used_by. Pass both to get node detail + surrounding graph context together. Returns structured text within token_budget. Use before reading any files.
Inputs: path (required), question, node, token_budget.
codegraph_reportC
Return CODEGRAPH_REPORT.md — god nodes, clusters, surprising connections, suggested questions.
Inputs: path (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose: building the graph, listing nodes, finding paths, querying, and generating reports. No overlap in functionality.
All tools follow a consistent 'codegraph_<verb>' pattern (build, nodes, path, query, report), making it easy to predict tool names.
Five tools is an ideal count for a focused code knowledge graph server, covering all essential operations without bloat or deficiency.
The tool surface covers building, querying (by node, path, natural language), listing nodes, and generating a summary report. No obvious gaps for code exploration.
Maintenance
Related MCP Connectors
Shared memory for coding agents. Stop re-explaining your codebase every session.
Your own memory for every AI: Claude, ChatGPT, Cursor, Zed and more. Brings in 20+ sources.
Private memory for AI agents: save and recall facts across Claude Code, Codex, Cursor and ChatGPT.
Persistent memory for Claude Code and Cursor. Stop re-explaining your project every session.
Related MCP Servers
- AlicenseCqualityAmaintenanceProvides AI assistants with persistent memory and code intelligence across all tools and conversations. Features semantic search, knowledge graphs, decision tracking, and impact analysis with 60+ tools for universal context preservation.364,638 npm46MIT
- AlicenseNot gradedqualityCmaintenanceTransforms codebases into a knowledge graph for AI agents, enabling semantic search, impact analysis, and persistent session memory with up to 94% token savings.4 npm15ISC
- AlicenseNot gradedqualityDmaintenanceProvides AI coding assistants with persistent, context-rich memory of a codebase, including documentation and git history, enabling recall across sessions.105Apache 2.0
- AlicenseNot gradedqualityCmaintenancePersistent memory for AI coding tools that captures conversations, builds a searchable knowledge graph, and automatically injects relevant context into new prompts.7 npm246MIT