context-mcp-server 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -359
- package/codegraph/server.py +37 -46
- package/package.json +4 -3
- package/pyproject.toml +1 -1
- package/src/assests/main.png +0 -0
- package/src/cli.js +69 -57
- package/src/db.js +946 -798
- package/src/guard.js +9 -3
- package/src/migrator.js +124 -0
- package/src/server.js +7 -6
- package/src/templates/AGENTS.md +6 -13
- package/src/templates/CLAUDE.md +6 -12
- package/src/templates/GEMINI.md +6 -13
- package/src/templates/commands/context-resume.md +1 -1
- package/src/templates/commands/save-context.md +1 -1
- package/src/templates/cursor-rules.mdc +3 -3
- package/src/templates/skills/SKILL.md +9 -16
- package/src/templates/windsurf-rules.md +3 -3
- package/src/tools/codegraph.js +8 -77
- package/src/tools/context.js +23 -11
- package/src/tools/gitTools.js +1 -3
- package/src/tools/plan.js +130 -0
- package/uv.lock +1 -1
- package/codegraph/extractors/audio_extractor.py +0 -8
- package/codegraph/extractors/doc_extractor.py +0 -34
- package/codegraph/extractors/image_extractor.py +0 -26
- package/src/tools/discussion.js +0 -123
package/README.md
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="src/assests/main.png" alt="context-mcp" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/context-mcp-server"><img src="https://img.shields.io/npm/v/context-mcp-server?style=flat-square" alt="npm version" /></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/context-mcp-server"><img src="https://img.shields.io/npm/dm/context-mcp-server?style=flat-square" alt="npm downloads" /></a>
|
|
8
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square" alt="License: MIT" /></a>
|
|
9
|
+
<a href="package.json"><img src="https://img.shields.io/node/v/context-mcp-server?style=flat-square" alt="Node.js" /></a>
|
|
10
|
+
</p>
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
Persistent memory and codebase knowledge graph for AI coding assistants — delivered as a single MCP server.
|
|
6
13
|
|
|
7
|
-
|
|
14
|
+
One shared context store across Claude Code, Cursor, Gemini CLI, Codex, Windsurf, VS Code Copilot, Claude.ai, and ChatGPT. Save context from one AI, pick it up in another.
|
|
8
15
|
|
|
9
16
|
---
|
|
10
17
|
|
|
11
18
|
## The Problem
|
|
12
19
|
|
|
13
|
-
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.
|
|
20
|
+
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.
|
|
14
21
|
|
|
15
|
-
This gets worse as projects grow
|
|
22
|
+
This gets worse as projects grow — reading 20 files to answer "what calls this function?" burns thousands of tokens every time.
|
|
16
23
|
|
|
17
24
|
---
|
|
18
25
|
|
|
19
|
-
## What
|
|
26
|
+
## What It Solves
|
|
20
27
|
|
|
21
|
-
**
|
|
22
|
-
|
|
28
|
+
- **Persistent memory** — decisions, bugs, notes, and config saved across sessions, loaded automatically at conversation start
|
|
29
|
+
- **Shared store** — `~/.context-mcp/projects/<name>/` per-project on your machine; all AI tools read and write it
|
|
30
|
+
- **ContextGraph** — build a knowledge graph of your codebase once, answer structural questions in ~500 tokens instead of ~50,000
|
|
23
31
|
|
|
24
|
-
**
|
|
25
|
-
You fix a bug with Claude Code, then open Cursor and it knows nothing about it. context-mcp stores everything in `~/.context-mcp/` — a single shared store on your machine. Any AI that connects reads and writes the same store.
|
|
26
|
-
|
|
27
|
-
**3. Structural understanding costs too many tokens.**
|
|
28
|
-
Reading 20 files to answer "what calls this function?" is wasteful. context-mcp builds a knowledge graph of your codebase once, then answers structural questions in ~500 tokens instead of ~50,000.
|
|
32
|
+
Real measured reduction on this project: **162× fewer tokens**, **99.38% reduction** per conversation.
|
|
29
33
|
|
|
30
34
|
---
|
|
31
35
|
|
|
@@ -35,36 +39,37 @@ Reading 20 files to answer "what calls this function?" is wasteful. context-mcp
|
|
|
35
39
|
npm install -g context-mcp-server
|
|
36
40
|
```
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
Requires Node.js ≥ 18. Installs `context-mcp`, `context-mcp-http`, and the `ctx` CLI.
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
**ContextGraph requires [uv](https://docs.astral.sh/uv/)** (Python runner). Memory tools work without it.
|
|
41
45
|
|
|
42
46
|
```bash
|
|
43
|
-
|
|
47
|
+
# macOS / Linux
|
|
48
|
+
curl -Ls https://astral.sh/uv/install.sh | sh
|
|
49
|
+
|
|
50
|
+
# Windows
|
|
51
|
+
winget install astral-sh.uv
|
|
44
52
|
```
|
|
45
53
|
|
|
46
|
-
|
|
54
|
+
---
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
> ```bash
|
|
50
|
-
> curl -Ls https://astral.sh/uv/install.sh | sh # macOS / Linux
|
|
51
|
-
> winget install astral-sh.uv # Windows
|
|
52
|
-
> ```
|
|
53
|
-
> Memory tools work with npm alone — uv is only needed for `codegraph_build` and graph queries.
|
|
56
|
+
## Quick Start
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
Run from your project root:
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
```bash
|
|
61
|
+
ctx install --initial
|
|
62
|
+
```
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|---------|-------------|
|
|
61
|
-
| `context-mcp` | Stdio MCP server (for local AI clients) |
|
|
62
|
-
| `context-mcp-http` | HTTP MCP server with OAuth 2.0 (for web clients) |
|
|
63
|
-
| `ctx` | Interactive CLI — browse, search, manage context |
|
|
64
|
+
This installs Node.js + Python (ContextGraph) dependencies. Run once after installing the npm package.
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
Then write MCP config + AI instruction files:
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
```bash
|
|
69
|
+
ctx install --all
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
To install for a specific platform only:
|
|
68
73
|
|
|
69
74
|
```bash
|
|
70
75
|
ctx install --claude # Claude Code
|
|
@@ -73,398 +78,132 @@ ctx install --vscode # VS Code Copilot
|
|
|
73
78
|
ctx install --gemini # Gemini CLI
|
|
74
79
|
ctx install --codex # Codex CLI
|
|
75
80
|
ctx install --windsurf # Windsurf
|
|
76
|
-
ctx install --all # all platforms + Python setup at once
|
|
77
81
|
```
|
|
78
82
|
|
|
79
|
-
|
|
83
|
+
For web clients (Claude.ai, ChatGPT), start the HTTP server:
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
`ctx install --claude` writes:
|
|
86
|
-
- `.claude/mcp.json` — MCP server config
|
|
87
|
-
- `CLAUDE.md` — instructions Claude reads automatically at conversation start
|
|
88
|
-
|
|
89
|
-
Manual config — add to `.claude/mcp.json`:
|
|
90
|
-
|
|
91
|
-
```json
|
|
92
|
-
{
|
|
93
|
-
"mcpServers": {
|
|
94
|
-
"context-mcp": {
|
|
95
|
-
"command": "npx",
|
|
96
|
-
"args": ["-y", "context-mcp-server@latest"]
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
85
|
+
```bash
|
|
86
|
+
ctx online # start in background, prints OAuth credentials + URL
|
|
87
|
+
ctx online --restart # force restart
|
|
88
|
+
ctx online --port 3200 # different port
|
|
100
89
|
```
|
|
101
90
|
|
|
102
91
|
---
|
|
103
92
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
`ctx install --cursor` writes:
|
|
107
|
-
- `.cursor/mcp.json` — MCP server config
|
|
108
|
-
- `.cursor/rules/context-mcp.mdc` — Cursor rules file
|
|
109
|
-
|
|
110
|
-
Manual config — add to `.cursor/mcp.json`:
|
|
93
|
+
## CLI Reference
|
|
111
94
|
|
|
112
|
-
|
|
113
|
-
{
|
|
114
|
-
"mcpServers": {
|
|
115
|
-
"context-mcp": {
|
|
116
|
-
"command": "npx",
|
|
117
|
-
"args": ["-y", "context-mcp-server@latest"]
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
```
|
|
95
|
+
Both `ctx` and `context` are aliases for the same CLI.
|
|
122
96
|
|
|
123
|
-
|
|
97
|
+
```bash
|
|
98
|
+
ctx # interactive mode (UI)
|
|
124
99
|
|
|
125
|
-
|
|
100
|
+
# Context
|
|
101
|
+
ctx list [project] # list entries by tree: graph / context / summary / plans
|
|
102
|
+
ctx projects # all projects with graph status + recent entries
|
|
103
|
+
ctx search "query" # keyword → semantic fallback search
|
|
104
|
+
ctx add # add entry interactively
|
|
105
|
+
ctx summary [project] # summarize recent entries
|
|
126
106
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
107
|
+
# Delete
|
|
108
|
+
ctx delete <id-prefix> # delete one entry
|
|
109
|
+
ctx delete project <name> # delete all entries for a project
|
|
130
110
|
|
|
131
|
-
|
|
111
|
+
# Server
|
|
112
|
+
ctx online # start HTTP server (idempotent)
|
|
113
|
+
ctx online --restart # force stop + restart
|
|
114
|
+
ctx settings # view and edit config interactively
|
|
132
115
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"servers": {
|
|
136
|
-
"context-mcp": {
|
|
137
|
-
"type": "stdio",
|
|
138
|
-
"command": "npx",
|
|
139
|
-
"args": ["-y", "context-mcp-server@latest"]
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
116
|
+
# Tools
|
|
117
|
+
ctx benchmark # token savings report (memory + graph)
|
|
143
118
|
```
|
|
144
119
|
|
|
145
120
|
---
|
|
146
121
|
|
|
147
|
-
|
|
122
|
+
## Security
|
|
148
123
|
|
|
149
|
-
`
|
|
150
|
-
- `.gemini/settings.json` — MCP server config
|
|
151
|
-
- `GEMINI.md` — instructions Gemini reads automatically
|
|
152
|
-
|
|
153
|
-
Manual config — add to `.gemini/settings.json`:
|
|
124
|
+
File and git tools are sandboxed to your project root. Pass `rootPath` when calling `context.resume`:
|
|
154
125
|
|
|
155
126
|
```json
|
|
156
|
-
{
|
|
157
|
-
"mcpServers": {
|
|
158
|
-
"context-mcp": {
|
|
159
|
-
"command": "npx",
|
|
160
|
-
"args": ["-y", "context-mcp-server@latest"]
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
127
|
+
{ "action": "resume", "project": "my-app", "rootPath": "/home/user/my-app" }
|
|
164
128
|
```
|
|
165
129
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
### Codex CLI
|
|
169
|
-
|
|
170
|
-
`ctx install --codex` writes:
|
|
171
|
-
- `.codex/config.toml` — MCP server config
|
|
172
|
-
- `AGENTS.md` — instructions Codex reads automatically
|
|
173
|
-
|
|
174
|
-
Manual config — add to `.codex/config.toml`:
|
|
175
|
-
|
|
176
|
-
```toml
|
|
177
|
-
[[mcp_servers]]
|
|
178
|
-
name = "context-mcp"
|
|
179
|
-
command = "npx"
|
|
180
|
-
args = ["-y", "context-mcp-server@latest"]
|
|
181
|
-
```
|
|
130
|
+
Any file or git operation outside that directory is rejected. Applies to all HTTP-connected clients.
|
|
182
131
|
|
|
183
132
|
---
|
|
184
133
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
`ctx install --windsurf` writes:
|
|
188
|
-
- `.windsurf/rules/context-mcp.md` — local rules file (project scope)
|
|
189
|
-
- `~/.codeium/windsurf/mcp_config.json` — global MCP config (merged, not overwritten)
|
|
190
|
-
|
|
191
|
-
Manual config — add to `~/.codeium/windsurf/mcp_config.json`:
|
|
192
|
-
|
|
193
|
-
```json
|
|
194
|
-
{
|
|
195
|
-
"mcpServers": {
|
|
196
|
-
"context-mcp": {
|
|
197
|
-
"command": "npx",
|
|
198
|
-
"args": ["-y", "context-mcp-server@latest"]
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
---
|
|
134
|
+
## Features
|
|
205
135
|
|
|
206
|
-
###
|
|
136
|
+
### Memory
|
|
207
137
|
|
|
208
|
-
|
|
138
|
+
- `context.resume` — loads recent entries, active plans, and graph status; registers `rootPath` for sandboxing
|
|
139
|
+
- `context.save` — store context with 4 types: `decision`, `bug`, `note`, `config`
|
|
140
|
+
- `context.get` / `context.update` / `context.delete` — full CRUD, single or batch
|
|
141
|
+
- `search` — keyword-first, semantic fallback
|
|
142
|
+
- `plan` — auto-triggered when AI makes any plan; saves a markdown summary to a `planDir` you specify
|
|
143
|
+
- Auto-deduplication on save; auto-compact at 20 entries → stored in `summary.json`
|
|
209
144
|
|
|
210
|
-
|
|
145
|
+
### ContextGraph
|
|
211
146
|
|
|
212
|
-
|
|
213
|
-
ctx online
|
|
214
|
-
```
|
|
147
|
+
> Also called **CodeGraph**. MCP tools use the `codegraph_*` prefix — both names mean the same thing.
|
|
215
148
|
|
|
216
|
-
|
|
149
|
+
**Step 1 — Build** (once per project, runs locally, no API cost):
|
|
217
150
|
|
|
218
|
-
```bash
|
|
219
|
-
ctx online --restart # force restart
|
|
220
|
-
ctx online --port 3200 # use a different port
|
|
221
151
|
```
|
|
222
|
-
|
|
223
|
-
Or start directly:
|
|
224
|
-
|
|
225
|
-
```bash
|
|
226
|
-
context-mcp-http --port 3100 --host localhost --access-git
|
|
152
|
+
codegraph_build(path)
|
|
227
153
|
```
|
|
228
154
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
1. Go to Claude.ai → Settings → Integrations → Add MCP Connector
|
|
232
|
-
2. Enter your server URL (e.g. `http://localhost:3100`)
|
|
233
|
-
3. Use the **Client ID** and **Client Secret** from `~/.context-mcp/contextconfig.json`
|
|
155
|
+
Parses codebase via tree-sitter AST (16 languages, regex fallback). Extracts functions, classes, imports, call edges. Build metadata saved to `~/.context-mcp/projects/<name>/graph.json`.
|
|
234
156
|
|
|
235
|
-
**
|
|
157
|
+
**Step 2 — Query** (instant, forever):
|
|
236
158
|
|
|
237
|
-
```bash
|
|
238
|
-
ctx settings
|
|
239
159
|
```
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
File and git tools are sandboxed to your project root. Pass `rootPath` when calling `context.resume` to register it:
|
|
246
|
-
|
|
247
|
-
```json
|
|
248
|
-
{ "action": "resume", "project": "my-app", "rootPath": "/home/user/my-app" }
|
|
160
|
+
codegraph_query(path, question?, node?) → structural question OR single-node lookup (or both)
|
|
161
|
+
codegraph_path(path, from, to) → shortest path between two concepts
|
|
162
|
+
codegraph_nodes(path, type) → list all nodes of a type
|
|
163
|
+
codegraph_report(path) → god nodes, clusters, surprising connections
|
|
249
164
|
```
|
|
250
165
|
|
|
251
|
-
|
|
166
|
+
`codegraph_query` accepts `question` (natural language), `node` (exact/partial name for type + file + deps + callers), or both in one call. Use before reading any files.
|
|
252
167
|
|
|
253
|
-
|
|
168
|
+
### File & Git Tools
|
|
254
169
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
```bash
|
|
258
|
-
ctx # open interactive mode
|
|
259
|
-
|
|
260
|
-
# Context
|
|
261
|
-
ctx list [project] # list entries, discussions, graphs
|
|
262
|
-
ctx projects # all projects with IDs, graph status, recent entries
|
|
263
|
-
ctx search "query" # keyword → semantic fallback search
|
|
264
|
-
ctx add # add entry interactively
|
|
265
|
-
ctx summary [project] # summarize recent entries
|
|
266
|
-
|
|
267
|
-
# Delete
|
|
268
|
-
ctx delete <id-prefix> # delete one entry by ID prefix
|
|
269
|
-
ctx delete project <name|id> # delete all entries for a project
|
|
170
|
+
Available to HTTP-connected clients (Claude.ai, ChatGPT). Local AI clients use their native IDE tools.
|
|
270
171
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
ctx online --restart # force stop + restart
|
|
274
|
-
ctx online --port 3200 # use a different port
|
|
275
|
-
ctx settings # view and edit config interactively
|
|
276
|
-
|
|
277
|
-
# Setup
|
|
278
|
-
ctx install --claude # write MCP config for Claude Code
|
|
279
|
-
ctx install --cursor # write MCP config for Cursor
|
|
280
|
-
ctx install --vscode # write MCP config for VS Code
|
|
281
|
-
ctx install --gemini # write MCP config for Gemini CLI
|
|
282
|
-
ctx install --codex # write MCP config for Codex CLI
|
|
283
|
-
ctx install --windsurf # write MCP config for Windsurf
|
|
284
|
-
ctx install --all # all platforms + Python setup
|
|
172
|
+
- `read_file`, `write_file`, `patch_file`, `create_dir`, `list_dir`, `delete_file`
|
|
173
|
+
- `git_status`, `git_diff`, `git_log`, `git_add`, `git_commit`, `git_push`, `git_pull`, `git_branch`, `git_stash`, `git_reset`, `git_show`
|
|
285
174
|
|
|
286
|
-
|
|
287
|
-
ctx benchmark # real token savings report (memory + graph)
|
|
288
|
-
ctx discuss [project] # view discussions
|
|
289
|
-
```
|
|
175
|
+
Enable git tools with `--access-git` flag or `access_git: true` in config.
|
|
290
176
|
|
|
291
177
|
---
|
|
292
178
|
|
|
293
179
|
## Server Flags
|
|
294
180
|
|
|
295
|
-
### `context-mcp` (stdio)
|
|
296
|
-
|
|
297
181
|
```
|
|
298
|
-
context-mcp [
|
|
182
|
+
context-mcp [--data-dir <path>]
|
|
299
183
|
|
|
300
|
-
|
|
301
|
-
--data-dir <path> Override storage directory (default: ~/.context-mcp)
|
|
302
|
-
Also via env: CONTEXT_MCP_DIR=<path>
|
|
303
|
-
--help, -h Show help
|
|
184
|
+
context-mcp-http [--port <number>] [--host <string>] [--access-git] [--data-dir <path>]
|
|
304
185
|
```
|
|
305
186
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
```
|
|
309
|
-
context-mcp-http [options]
|
|
310
|
-
|
|
311
|
-
Options:
|
|
312
|
-
--port <number> HTTP listen port (default: 3100)
|
|
313
|
-
--host <string> Bind address (default: localhost)
|
|
314
|
-
--access-git Enable git tools for connected clients
|
|
315
|
-
--data-dir <path> Override storage directory (default: ~/.context-mcp)
|
|
316
|
-
Also via env: CONTEXT_MCP_DIR=<path>
|
|
317
|
-
--help, -h Show help
|
|
318
|
-
```
|
|
187
|
+
Default port: `3100`. Default data dir: `~/.context-mcp`.
|
|
319
188
|
|
|
320
189
|
---
|
|
321
190
|
|
|
322
191
|
## Config Reference
|
|
323
192
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
```json
|
|
327
|
-
{
|
|
328
|
-
"client_id": "context-mcp",
|
|
329
|
-
"client_secret": "<auto-generated>",
|
|
330
|
-
"port": 3100,
|
|
331
|
-
"host": "localhost",
|
|
332
|
-
"access_git": false,
|
|
333
|
-
"public_url": null,
|
|
334
|
-
"allowed_redirect_uris": ["https://claude.ai"],
|
|
335
|
-
"allowed_origins": []
|
|
336
|
-
}
|
|
337
|
-
```
|
|
193
|
+
`~/.context-mcp/contextconfig.json` — auto-created on first run:
|
|
338
194
|
|
|
339
195
|
| Field | Default | Description |
|
|
340
196
|
|-------|---------|-------------|
|
|
341
197
|
| `client_id` | `"context-mcp"` | OAuth client ID |
|
|
342
|
-
| `client_secret` | auto-generated | OAuth signing secret
|
|
198
|
+
| `client_secret` | auto-generated | OAuth signing secret |
|
|
343
199
|
| `port` | `3100` | HTTP server port |
|
|
344
200
|
| `host` | `"localhost"` | HTTP bind host |
|
|
345
201
|
| `access_git` | `false` | Enable git tools for HTTP clients |
|
|
346
|
-
| `public_url` | `null` | Public URL
|
|
202
|
+
| `public_url` | `null` | Public URL for `ctx online` output |
|
|
347
203
|
| `allowed_redirect_uris` | `["https://claude.ai"]` | OAuth redirect URI whitelist |
|
|
348
|
-
| `allowed_origins` | `[]` | Extra CORS origins
|
|
349
|
-
|
|
350
|
-
Edit any field interactively with `ctx settings`.
|
|
351
|
-
|
|
352
|
-
---
|
|
353
|
-
|
|
354
|
-
## Features
|
|
355
|
-
|
|
356
|
-
### Memory
|
|
357
|
-
- `context.resume` — loads recent entries, active discussions, and graph status. Pass `rootPath` to sandbox file/git tools to your project directory.
|
|
358
|
-
- `context.save` — store decisions, bugs, notes, code snippets, architecture with type tags
|
|
359
|
-
- `context.get` / `context.update` / `context.delete` — full CRUD
|
|
360
|
-
- `search` — keyword-first, semantic fallback, searches all past context
|
|
361
|
-
- `discussion` — threaded plans with steps, status tracking, cross-session continuity
|
|
362
|
-
- Auto-deduplication on save
|
|
363
|
-
- Auto-compact at 50 entries (oldest entries summarized into a digest)
|
|
364
|
-
- Per-project isolation with stable UUIDs
|
|
365
|
-
|
|
366
|
-
### File & Git Tools (HTTP mode)
|
|
367
|
-
Available to web clients (Claude.ai, ChatGPT) only — local AI clients use their native IDE tools directly.
|
|
368
|
-
|
|
369
|
-
- `read_file`, `write_file`, `patch_file`, `create_dir`, `list_dir`, `delete_file`
|
|
370
|
-
- `git_status`, `git_diff`, `git_log`, `git_add`, `git_commit`, `git_push`, `git_pull`, `git_branch`, `git_stash`, `git_reset`, `git_show`
|
|
371
|
-
|
|
372
|
-
All file and git operations are sandboxed to the registered project root. Enable git tools with `--access-git` or `access_git: true` in config.
|
|
373
|
-
|
|
374
|
-
### ContextGraph (CodeGraph)
|
|
375
|
-
|
|
376
|
-
> Also referred to as **ContextGraph** — the MCP tools use the `codegraph_*` prefix but both names mean the same thing.
|
|
377
|
-
|
|
378
|
-
- `codegraph_build` — AST scan using tree-sitter: functions, classes, imports, edges. Runs locally, no API cost.
|
|
379
|
-
- `codegraph_query` — fetch any details about the codebase using natural language: find functions, classes, files, dependencies, callers
|
|
380
|
-
- `codegraph_explain` — single node: type, file location, all direct connections (depends_on, used_by)
|
|
381
|
-
- `codegraph_path` — shortest path between two concepts
|
|
382
|
-
- `codegraph_nodes` — list all nodes of a given type
|
|
383
|
-
- `codegraph_report` — full graph analysis: god nodes, clusters, surprising connections
|
|
384
|
-
|
|
385
|
-
### Multi-AI Support
|
|
386
|
-
|
|
387
|
-
| AI | Config File | Instructions | Slash Commands |
|
|
388
|
-
|----|------------|--------------|----------------|
|
|
389
|
-
| Claude Code | `.claude/mcp.json` | Skill → `~/.claude/skills/context-mcp/` (global) | ✓ (3 commands) |
|
|
390
|
-
| Cursor | `.cursor/mcp.json` | Rule → `.cursor/rules/context-mcp.mdc` | — |
|
|
391
|
-
| Windsurf | `~/.codeium/windsurf/mcp_config.json` | Rule → `.windsurf/rules/context-mcp.md` | — |
|
|
392
|
-
| Gemini CLI | `.gemini/settings.json` | `GEMINI.md` | — |
|
|
393
|
-
| Codex CLI | `.codex/config.toml` | `AGENTS.md` | — |
|
|
394
|
-
| VS Code Copilot | `.vscode/mcp.json` | — | — |
|
|
395
|
-
| Claude.ai / ChatGPT | HTTP (`ctx online`) | — | — |
|
|
396
|
-
|
|
397
|
-
> Claude Code installs context-mcp as a **skill** (`~/.claude/skills/context-mcp/SKILL.md`) — available globally across all projects, not just the current one. Cursor and Windsurf use their native rules system. Gemini and Codex use plain instruction files since they have no skill/rules system.
|
|
204
|
+
| `allowed_origins` | `[]` | Extra CORS origins |
|
|
398
205
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
| Command | What it does |
|
|
402
|
-
|---------|-------------|
|
|
403
|
-
| `/context-resume` | Resume context for the current project |
|
|
404
|
-
| `/graph-build` | Build or rebuild the ContextGraph |
|
|
405
|
-
| `/save-context` | Save a note, decision, or bug to context |
|
|
406
|
-
|
|
407
|
-
> The context store lives at `~/.context-mcp/` — not inside any tool, IDE, or session. A decision saved in Claude Code is visible in Cursor. A bug logged from Gemini CLI shows up when you resume in Codex.
|
|
408
|
-
|
|
409
|
-
---
|
|
410
|
-
|
|
411
|
-
## Token Reduction
|
|
412
|
-
|
|
413
|
-
| Scenario | Without context-mcp | With context-mcp |
|
|
414
|
-
|----------|-------------------|--------------------|
|
|
415
|
-
| Start of conversation | Paste background, re-explain project | `context.resume` → 15 entries, ~750 tokens |
|
|
416
|
-
| "What calls function X?" | Read 10 files to trace callers | `codegraph_query` → subgraph, ~400 tokens |
|
|
417
|
-
| "What does module Y depend on?" | Read module + all imports | `codegraph_explain` → node + edges, ~200 tokens |
|
|
418
|
-
| Understand architecture | Read 20+ files | Graph built once, queried forever |
|
|
419
|
-
| Remember last session's decision | Ask user or re-derive | `context.resume` loads it automatically |
|
|
420
|
-
|
|
421
|
-
Real measured reduction on this project: **162× fewer tokens**, **99.38% reduction** per conversation.
|
|
422
|
-
|
|
423
|
-
---
|
|
424
|
-
|
|
425
|
-
## Architecture
|
|
426
|
-
|
|
427
|
-
```
|
|
428
|
-
context-mcp/
|
|
429
|
-
├── src/
|
|
430
|
-
│ ├── index.js Stdio MCP server entrypoint
|
|
431
|
-
│ ├── server.js MCP server — registers all tools
|
|
432
|
-
│ ├── db.js JSON store — in-memory cache, debounced writes, project registry
|
|
433
|
-
│ ├── guard.js Path sandboxing — enforces project root on all file/git ops
|
|
434
|
-
│ ├── search.js Keyword + semantic search
|
|
435
|
-
│ ├── summarizer.js Auto-compact summarization
|
|
436
|
-
│ ├── cli.js Interactive CLI (ctx)
|
|
437
|
-
│ ├── http.js HTTP server — OAuth 2.0 + Streamable HTTP transport
|
|
438
|
-
│ ├── config.js Config loader — contextconfig.json + keytar
|
|
439
|
-
│ ├── vector.js Embedding helpers
|
|
440
|
-
│ └── tools/
|
|
441
|
-
│ ├── context.js Memory tool (resume/save/get/update/delete)
|
|
442
|
-
│ ├── discussion.js Discussion tool (threaded plans + steps)
|
|
443
|
-
│ ├── codegraph.js CodeGraph tool — bridge to Python subprocess
|
|
444
|
-
│ ├── search.js Search tool
|
|
445
|
-
│ ├── fileTools.js File read/write (HTTP mode, sandboxed to project root)
|
|
446
|
-
│ ├── gitTools.js Git integration (HTTP mode, sandboxed to project root)
|
|
447
|
-
│ └── errorCheck.js Error checking tool
|
|
448
|
-
├── codegraph/ Python package — AST extraction + graph queries
|
|
449
|
-
│ ├── server.py MCP server — tool definitions + dispatch
|
|
450
|
-
│ ├── scanner.py File walker + classifier (SKIP/BUILD/CODE/CONFIG/DOC/MEDIA)
|
|
451
|
-
│ ├── config.py File type taxonomy
|
|
452
|
-
│ ├── cache.py AST cache (hash-based, incremental)
|
|
453
|
-
│ ├── report.py Graph report generator
|
|
454
|
-
│ ├── extractors/
|
|
455
|
-
│ │ ├── ast_extractor.py Tree-sitter AST (16 languages) + regex fallback
|
|
456
|
-
│ │ └── build_extractor.py Single-node extraction for build files
|
|
457
|
-
│ └── graph/
|
|
458
|
-
│ ├── builder.py NetworkX graph construction
|
|
459
|
-
│ ├── query.py Natural language → subgraph traversal
|
|
460
|
-
│ └── clustering.py Community detection
|
|
461
|
-
└── ~/.context-mcp/ Data directory (outside repo, never committed)
|
|
462
|
-
├── contexts.json
|
|
463
|
-
├── discussions.json
|
|
464
|
-
├── projects.json Project registry — includes rootPath per project
|
|
465
|
-
├── graphs.json Knowledge graph (nodes, edges, communities)
|
|
466
|
-
└── contextconfig.json OAuth config + server settings
|
|
467
|
-
```
|
|
206
|
+
Edit with `ctx settings`.
|
|
468
207
|
|
|
469
208
|
---
|
|
470
209
|
|