context-mcp-server 1.0.5 → 1.0.7
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 +99 -359
- package/codegraph/server.py +37 -46
- package/package.json +3 -2
- package/pyproject.toml +1 -1
- package/src/assests/main.png +0 -0
- package/src/cli.js +35 -8
- package/src/db.js +28 -9
- package/src/hooks/autoContext.js +1 -1
- package/src/templates/CLAUDE.md +8 -3
- package/src/templates/commands/context-resume.md +3 -1
- package/src/templates/skills/SKILL.md +9 -7
- package/src/tools/codegraph.js +12 -78
- package/src/tools/context.js +29 -9
- package/src/tools/gitTools.js +3 -4
- 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/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 architecture saved across sessions, loaded automatically at conversation start
|
|
29
|
+
- **Shared store** — `~/.context-mcp/` is one place 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,133 @@ 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
|
-
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
### Claude Code
|
|
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`:
|
|
83
|
+
For web clients (Claude.ai, ChatGPT), start the HTTP server:
|
|
90
84
|
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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 — no "ctx" prefix inside)
|
|
124
99
|
|
|
125
|
-
|
|
100
|
+
# Context
|
|
101
|
+
ctx list [project] # list entries, discussions, graphs
|
|
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
|
-
|
|
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)
|
|
118
|
+
ctx discuss [project] # view discussions
|
|
143
119
|
```
|
|
144
120
|
|
|
145
121
|
---
|
|
146
122
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
`ctx install --gemini` writes:
|
|
150
|
-
- `.gemini/settings.json` — MCP server config
|
|
151
|
-
- `GEMINI.md` — instructions Gemini reads automatically
|
|
123
|
+
## Security
|
|
152
124
|
|
|
153
|
-
|
|
125
|
+
File and git tools are sandboxed to your project root. Pass `rootPath` when calling `context.resume`:
|
|
154
126
|
|
|
155
127
|
```json
|
|
156
|
-
{
|
|
157
|
-
"mcpServers": {
|
|
158
|
-
"context-mcp": {
|
|
159
|
-
"command": "npx",
|
|
160
|
-
"args": ["-y", "context-mcp-server@latest"]
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
128
|
+
{ "action": "resume", "project": "my-app", "rootPath": "/home/user/my-app" }
|
|
164
129
|
```
|
|
165
130
|
|
|
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
|
-
```
|
|
131
|
+
Any file or git operation outside that directory is rejected. Applies to all HTTP-connected clients.
|
|
182
132
|
|
|
183
133
|
---
|
|
184
134
|
|
|
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
|
-
---
|
|
135
|
+
## Features
|
|
205
136
|
|
|
206
|
-
###
|
|
137
|
+
### Memory
|
|
207
138
|
|
|
208
|
-
|
|
139
|
+
- `context.resume` — loads recent entries, discussions, and graph status; registers `rootPath` for sandboxing
|
|
140
|
+
- `context.save` — store decisions, bugs, notes, architecture with type tags
|
|
141
|
+
- `context.get` / `context.update` / `context.delete` — full CRUD
|
|
142
|
+
- `search` — keyword-first, semantic fallback
|
|
143
|
+
- `discussion` — threaded plans with steps and cross-session continuity
|
|
144
|
+
- Auto-deduplication on save; auto-compact at 20 entries
|
|
209
145
|
|
|
210
|
-
|
|
146
|
+
### ContextGraph
|
|
211
147
|
|
|
212
|
-
|
|
213
|
-
ctx online
|
|
214
|
-
```
|
|
148
|
+
> Also called **CodeGraph**. MCP tools use the `codegraph_*` prefix — both names mean the same thing.
|
|
215
149
|
|
|
216
|
-
|
|
150
|
+
**Step 1 — Build** (once per project, runs locally, no API cost):
|
|
217
151
|
|
|
218
|
-
```bash
|
|
219
|
-
ctx online --restart # force restart
|
|
220
|
-
ctx online --port 3200 # use a different port
|
|
221
152
|
```
|
|
222
|
-
|
|
223
|
-
Or start directly:
|
|
224
|
-
|
|
225
|
-
```bash
|
|
226
|
-
context-mcp-http --port 3100 --host localhost --access-git
|
|
153
|
+
codegraph_build(path)
|
|
227
154
|
```
|
|
228
155
|
|
|
229
|
-
|
|
156
|
+
Parses codebase via tree-sitter AST (16 languages, regex fallback). Extracts functions, classes, imports, call edges. Saved to `~/.context-mcp/`.
|
|
230
157
|
|
|
231
|
-
|
|
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`
|
|
158
|
+
**Step 2 — Query** (instant, forever):
|
|
234
159
|
|
|
235
|
-
**View or edit config:**
|
|
236
|
-
|
|
237
|
-
```bash
|
|
238
|
-
ctx settings
|
|
239
160
|
```
|
|
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" }
|
|
161
|
+
codegraph_query(path, question?, node?) → structural question OR single-node lookup (or both)
|
|
162
|
+
codegraph_path(path, from, to) → shortest path between two concepts
|
|
163
|
+
codegraph_nodes(path, type) → list all nodes of a type
|
|
164
|
+
codegraph_report(path) → god nodes, clusters, surprising connections
|
|
249
165
|
```
|
|
250
166
|
|
|
251
|
-
|
|
167
|
+
`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
168
|
|
|
253
|
-
|
|
169
|
+
### File & Git Tools
|
|
254
170
|
|
|
255
|
-
|
|
171
|
+
Available to HTTP-connected clients (Claude.ai, ChatGPT). Local AI clients use their native IDE tools.
|
|
256
172
|
|
|
257
|
-
|
|
258
|
-
|
|
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
|
|
270
|
-
|
|
271
|
-
# Server
|
|
272
|
-
ctx online # start HTTP server (idempotent)
|
|
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
|
|
173
|
+
- `read_file`, `write_file`, `patch_file`, `create_dir`, `list_dir`, `delete_file`
|
|
174
|
+
- `git_status`, `git_diff`, `git_log`, `git_add`, `git_commit`, `git_push`, `git_pull`, `git_branch`, `git_stash`, `git_reset`, `git_show`
|
|
285
175
|
|
|
286
|
-
|
|
287
|
-
ctx benchmark # real token savings report (memory + graph)
|
|
288
|
-
ctx discuss [project] # view discussions
|
|
289
|
-
```
|
|
176
|
+
Enable git tools with `--access-git` flag or `access_git: true` in config.
|
|
290
177
|
|
|
291
178
|
---
|
|
292
179
|
|
|
293
180
|
## Server Flags
|
|
294
181
|
|
|
295
|
-
### `context-mcp` (stdio)
|
|
296
|
-
|
|
297
182
|
```
|
|
298
|
-
context-mcp [
|
|
183
|
+
context-mcp [--data-dir <path>]
|
|
299
184
|
|
|
300
|
-
|
|
301
|
-
--data-dir <path> Override storage directory (default: ~/.context-mcp)
|
|
302
|
-
Also via env: CONTEXT_MCP_DIR=<path>
|
|
303
|
-
--help, -h Show help
|
|
185
|
+
context-mcp-http [--port <number>] [--host <string>] [--access-git] [--data-dir <path>]
|
|
304
186
|
```
|
|
305
187
|
|
|
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
|
-
```
|
|
188
|
+
Default port: `3100`. Default data dir: `~/.context-mcp`.
|
|
319
189
|
|
|
320
190
|
---
|
|
321
191
|
|
|
322
192
|
## Config Reference
|
|
323
193
|
|
|
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
|
-
```
|
|
194
|
+
`~/.context-mcp/contextconfig.json` — auto-created on first run:
|
|
338
195
|
|
|
339
196
|
| Field | Default | Description |
|
|
340
197
|
|-------|---------|-------------|
|
|
341
198
|
| `client_id` | `"context-mcp"` | OAuth client ID |
|
|
342
|
-
| `client_secret` | auto-generated | OAuth signing secret
|
|
199
|
+
| `client_secret` | auto-generated | OAuth signing secret |
|
|
343
200
|
| `port` | `3100` | HTTP server port |
|
|
344
201
|
| `host` | `"localhost"` | HTTP bind host |
|
|
345
202
|
| `access_git` | `false` | Enable git tools for HTTP clients |
|
|
346
|
-
| `public_url` | `null` | Public URL
|
|
203
|
+
| `public_url` | `null` | Public URL for `ctx online` output |
|
|
347
204
|
| `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`.
|
|
205
|
+
| `allowed_origins` | `[]` | Extra CORS origins |
|
|
351
206
|
|
|
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.
|
|
398
|
-
|
|
399
|
-
`ctx install --claude` also writes slash commands into `.claude/commands/`:
|
|
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
|
-
```
|
|
207
|
+
Edit with `ctx settings`.
|
|
468
208
|
|
|
469
209
|
---
|
|
470
210
|
|