ContextForge MCP
Integrates with Git repositories to sync commits and pull requests automatically and to use branch, commit, and changed-file context when recalling relevant memories.
Provides persistent memory across sessions for GitHub Copilot in VS Code via MCP, letting Copilot retrieve project decisions, architecture notes, and task context by semantic search.
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., "@ContextForge MCP what did we decide about the auth middleware last week?"
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.
ContextForge MCP — Persistent Memory for Claude, Cursor & Copilot
Give Claude Code, Cursor, and GitHub Copilot persistent memory across sessions via the Model Context Protocol (MCP). Stop re-explaining your project every time.
ContextForge MCP is an open-source MCP server that connects your AI coding assistants to long-term, searchable memory. Decisions, architecture notes, debugging context, and project knowledge stay available across every session — across every tool that supports MCP.
🧠 Persistent memory — your AI remembers everything across sessions, days, and weeks
🔍 Semantic search — find knowledge by meaning, not keywords
🔗 One memory, every tool — Claude Code, Cursor, Copilot, Claude Desktop, Windsurf
🐙 Git integration — sync commits and PRs automatically
✅ Task tracking — issues, assignments, and project status
👥 Team collaboration — share projects and memory with your team
🆓 Free tier — get started without a credit card
Works automatically, no config needed (v0.5.1+). On connect, the server sends startup instructions to your AI client. Clients that honor them (Claude Desktop, Claude Code) load your project memory at the start of every session and save new decisions proactively — without you editing any settings. Running init (Step 4) is now a reinforcement, not a requirement, and still helps on clients that don't yet honor server instructions (e.g. Cursor).
Quick Start
1. Install
No install step needed — the setup below runs the server via npx -y contextforge-mcp, which fetches it on demand and keeps it up to date.
Prefer a global install for slightly faster cold starts?
npm install -g contextforge-mcpis optional; if you do it, you can drop thenpx -yprefix from the commands below.
2. Get your API key
Go to contextforge.dev
Sign up (free tier available)
Settings → API Keys → Generate API Key
Copy your key (starts with
cf_)
3. Connect to your AI tool
Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"contextforge": {
"command": "npx",
"args": ["-y", "contextforge-mcp"],
"env": {
"CONTEXTFORGE_API_KEY": "your-api-key-here"
}
}
}
}Restart Claude Desktop.
Claude Code (CLI)
claude mcp add contextforge -s user \
-e CONTEXTFORGE_API_KEY=your-api-key-here \
-- npx -y contextforge-mcpRestart Claude Code and run /mcp to verify it's connected.
Cursor
Add to your Cursor MCP settings:
{
"mcpServers": {
"contextforge": {
"command": "npx",
"args": ["-y", "contextforge-mcp"],
"env": {
"CONTEXTFORGE_API_KEY": "your-api-key-here"
}
}
}
}GitHub Copilot (VS Code)
Add to your Copilot MCP config:
{
"servers": {
"contextforge": {
"command": "npx",
"args": ["-y", "contextforge-mcp"],
"env": {
"CONTEXTFORGE_API_KEY": "your-api-key-here"
}
}
}
}4. Initialize your project (recommended)
With v0.5.1+ the server auto-loads memory on supporting clients (see the note at the top), so this step is optional but recommended: it reinforces the behavior, covers clients that don't honor server instructions, and fully overrides the built-in file-based memory.
Set up your project so your AI editor always prefers ContextForge memory:
npx contextforge-mcp initBy default, init auto-detects which editor your project uses and writes three rule sections and two hooks:
Memory rules — route memory questions to ContextForge instead of the built-in file memory
Session Presence rules — make parallel sessions check for each other at conversation start and before big changes
Startup Context rules — load a short project summary (overview, open tasks, live sessions) from ContextForge at the start of every conversation
Post-compaction recall hook (Claude Code only) — a
SessionStarthook with matchercompactin.claude/settings.json. When Claude Code compacts a long conversation, the hook runsnpx -y contextforge-mcp recalland re-injects the session objective, memories relevant to what you are working on, your project's 10 most recent memories and pending tasks, so decisions saved in ContextForge survive the summary.Session objective hook (Claude Code only, 0.13.0) — a
UserPromptSubmithook that runs the generated script.claude/hooks/contextforge-objective.cjswith plainnode(~50 ms). It records your prompts to~/.contextforge-mcp/sessions/<session_id>.jsonlon your machine, sorecallcan put the session's objective back after a compaction. The log is pruned after 14 days and never uploaded; see the privacy note below for whatrecallsends.
Files written:
CLAUDE.mdfor Claude Code (signals: existingCLAUDE.mdor.claude/directory).cursorrulesfor Cursor (signals: existing.cursorrulesor.cursor/directory).claude/settings.jsonfor Claude Code — merged, never overwritten; only the two ContextForge hook groups are added.claude/hooks/contextforge-objective.cjsfor Claude Code — the generated objective hook script (safe to commit; refreshed byinitwhen a new version ships; Claude Code's own system turns — prompts that start with an XML-like tag and contain a closing tag — are not logged)
If no editor is detected, both files are generated.
On clients that honor server instructions (Claude Desktop, Claude Code), ContextForge is used automatically even without this step. On other clients — or to guarantee the built-in file-based auto-memory never wins — run init: it writes explicit rules that always route memory to ContextForge.
Override with --editor
Flag | Behavior |
| Generate only |
| Generate only |
| Generate both, skip detection |
Re-running init is idempotent per section — sections you already have are left untouched; missing ones are appended. Upgrading from an older version? Just re-run npx contextforge-mcp init: it adds the new Startup Context section without touching the rest of your file.
Check your version
npx contextforge-mcp --version # also: -v, versionPrints the installed version (e.g. contextforge-mcp 0.5.2).
Surviving compaction (Claude Code)
Long sessions get compacted: Claude Code summarizes the conversation to free space, and the summary keeps the gist but drops details — usually the decisions, and often the task itself. init installs two hooks that fix both:
Objective hook (
UserPromptSubmit) — records each prompt locally so the session's first real request is never lost to the summary.Recall hook (
SessionStart, matchercompact) — fires right after every compaction and prints back, in this order: the session objective and the latest request before the cut; up to 5 memories relevant to the current work (semantic search over the objective, git branch, recent commit subjects and changed files, whatever their age); the project's 10 most recent memories; up to 5 pending tasks; and a reminder to callmemory_queryfor anything older. The whole block stays around 4 KB and is injected once, never pinned, so it does not move the compaction trigger.
The relevance search is one metered query per compaction. It only runs when there is a session objective or you are on a non-default branch (git-only context on main is noise), it runs in parallel with the other fetches under the same 6-second stage deadline, so a slow search can never drop the rest of the block, and CONTEXTFORGE_RECALL_RELEVANCE=0 in the environment turns it off entirely.
The hooks run as plain shell commands, so recall reads your API key from CONTEXTFORGE_API_KEY if set, otherwise from the contextforge server entry in ~/.claude.json (where claude mcp add stores it), otherwise from a project .mcp.json. It needs a linked project (.contextforge in the repo root). If anything is missing it prints nothing and never blocks the session. Note that a CONTEXTFORGE_API_KEY exported in your shell profile wins over ~/.claude.json: if it holds an old key, recall silently prints nothing.
Try it by hand from your project directory:
npx contextforge-mcp recall # prints the block for the newest session in this directory
npx contextforge-mcp recall --stats # local numbers: recalls, objective coverage, follow-up queriesPrivacy: the prompt log and the recall stats live under ~/.contextforge-mcp/ on your machine and are never uploaded. What leaves the machine: after a compaction, recall sends the session objective (at most 600 characters, together with the git branch, recent commit subjects and changed file names) to ContextForge as the search query, the same way memory_query sends a query; it is not stored. Note that .claude/settings.json is usually committed, so teammates who pull the repo get the prompt hook too; they can remove the UserPromptSubmit group to opt out.
Already using ContextForge? (existing users)
Nothing to reconfigure. Update to the latest and restart your AI client:
npm update -g contextforge-mcp # only if you installed globally; npx users get it on next launchYou do not need to re-run init for the auto-load behavior. To get the post-compaction recall hook and the session objective hook, run npx contextforge-mcp init once in each project; it only adds what is missing. Since 0.13.2 the server reminds you once per project when the recall hook is installed but the objective hook is missing or outdated.
Related MCP server: Heimdall MCP Server
Available Tools
ContextForge defines 69 tools across Knowledge Management, GitHub Integration, Issue Tracking, and Collaboration. No capability was ever removed — every tool below is fully callable — but since v0.11.0 your AI client sees only a small subset by default — 15 since v0.13.3 (11 in 0.11.0–0.13.2) (CONTEXTFORGE_TOOLS=lean, the default):
14 core tools — the ten used on the agent's own initiative every session:
memory_query,memory_ingest,memory_check_freshness,memory_confirm,memory_correct,memory_forget,tasks_list,tasks_what_next,session_list,memory_help— plus the four thatCLAUDE.md/.cursorrulesfiles generated before 0.11.0 call by name, kept visible so those files keep working without re-runninginit:session_update,memory_current_project,memory_link_project,memory_list_items.cf_tools— one gateway tool that discovers and runs the other 55 (and can reach the core ones too). Ask your AI naturally ("sync my git commits", "restore from a snapshot", "olvida ese recuerdo viejo") and it searches (English or Spanish) and calls the right tool for you — no need to know an exact name.
Set CONTEXTFORGE_TOOLS=full to expose all 69 tools directly to your client instead, matching the behavior of versions before 0.11.0. See Environment Variables.
Why lean by default: 69 tool schemas cost ~15,000 tokens of context on every session, push past Cursor's 40-tool cap, and contribute to the accuracy degradation several clients show past ~50 tools. The lean set cuts that to ~3,500 tokens (~77% less) while keeping every tool one call away via cf_tools.
Knowledge Management
Tool | Description |
| Save knowledge to memory |
| Search your knowledge semantically |
| List all stored items |
| Remove specific items |
| Save multiple items at once |
| Delete items by filter |
Spaces & Projects
Tool | Description |
| List your spaces |
| Create a new space |
| Delete a space |
| Move space to project |
| List your projects |
| Create a new project |
| Delete a project |
| Link directory to project |
| Unlink directory |
| Show linked project |
GitHub Integration
Tool | Description |
| Connect a GitHub repo |
| List connected repos |
| Activate/deactivate webhook |
| Import existing history |
| List synced commits |
| List synced PRs |
| Disconnect a repo |
Issue Tracking
Tool | Description |
| List your issues |
| Create a new issue |
| Mark as in progress |
| Mark as resolved |
| Resolve by title |
| Assign to collaborator |
| Get recommendation |
Collaboration
Tool | Description |
| Share project by email |
| List collaborators |
Snapshots & Export
Tool | Description |
| Create a backup |
| List all snapshots |
| Restore from backup |
| Delete a snapshot |
| Export to JSON/MD/CSV |
| Import from file |
Utility
Tool | Description |
| View usage statistics |
| Link two items |
| Show help |
Session Presence (multi-session coordination)
Running several Claude Code sessions in parallel (worktrees, agent teams)?
Each MCP process automatically registers itself as a live session and
heartbeats while it runs. On a clean exit the session is removed at once
(a detached helper delivers the goodbye even while the host process is
being killed); if the process dies hard, the session expires ~10 minutes
after its last heartbeat. Three tools let the agent coordinate — session_list
is a core tool and always visible; session_update and session_end are
reached through the cf_tools gateway by default (or set
CONTEXTFORGE_TOOLS=full to see all three directly):
Tool | What it does |
| Declare what this session is working on ("working on the auth module") |
| See other live sessions in the same project and their focus before touching shared areas (pass |
| Explicitly end this session's presence (also automatic on exit) |
By default session_list is scoped to the current project — where work
actually collides. In a multi-project organization, pass all_projects: true
to see every session, or project: "<name-or-id>" to scope elsewhere.
Recommended pattern for your CLAUDE.md: call session_list when a
conversation starts; call session_update when starting or switching tasks.
Natural Language Examples
You don't need to memorize commands — just talk naturally to your AI:
# Knowledge
"Save this: we use PostgreSQL for the main database"
"What database do we use?"
"List my spaces"
# GitHub
"Connect my repo github.com/myuser/myproject"
"What commits did I make today?"
"Show PRs merged this week"
# Issues
"Create an issue: Update the login page design"
"What's pending?"
"What should I work on next?"
"Mark the login issue as done"Environment Variables
Variable | Required | Description |
| Yes | Your API key from the dashboard |
| No | API endpoint (defaults to production) |
| No | Default space for operations |
| No |
|
How it works
ContextForge MCP is a thin client that translates Model Context Protocol tool calls into authenticated HTTP requests against the ContextForge API. Your knowledge is stored, indexed (semantic embeddings), and retrieved on the server side — the MCP client itself is stateless.
This means:
No infra to manage — no local databases, no embeddings to run, no vector stores to maintain
Works everywhere your AI works — same memory across Claude Code, Cursor, Copilot, etc.
Team collaboration — shared projects sync in real time
Dashboard
Manage your memory visually at contextforge.dev:
View and organize your knowledge
Search and filter memories
Manage API keys and billing
Track issues and collaborate
Export and backup data
Development
# Clone and install
git clone https://github.com/alfredoizdev/contextforge-mcp.git
cd contextforge-mcp
npm install
# Build
npm run build
# Run tests
npm test
# Watch mode
npm run devContributing
Issues and pull requests are welcome at github.com/alfredoizdev/contextforge-mcp.
Support
💬 Questions: support@contextforge.app
License
MIT © Alfredo Izquierdo
Available Tools
15 toolscf_toolsADestructive
Discover and run 55 additional ContextForge capabilities that are not in your tool list: git sync and history, spaces, projects, skills, routines, snapshots, import/export, task editing, and collaboration. If you cannot find a ContextForge capability in your tool list, search for it HERE before concluding it does not exist. Two modes: pass query with a plain-language description to search (returns full, ready-to-call schemas of the best matches), or pass name plus args to run one.
Inputs: args, name, query.
memory_check_freshnessARead-onlyIdempotent
Check whether memories linked to git-tracked code (via related_paths on memory_ingest) are stale because the underlying code changed since they were saved. Compares each candidate's saved commit SHA against the current HEAD with a local git diff — no data leaves your machine for the diff itself. Returns up to 3 memories whose related files changed, so you can review and refresh them. Call this periodically or when you suspect saved context might be out of date.
Inputs: space_id.
memory_confirmAIdempotent
Confirm that a memory flagged by memory_check_freshness is still accurate, even though its related code changed. Updates the memory's confirmed timestamp so it won't be flagged again until the code changes further.
Inputs: id (required).
memory_correctA
Update a memory flagged by memory_check_freshness with corrected content after its related code changed. Replaces the stored content and refreshes the git context (current commit SHA) so future freshness checks compare against the new baseline. For a general edit to any memory that is NOT part of a freshness check, use memory_update instead.
Inputs: id (required), content (required), related_paths.
memory_current_projectARead-onlyIdempotent
Check the linked project at the start of every new conversation in a directory. Call this FIRST (alongside memory_query) before answering questions about the user's project, code, or work — it tells you which ContextForge project and spaces are scoped to the current working directory. If linked: false, surface that to the user and suggest memory_link_project. Pair this with memory_query as your two startup-context calls — they are the cheapest possible way to avoid hallucinating about the user's project.
Inputs: no named parameters.
memory_forgetADestructiveIdempotent
Delete a memory flagged by memory_check_freshness that is no longer relevant or accurate. Use this instead of memory_delete when acting directly on a freshness check result.
Inputs: id (required).
memory_helpARead-onlyIdempotent
Show help and usage instructions for ContextForge memory commands
Inputs: no named parameters.
memory_ingestA
Save important context to persistent memory — be proactive. Call this WHENEVER you learn information that would be valuable in a future conversation: project decisions ('we chose Postgres because X'), architectural choices, user preferences, debugging insights, recurring patterns, deadlines, stakeholder context, or any 'remember this' / 'save this' / 'note that' style request from the user. Heuristic: if you would be sad to lose this fact when the conversation ends, ingest it. Better to over-save than to under-save — the memory_query semantic search will surface what's relevant later. Always pass meaningful title and tags so the item is discoverable. Set deduplicate:false to save even if identical content already exists. ROUTE BY TOPIC: pass space:"<name>" matching the memory's topic so it lands in the right space instead of the catch-all default. If you don't yet know the project's spaces, call cf_tools with query "list spaces" once and reuse the result. Saving without space: piles everything into one default space — avoid it in multi-space projects.
Inputs: content (required), tags, title, category, +5 more.
memory_link_projectAIdempotent
Link the current directory to a ContextForge project. When linked, all queries will be automatically filtered to only search within that project's spaces. This creates a .contextforge file in the current directory.
Inputs: create_new, project_name.
memory_list_itemsARead-onlyIdempotent
List all items stored in memory. Shows titles, previews, tags, and creation dates.
Inputs: limit, offset, space_id.
memory_queryARead-onlyIdempotent
Search persistent memory BEFORE answering any project-specific question. You MUST call this tool: (a) at the start of any conversation that touches the user's codebase, work, or decisions, BEFORE generating any response; (b) whenever the user references prior context ('did we', 'we decided', 'remember', 'what did I save', 'last time'); (c) before making architectural or design recommendations — the user's prior decisions live here. Returns semantically relevant stored content. Skipping this when relevant context exists makes you appear to have amnesia and is the #1 reason users abandon persistent memory — always check first, even if you think you remember.
Inputs: query (required), limit, filters, space_id, +3 more.
session_listA
List OTHER live Claude Code sessions working on the same project right now, and what each is focused on. By default it is scoped to THIS session's project (the one linked in the current directory) — that's where work actually collides. If the current directory isn't linked to a project, it falls back to the whole organization. Use it at conversation start and before big changes to avoid stepping on parallel sessions. Pass a specific project to scope elsewhere, or all_projects: true to see every session across the organization. Sessions expire automatically ~10 minutes after their last heartbeat.
Inputs: project, all_projects, include_stale.
session_updateA
Declare or update what THIS Claude Code session is currently working on (live presence). Call it when you start or switch tasks so parallel sessions can avoid stepping on your work. Example focus: 'working on the auth module'.
Inputs: focus (required), label.
tasks_listARead-onlyIdempotent
Call this at the start of any conversation about work, planning, or status — and any time the user asks about pending/open/in-progress tasks. Shows pending tasks by default (sort by due date, urgent first). Use status "all" for everything, "resolved" for completed, "in_progress" for active work. IMPORTANT: Every task includes a dashboard URL (🔗). You MUST include these clickable links when presenting tasks to the user. If you see overdue tasks (past due date), surface them at the top of your response.
Inputs: limit, scope, status, project_id.
tasks_what_nextARead-onlyIdempotent
Call this whenever the user asks what they should work on, what's next, what's pending, or how to start the day. Trigger phrases include: 'what should I do', 'where do I start', 'qué hago hoy', 'next task', 'I have time, what's open'. Returns the highest-priority unresolved task assigned to the user, with due date and priority. Always include the dashboard URL (🔗) in your reply so the user can click through. Prefer this over generic answers when the user seems unsure about priorities — it gives a concrete next action.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Most tools have crisp, distinct purposes (ingest vs query vs list_items, link_project vs current_project, session_update vs session_list), and the confirm/correct/forget trio is explicitly scoped to freshness-check results. The main overlaps are tasks_list vs tasks_what_next (both surface pending tasks) and the catch-all cf_tools, which makes agents uncertain whether a capability lives in the visible list or behind the gateway.
A clear namespace_prefix_verb_noun convention runs through memory_*, tasks_*, and session_* (memory_list_items, memory_check_freshness, tasks_list, session_update). Deviations are minor: cf_tools breaks the namespaced verb pattern entirely, and a few names are noun-only or state-like (memory_current_project, memory_help).
15 top-level tools sit at the top of the comfortable range and each maps to a real workflow (memory lifecycle, tasks, sessions, project scoping). The count is kept sane by pushing 55 capabilities behind cf_tools, though memory_confirm/correct/forget could plausibly collapse into one parameterized tool.
The memory surface covers list/create/search/delete, but general update and delete are absent from the visible list — descriptions reference memory_update and memory_delete as if they were callable, which is a dead end agents will hit. Task creation/completion and session teardown are also missing, forcing agents through cf_tools for routine CRUD.
Maintenance
Related MCP Connectors
Shared memory for coding agents. Stop re-explaining your codebase every session.
Shared project memory that keeps teammates and AI agents aligned across sessions.
Project memory, documentation and controlled secret access for AI coding agents.
Shared, scoped, reviewable team memory for AI coding agents.
Related MCP Servers
- AlicenseBqualityCmaintenanceProvides AI assistants with persistent memory of your project architecture, development history, and technical decisions, allowing them to give context-aware coding help without needing repeated explanations.1661 npm2MIT
- 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
- AlicenseAqualityDmaintenanceEnables AI coding assistants to store and retrieve persistent long-term memory across sessions, remembering project preferences, build steps, and architecture decisions.4MIT
- AlicenseNot gradedqualityBmaintenanceProvides persistent long-term memory (semantic RAG) for AI coding assistants, enabling them to store and semantically search code and documentation across chat sessions without token limits.5MIT