purecontext-mcp 1.5.2 → 1.11.0

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.
Files changed (196) hide show
  1. package/AGENT_INSTRUCTIONS.md +18 -10
  2. package/AGENT_REFERENCE.md +684 -561
  3. package/CHANGELOG.md +567 -445
  4. package/CODE-HISTORY.md +29 -1
  5. package/FRAMEWORK-ADAPTERS.md +368 -351
  6. package/FULL-INSTALLATION-GUIDE.md +351 -341
  7. package/README.md +411 -339
  8. package/REFACTORING-SAFELY.md +338 -279
  9. package/SAFE-CHANGES.md +208 -156
  10. package/USER-GUIDE.md +3 -1
  11. package/WHY-PURECONTEXT.md +103 -73
  12. package/WORKFLOW-PR-REVIEW.md +245 -199
  13. package/dist/adapters/astro-preprocessor.d.ts +25 -0
  14. package/dist/adapters/astro-preprocessor.d.ts.map +1 -0
  15. package/dist/adapters/astro-preprocessor.js +50 -0
  16. package/dist/adapters/astro-preprocessor.js.map +1 -0
  17. package/dist/adapters/astro.d.ts +13 -0
  18. package/dist/adapters/astro.d.ts.map +1 -0
  19. package/dist/adapters/astro.js +83 -0
  20. package/dist/adapters/astro.js.map +1 -0
  21. package/dist/adapters/detect-utils.d.ts +38 -0
  22. package/dist/adapters/detect-utils.d.ts.map +1 -0
  23. package/dist/adapters/detect-utils.js +95 -0
  24. package/dist/adapters/detect-utils.js.map +1 -0
  25. package/dist/adapters/nuxt.d.ts +20 -0
  26. package/dist/adapters/nuxt.d.ts.map +1 -1
  27. package/dist/adapters/nuxt.js +128 -13
  28. package/dist/adapters/nuxt.js.map +1 -1
  29. package/dist/adapters/svelte-preprocessor.d.ts +29 -0
  30. package/dist/adapters/svelte-preprocessor.d.ts.map +1 -0
  31. package/dist/adapters/svelte-preprocessor.js +83 -0
  32. package/dist/adapters/svelte-preprocessor.js.map +1 -0
  33. package/dist/adapters/svelte.d.ts +13 -0
  34. package/dist/adapters/svelte.d.ts.map +1 -0
  35. package/dist/adapters/svelte.js +96 -0
  36. package/dist/adapters/svelte.js.map +1 -0
  37. package/dist/adapters/vue.d.ts.map +1 -1
  38. package/dist/adapters/vue.js +87 -20
  39. package/dist/adapters/vue.js.map +1 -1
  40. package/dist/bin.d.ts +16 -0
  41. package/dist/bin.d.ts.map +1 -0
  42. package/dist/bin.js +21 -0
  43. package/dist/bin.js.map +1 -0
  44. package/dist/cli/hooks.d.ts +2 -2
  45. package/dist/cli/hooks.d.ts.map +1 -1
  46. package/dist/cli/hooks.js +123 -135
  47. package/dist/cli/hooks.js.map +1 -1
  48. package/dist/cli/install-writers.d.ts.map +1 -1
  49. package/dist/cli/install-writers.js +281 -36
  50. package/dist/cli/install-writers.js.map +1 -1
  51. package/dist/cli/resolve-node.d.ts +53 -0
  52. package/dist/cli/resolve-node.d.ts.map +1 -0
  53. package/dist/cli/resolve-node.js +84 -0
  54. package/dist/cli/resolve-node.js.map +1 -0
  55. package/dist/config/config-loader.js +24 -0
  56. package/dist/config/config-loader.js.map +1 -1
  57. package/dist/config/config-schema.d.ts +71 -0
  58. package/dist/config/config-schema.d.ts.map +1 -1
  59. package/dist/config/config-schema.js +102 -0
  60. package/dist/config/config-schema.js.map +1 -1
  61. package/dist/core/db/api-keys.d.ts +1 -1
  62. package/dist/core/db/api-keys.d.ts.map +1 -1
  63. package/dist/core/db/api-keys.js +39 -39
  64. package/dist/core/db/api-keys.js.map +1 -1
  65. package/dist/core/db/co-change-store.d.ts +34 -0
  66. package/dist/core/db/co-change-store.d.ts.map +1 -0
  67. package/dist/core/db/co-change-store.js +78 -0
  68. package/dist/core/db/co-change-store.js.map +1 -0
  69. package/dist/core/db/schema.d.ts +3 -3
  70. package/dist/core/db/schema.d.ts.map +1 -1
  71. package/dist/core/db/schema.js +12 -30
  72. package/dist/core/db/schema.js.map +1 -1
  73. package/dist/core/db/sqlite-loader.d.ts +51 -0
  74. package/dist/core/db/sqlite-loader.d.ts.map +1 -0
  75. package/dist/core/db/sqlite-loader.js +94 -0
  76. package/dist/core/db/sqlite-loader.js.map +1 -0
  77. package/dist/core/db/wasm-sqlite.d.ts +4 -0
  78. package/dist/core/db/wasm-sqlite.d.ts.map +1 -0
  79. package/dist/core/db/wasm-sqlite.js +270 -0
  80. package/dist/core/db/wasm-sqlite.js.map +1 -0
  81. package/dist/core/diff-parser.d.ts.map +1 -1
  82. package/dist/core/diff-parser.js +6 -1
  83. package/dist/core/diff-parser.js.map +1 -1
  84. package/dist/core/git-log-reader.d.ts +28 -0
  85. package/dist/core/git-log-reader.d.ts.map +1 -1
  86. package/dist/core/git-log-reader.js +74 -3
  87. package/dist/core/git-log-reader.js.map +1 -1
  88. package/dist/core/index-manager.d.ts.map +1 -1
  89. package/dist/core/index-manager.js +29 -3
  90. package/dist/core/index-manager.js.map +1 -1
  91. package/dist/core/indexing-worker.d.ts +2 -0
  92. package/dist/core/indexing-worker.d.ts.map +1 -1
  93. package/dist/core/indexing-worker.js +2 -0
  94. package/dist/core/indexing-worker.js.map +1 -1
  95. package/dist/core/watcher/file-watcher.d.ts +6 -0
  96. package/dist/core/watcher/file-watcher.d.ts.map +1 -1
  97. package/dist/core/watcher/file-watcher.js +11 -1
  98. package/dist/core/watcher/file-watcher.js.map +1 -1
  99. package/dist/graph/path-resolver.js +86 -17
  100. package/dist/graph/path-resolver.js.map +1 -1
  101. package/dist/index.d.ts +3 -0
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js +11 -1
  104. package/dist/index.js.map +1 -1
  105. package/dist/node-guard.d.ts +15 -0
  106. package/dist/node-guard.d.ts.map +1 -0
  107. package/dist/node-guard.js +33 -0
  108. package/dist/node-guard.js.map +1 -0
  109. package/dist/server/admin-api.d.ts +1 -1
  110. package/dist/server/admin-api.d.ts.map +1 -1
  111. package/dist/server/admin-api.js +2 -2
  112. package/dist/server/admin-api.js.map +1 -1
  113. package/dist/server/auth/api-key.d.ts +1 -1
  114. package/dist/server/auth/api-key.d.ts.map +1 -1
  115. package/dist/server/mcp-server.d.ts.map +1 -1
  116. package/dist/server/mcp-server.js +25 -0
  117. package/dist/server/mcp-server.js.map +1 -1
  118. package/dist/server/tools/analyze-diff.d.ts +8 -0
  119. package/dist/server/tools/analyze-diff.d.ts.map +1 -1
  120. package/dist/server/tools/analyze-diff.js +80 -16
  121. package/dist/server/tools/analyze-diff.js.map +1 -1
  122. package/dist/server/tools/change-synthesis.d.ts +90 -0
  123. package/dist/server/tools/change-synthesis.d.ts.map +1 -0
  124. package/dist/server/tools/change-synthesis.js +236 -0
  125. package/dist/server/tools/change-synthesis.js.map +1 -0
  126. package/dist/server/tools/co-change.d.ts +65 -0
  127. package/dist/server/tools/co-change.d.ts.map +1 -0
  128. package/dist/server/tools/co-change.js +146 -0
  129. package/dist/server/tools/co-change.js.map +1 -0
  130. package/dist/server/tools/compare-change-impact.d.ts +58 -0
  131. package/dist/server/tools/compare-change-impact.d.ts.map +1 -0
  132. package/dist/server/tools/compare-change-impact.js +0 -0
  133. package/dist/server/tools/compare-change-impact.js.map +1 -0
  134. package/dist/server/tools/find-refactoring-opportunities.d.ts +1 -1
  135. package/dist/server/tools/get-architecture-snapshot.d.ts.map +1 -1
  136. package/dist/server/tools/get-architecture-snapshot.js +28 -14
  137. package/dist/server/tools/get-architecture-snapshot.js.map +1 -1
  138. package/dist/server/tools/get-churn-metrics.d.ts.map +1 -1
  139. package/dist/server/tools/get-churn-metrics.js +1 -12
  140. package/dist/server/tools/get-churn-metrics.js.map +1 -1
  141. package/dist/server/tools/get-co-change.d.ts +37 -0
  142. package/dist/server/tools/get-co-change.d.ts.map +1 -0
  143. package/dist/server/tools/get-co-change.js +120 -0
  144. package/dist/server/tools/get-co-change.js.map +1 -0
  145. package/dist/server/tools/get-context-bundle.d.ts.map +1 -1
  146. package/dist/server/tools/get-context-bundle.js +56 -3
  147. package/dist/server/tools/get-context-bundle.js.map +1 -1
  148. package/dist/server/tools/get-entry-points.d.ts +1 -1
  149. package/dist/server/tools/get-symbol-risk.d.ts +25 -0
  150. package/dist/server/tools/get-symbol-risk.d.ts.map +1 -0
  151. package/dist/server/tools/get-symbol-risk.js +60 -0
  152. package/dist/server/tools/get-symbol-risk.js.map +1 -0
  153. package/dist/server/tools/get-symbol-source.d.ts +2 -0
  154. package/dist/server/tools/get-symbol-source.d.ts.map +1 -1
  155. package/dist/server/tools/get-symbol-source.js +18 -1
  156. package/dist/server/tools/get-symbol-source.js.map +1 -1
  157. package/dist/server/tools/index-repo.d.ts.map +1 -1
  158. package/dist/server/tools/index-repo.js +8 -2
  159. package/dist/server/tools/index-repo.js.map +1 -1
  160. package/dist/server/tools/prepare-change.d.ts +61 -0
  161. package/dist/server/tools/prepare-change.d.ts.map +1 -0
  162. package/dist/server/tools/prepare-change.js +262 -0
  163. package/dist/server/tools/prepare-change.js.map +1 -0
  164. package/dist/server/tools/search-symbols.d.ts +2 -0
  165. package/dist/server/tools/search-symbols.d.ts.map +1 -1
  166. package/dist/server/tools/search-symbols.js +33 -0
  167. package/dist/server/tools/search-symbols.js.map +1 -1
  168. package/dist/server/tools/symbol-lines.d.ts +25 -0
  169. package/dist/server/tools/symbol-lines.d.ts.map +1 -0
  170. package/dist/server/tools/symbol-lines.js +40 -0
  171. package/dist/server/tools/symbol-lines.js.map +1 -0
  172. package/dist/server/tools/symbol-risk.d.ts +109 -0
  173. package/dist/server/tools/symbol-risk.d.ts.map +1 -0
  174. package/dist/server/tools/symbol-risk.js +251 -0
  175. package/dist/server/tools/symbol-risk.js.map +1 -0
  176. package/dist/server/tools/verify-change.d.ts +40 -0
  177. package/dist/server/tools/verify-change.d.ts.map +1 -0
  178. package/dist/server/tools/verify-change.js +149 -0
  179. package/dist/server/tools/verify-change.js.map +1 -0
  180. package/dist/version.d.ts +1 -1
  181. package/dist/version.d.ts.map +1 -1
  182. package/dist/version.js +1 -1
  183. package/dist/version.js.map +1 -1
  184. package/docs/01-introduction.md +2 -2
  185. package/docs/02-installation.md +97 -89
  186. package/docs/03-quick-start.md +138 -135
  187. package/docs/04-configuration.md +247 -214
  188. package/docs/05-cli-reference.md +236 -219
  189. package/docs/06-tools-reference.md +902 -499
  190. package/docs/14-transport-modes.md +170 -167
  191. package/docs/18-git-history.md +43 -0
  192. package/docs/23-performance.md +123 -121
  193. package/docs/26-troubleshooting.md +249 -234
  194. package/grammars/README.md +88 -0
  195. package/package.json +7 -25
  196. package/AGENT_INSTRUCTIONS_SHORT.md +0 -150
@@ -1,341 +1,351 @@
1
- # Installation
2
-
3
-
4
- ## Prerequisites
5
-
6
- | Requirement | Version | Notes |
7
- |-------------|---------|-------|
8
- | Node.js | >= 18.0.0 | 18, 20, and 22 are tested |
9
- | npm | >= 9.0.0 | Ships with Node 18+ |
10
- | Git | any | Required only for `index_repo` (remote repo cloning) |
11
-
12
- ## Install via npm (recommended)
13
-
14
- ```bash
15
- npm install -g purecontext-mcp@latest
16
- ```
17
-
18
- After this, `purecontext-mcp` is available as a global command.
19
-
20
- If you prefer not to install globally, use `npx` to run without installing:
21
-
22
- ```bash
23
- npx purecontext-mcp@latest
24
- ```
25
-
26
- `npx` downloads the package on first use and caches it. This is the recommended approach for most AI client integrations because it picks up new versions automatically without a manual upgrade step.
27
-
28
- ## Prebuilt binaries
29
-
30
- PureContext uses `better-sqlite3` for SQLite access. Pre-built native binaries are bundled for:
31
-
32
- | Platform | Node 18 | Node 20 | Node 22 |
33
- |----------|---------|---------|---------|
34
- | Windows x64 | ✓ | ✓ | ✓ |
35
- | macOS x64 | ✓ | ✓ | ✓ |
36
- | macOS arm64 | ✓ | ✓ | ✓ |
37
- | Linux x64 | ✓ | ✓ | ✓ |
38
- | Linux arm64 | ✓ | ✓ | ✓ |
39
-
40
- When a prebuilt binary matches your platform, `npm install` completes without any native compilation. No Python, no `node-gyp`, no build tools needed.
41
-
42
- If your platform/Node combination is not in the table above, `npm install` will attempt a native compile. You will need:
43
- - Python 3.x
44
- - A C++ compiler (MSVC on Windows, clang/gcc on macOS/Linux)
45
- - `node-gyp`: `npm install -g node-gyp`
46
-
47
- ---
48
-
49
- ## Connecting to your AI client
50
-
51
- PureContext works with any MCP-compatible AI client. Choose the setup that matches your environment.
52
-
53
- ### Claude Code (CLI)
54
-
55
- ```bash
56
- claude mcp add purecontext-mcp -- npx purecontext-mcp@latest
57
- ```
58
-
59
- Verify:
60
-
61
- ```bash
62
- claude mcp list
63
- # purecontext-mcp connected npx purecontext-mcp
64
- ```
65
-
66
- ### Claude Desktop
67
-
68
- Edit `~/.claude/claude_desktop_config.json` (create it if it doesn't exist):
69
-
70
- ```json
71
- {
72
- "mcpServers": {
73
- "purecontext": {
74
- "command": "npx",
75
- "args": ["purecontext-mcp@latest"]
76
- }
77
- }
78
- }
79
- ```
80
-
81
- If you installed globally (`npm install -g purecontext-mcp`), you can use the binary directly:
82
-
83
- ```json
84
- {
85
- "mcpServers": {
86
- "purecontext": {
87
- "command": "purecontext-mcp@latest"
88
- }
89
- }
90
- }
91
- ```
92
-
93
- Restart Claude Desktop after saving the file.
94
-
95
- ### Cursor
96
-
97
- Create or edit `.cursor/mcp.json` in your project directory for a project-scoped connection, or `~/.cursor/mcp.json` for a global one:
98
-
99
- ```json
100
- {
101
- "mcpServers": {
102
- "purecontext": {
103
- "command": "npx",
104
- "args": ["purecontext-mcp@latest"]
105
- }
106
- }
107
- }
108
- ```
109
-
110
- Reload the Cursor window after saving (`Ctrl+Shift+P` → "Developer: Reload Window").
111
-
112
- ### Windsurf
113
-
114
- Open Windsurf Settings and navigate to the MCP section, or edit the MCP configuration file directly:
115
-
116
- ```json
117
- {
118
- "mcpServers": {
119
- "purecontext": {
120
- "command": "npx",
121
- "args": ["purecontext-mcp@latest"]
122
- }
123
- }
124
- }
125
- ```
126
-
127
- ### VS Code (with MCP support)
128
-
129
- Create `.vscode/mcp.json` in your project:
130
-
131
- ```json
132
- {
133
- "servers": {
134
- "purecontext": {
135
- "type": "stdio",
136
- "command": "npx",
137
- "args": ["purecontext-mcp@latest"]
138
- }
139
- }
140
- }
141
- ```
142
-
143
- ### Connecting to a shared team server (HTTP)
144
-
145
- If your team runs a shared PureContext server, connect with an HTTP transport instead of launching a local process. The config format is the same across all clients — only the transport section changes:
146
-
147
- **Claude Code CLI:**
148
-
149
- ```bash
150
- claude mcp add purecontext-shared \
151
- --transport http \
152
- --url https://purecontext.yourcompany.com/mcp/sse \
153
- --header "Authorization: Bearer pctx_yourpersonalkey"
154
- ```
155
-
156
- **Claude Desktop / Cursor / Windsurf (config file):**
157
-
158
- ```json
159
- {
160
- "mcpServers": {
161
- "purecontext": {
162
- "transport": "http",
163
- "url": "https://purecontext.yourcompany.com/mcp/sse",
164
- "headers": {
165
- "Authorization": "Bearer pctx_yourpersonalkey"
166
- }
167
- }
168
- }
169
- }
170
- ```
171
-
172
- Your API key is issued by your team's PureContext administrator. See [Team Setup](15-team-setup.md) for how to deploy and manage a shared server.
173
-
174
- ---
175
-
176
- ## Teaching your AI agent to use PureContext well
177
-
178
- Installing PureContext gives your AI agent access to the tools. Adding the agent instructions tells it *how* to use them efficiently — which tool to pick for each situation, in what order to call them, and what patterns to avoid.
179
-
180
- Without them, an AI agent given access to PureContext may default to reading entire files (wasting tokens) rather than using `search_symbols`, or may not know to call `list_repos` first to get the `repoId` required by every tool. The instructions encode the correct workflow: check if indexed → search by name or meaning → retrieve source only for what you'll use.
181
-
182
- ### Recommended: `purecontext-mcp install`
183
-
184
- PureContext ships with a multi-IDE installer that writes the workflow rules into the conventions file each tool expects. Run it once inside your project root:
185
-
186
- ```bash
187
- npx purecontext-mcp install all
188
- ```
189
-
190
- This auto-detects which AI tools are configured in the project (by looking for marker files such as `.cursor/`, `.windsurfrules`, `CLAUDE.md`, `.continue/`, etc.) and installs the rules for each.
191
-
192
- When no `--scope` flag is given, the CLI prompts you to choose where to install:
193
-
194
- ```
195
- Where should PureContext be installed?
196
- 1) Local — this project only
197
- 2) Global — all projects (user-level config)
198
- 3) Both
199
- ```
200
-
201
- Pass `--scope` to skip the prompt:
202
-
203
- ```bash
204
- npx purecontext-mcp install all --scope=local # this project only
205
- npx purecontext-mcp install all --scope=global # user-level, all projects
206
- npx purecontext-mcp install all --scope=both # both places at once
207
- ```
208
-
209
- For a single tool:
210
-
211
- ```bash
212
- npx purecontext-mcp install cursor --scope=global
213
- npx purecontext-mcp install windsurf
214
- npx purecontext-mcp install continue
215
- # ...etc.
216
- ```
217
-
218
- Useful flags:
219
-
220
- ```bash
221
- npx purecontext-mcp install --list # show detection state, write nothing
222
- npx purecontext-mcp install all --dry-run # preview which writers would run
223
- ```
224
-
225
- ### Supported tools
226
-
227
- | Tool | Local | Global | Notes |
228
- |------|-------|--------|-------|
229
- | `claude` | `CLAUDE.md` in project | `~/.claude/CLAUDE.md` + hooks | Global installs PostToolUse re-index, PreCompact snapshot, and edit guard. |
230
- | `cursor` | `.cursor/rules/purecontext.mdc` | `~/.cursor/rules/purecontext.mdc` | MDC frontmatter with `alwaysApply: true`. |
231
- | `windsurf` | `.windsurfrules` | `~/.windsurfrules` | Marked block appended or replaced in place. |
232
- | `continue` | `.continue/config.json` | `~/.continue/config.json` | JSON-aware merge; other fields are preserved. |
233
- | `cline` | `.clinerules` | local only | No known global config path. |
234
- | `roo-code` | `.roo/rules-code.md` | local only | No known global config path. |
235
- | `vscode` | `.github/copilot-instructions.md` | local only | Picked up by GitHub Copilot in VS Code. |
236
- | `claude-desktop` | always global | always global | Merges MCP server entry; leaves other servers untouched. |
237
-
238
- ### Idempotency
239
-
240
- Every writer is safe to re-run. The Markdown writers wrap their content in HTML comment markers:
241
-
242
- ```html
243
- <!-- purecontext-mcp-start -->
244
- ... PureContext workflow rules ...
245
- <!-- purecontext-mcp-end -->
246
- ```
247
-
248
- On re-run, the marked block is replaced in place. Anything outside the markers (your own rules, other tools' rules) is preserved. The JSON writers (`continue`, `claude-desktop`) parse and merge structurally rather than re-emitting the whole file.
249
-
250
- ### Manual install (if you'd rather paste)
251
-
252
- The two source-of-truth files are at the repository root:
253
-
254
- - **`AGENT_INSTRUCTIONS_SHORT.md`** Compact (~2 KB). Mandatory first step, tool selection table, core rules, common usage patterns. Use for agents with limited system prompt space.
255
- - **`AGENT_INSTRUCTIONS.md`** — Full (~15 KB). Adds parameter notes, every usage pattern, known limitations, decision trees, anti-patterns. Use for complex multi-step workflows.
256
-
257
- To use these manually:
258
-
259
- ```bash
260
- # Claude Code
261
- cat AGENT_INSTRUCTIONS_SHORT.md >> CLAUDE.md
262
-
263
- # Cursor — paste into .cursorrules or via Cursor Settings → Rules
264
- # Windsurfpaste into .windsurfrules or workspace memory
265
- # Anything else paste into whatever rule/memory config it supports
266
- ```
267
-
268
- ---
269
-
270
- ## Verifying the installation
271
-
272
- ```bash
273
- purecontext-mcp --version
274
- # 1.x.x
275
-
276
- purecontext-mcp config --check
277
- # ✓ Node.js 20.11.0
278
- # ✓ SQLite (better-sqlite3 9.x)
279
- # ✓ Grammar: tree-sitter-typescript.wasm
280
- # Grammar: tree-sitter-javascript.wasm
281
- # ... (all 34 grammars)
282
- # ✓ Config: ~/.purecontext/config.json
283
- ```
284
-
285
- `config --check` validates the installation, verifies all grammar files are present, and reports the effective configuration.
286
-
287
- ## Upgrading
288
-
289
- Run the command that matches how you installed PureContext:
290
-
291
- **Installed with Volta:**
292
- ```bash
293
- volta install purecontext-mcp
294
- ```
295
-
296
- **Installed with npm globally:**
297
- ```bash
298
- npm install -g purecontext-mcp@latest
299
- ```
300
-
301
- **Running via npx (no global install):** npx may serve a cached older version. Force the latest:
302
- ```bash
303
- npx purecontext-mcp@latest
304
- ```
305
- To always get the latest version automatically, use `purecontext-mcp@latest` in your MCP client config instead of the bare package name.
306
-
307
- **Installed from source:**
308
- ```bash
309
- cd /path/to/purecontext-mcp
310
- git pull
311
- npm install
312
- npm run build
313
- ```
314
-
315
- > **Note:** `npm update -g purecontext-mcp` does not work reliably use `npm install -g purecontext-mcp@latest` instead.
316
-
317
- Index files (SQLite databases) are forward-compatible within a major version. After upgrading from `1.x` to `1.y`, existing indexes continue to work. A major version upgrade (e.g., `1.x` → `2.0`) may require a re-index — the CLI will warn if it detects an incompatible index version.
318
-
319
- ## Install from source
320
-
321
- Use this when contributing, testing unreleased features, or running a local build.
322
-
323
- ```bash
324
- git clone <repository-url> purecontext-mcp
325
- cd purecontext-mcp
326
- npm install
327
- npm run build
328
- npm link # makes 'purecontext-mcp' available globally from this build
329
- ```
330
-
331
- ## Uninstalling
332
-
333
- ```bash
334
- npm uninstall -g purecontext-mcp
335
- ```
336
-
337
- This removes the binaries. Index files and configuration are not removed. To clean everything up:
338
-
339
- ```bash
340
- rm -rf ~/.purecontext # Removes indexes, config, savings stats
341
- ```
1
+ # Installation
2
+
3
+
4
+ ## Prerequisites
5
+
6
+ | Requirement | Version | Notes |
7
+ |-------------|---------|-------|
8
+ | Node.js | >= 18.0.0 | 18, 20, and 22 are tested |
9
+ | npm | >= 9.0.0 | Ships with Node 18+ |
10
+ | Git | any | Required only for `index_repo` (remote repo cloning) |
11
+
12
+ ## Install via npm (recommended)
13
+
14
+ ```bash
15
+ npm install -g purecontext-mcp@latest
16
+ ```
17
+
18
+ After this, `purecontext-mcp` is available as a global command.
19
+
20
+ If you prefer not to install globally, use `npx` to run without installing:
21
+
22
+ ```bash
23
+ npx purecontext-mcp@latest
24
+ ```
25
+
26
+ `npx` downloads the package on first use and caches it. This is the recommended approach for most AI client integrations because it picks up new versions automatically without a manual upgrade step.
27
+
28
+ ## Prebuilt binaries
29
+
30
+ PureContext uses `better-sqlite3` for SQLite access. Pre-built native binaries are bundled for:
31
+
32
+ | Platform | Node 18 | Node 20 | Node 22 |
33
+ |----------|---------|---------|---------|
34
+ | Windows x64 | ✓ | ✓ | ✓ |
35
+ | macOS x64 | ✓ | ✓ | ✓ |
36
+ | macOS arm64 | ✓ | ✓ | ✓ |
37
+ | Linux x64 | ✓ | ✓ | ✓ |
38
+ | Linux arm64 | ✓ | ✓ | ✓ |
39
+
40
+ When a prebuilt binary matches your platform, `npm install` completes without any native compilation. No Python, no `node-gyp`, no build tools needed.
41
+
42
+ If your platform/Node combination is not in the table above, `npm install` will attempt a native compile. You will need:
43
+ - Python 3.x
44
+ - A C++ compiler (MSVC on Windows, clang/gcc on macOS/Linux)
45
+ - `node-gyp`: `npm install -g node-gyp`
46
+
47
+ ---
48
+
49
+ ## Connecting to your AI client
50
+
51
+ PureContext works with any MCP-compatible AI client. Choose the setup that matches your environment.
52
+
53
+ ### Claude Code (CLI)
54
+
55
+ Easiest — let the installer register the server (pinned to your global Node) and add the workflow rules in one step:
56
+
57
+ ```bash
58
+ npx purecontext-mcp@latest install claude
59
+ ```
60
+
61
+ Or register the server manually:
62
+
63
+ ```bash
64
+ claude mcp add purecontext-mcp -- npx purecontext-mcp@latest
65
+ ```
66
+
67
+ Verify:
68
+
69
+ ```bash
70
+ claude mcp list
71
+ # purecontext-mcp connected npx purecontext-mcp
72
+ ```
73
+
74
+ ### Claude Desktop
75
+
76
+ Edit `~/.claude/claude_desktop_config.json` (create it if it doesn't exist):
77
+
78
+ ```json
79
+ {
80
+ "mcpServers": {
81
+ "purecontext": {
82
+ "command": "npx",
83
+ "args": ["purecontext-mcp@latest"]
84
+ }
85
+ }
86
+ }
87
+ ```
88
+
89
+ If you installed globally (`npm install -g purecontext-mcp`), you can use the binary directly:
90
+
91
+ ```json
92
+ {
93
+ "mcpServers": {
94
+ "purecontext": {
95
+ "command": "purecontext-mcp@latest"
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ Restart Claude Desktop after saving the file.
102
+
103
+ ### Cursor
104
+
105
+ Create or edit `.cursor/mcp.json` in your project directory for a project-scoped connection, or `~/.cursor/mcp.json` for a global one:
106
+
107
+ ```json
108
+ {
109
+ "mcpServers": {
110
+ "purecontext": {
111
+ "command": "npx",
112
+ "args": ["purecontext-mcp@latest"]
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ Reload the Cursor window after saving (`Ctrl+Shift+P` → "Developer: Reload Window").
119
+
120
+ ### Windsurf
121
+
122
+ Open Windsurf Settings and navigate to the MCP section, or edit the MCP configuration file directly:
123
+
124
+ ```json
125
+ {
126
+ "mcpServers": {
127
+ "purecontext": {
128
+ "command": "npx",
129
+ "args": ["purecontext-mcp@latest"]
130
+ }
131
+ }
132
+ }
133
+ ```
134
+
135
+ ### VS Code (with MCP support)
136
+
137
+ Create `.vscode/mcp.json` in your project:
138
+
139
+ ```json
140
+ {
141
+ "servers": {
142
+ "purecontext": {
143
+ "type": "stdio",
144
+ "command": "npx",
145
+ "args": ["purecontext-mcp@latest"]
146
+ }
147
+ }
148
+ }
149
+ ```
150
+
151
+ ### Connecting to a shared team server (HTTP)
152
+
153
+ If your team runs a shared PureContext server, connect with an HTTP transport instead of launching a local process. The config format is the same across all clients — only the transport section changes:
154
+
155
+ **Claude Code CLI:**
156
+
157
+ ```bash
158
+ claude mcp add purecontext-shared \
159
+ --transport http \
160
+ --url https://purecontext.yourcompany.com/mcp/sse \
161
+ --header "Authorization: Bearer pctx_yourpersonalkey"
162
+ ```
163
+
164
+ **Claude Desktop / Cursor / Windsurf (config file):**
165
+
166
+ ```json
167
+ {
168
+ "mcpServers": {
169
+ "purecontext": {
170
+ "transport": "http",
171
+ "url": "https://purecontext.yourcompany.com/mcp/sse",
172
+ "headers": {
173
+ "Authorization": "Bearer pctx_yourpersonalkey"
174
+ }
175
+ }
176
+ }
177
+ }
178
+ ```
179
+
180
+ Your API key is issued by your team's PureContext administrator. See [Team Setup](15-team-setup.md) for how to deploy and manage a shared server.
181
+
182
+ ---
183
+
184
+ ## Teaching your AI agent to use PureContext well
185
+
186
+ Installing PureContext gives your AI agent access to the tools. Adding the agent instructions tells it *how* to use them efficiently — which tool to pick for each situation, in what order to call them, and what patterns to avoid.
187
+
188
+ Without them, an AI agent given access to PureContext may default to reading entire files (wasting tokens) rather than using `search_symbols`, or may not know to call `list_repos` first to get the `repoId` required by every tool. The instructions encode the correct workflow: check if indexed → search by name or meaning → retrieve source only for what you'll use.
189
+
190
+ ### Recommended: `purecontext-mcp install`
191
+
192
+ PureContext ships with a multi-IDE installer that writes the workflow rules into each tool's conventions file **and registers the `purecontext-mcp` MCP server** (pinned to your global Node — so it works in every project regardless of any per-project Node pin). Run it once inside your project root:
193
+
194
+ ```bash
195
+ npx purecontext-mcp install all
196
+ ```
197
+
198
+ This auto-detects which AI tools are configured in the project (by looking for marker files such as `.cursor/`, `.windsurf/`, `CLAUDE.md`, `.continue/`, etc.) and sets up each.
199
+
200
+ When no `--scope` flag is given, the CLI prompts you to choose where to install:
201
+
202
+ ```
203
+ Where should PureContext be installed?
204
+ 1) Local — this project only
205
+ 2) Global all projects (user-level config)
206
+ 3) Both
207
+ ```
208
+
209
+ Pass `--scope` to skip the prompt:
210
+
211
+ ```bash
212
+ npx purecontext-mcp install all --scope=local # this project only
213
+ npx purecontext-mcp install all --scope=global # user-level, all projects
214
+ npx purecontext-mcp install all --scope=both # both places at once
215
+ ```
216
+
217
+ For a single tool:
218
+
219
+ ```bash
220
+ npx purecontext-mcp install cursor --scope=global
221
+ npx purecontext-mcp install windsurf
222
+ npx purecontext-mcp install continue
223
+ # ...etc.
224
+ ```
225
+
226
+ Useful flags:
227
+
228
+ ```bash
229
+ npx purecontext-mcp install --list # show detection state, write nothing
230
+ npx purecontext-mcp install all --dry-run # preview which writers would run
231
+ ```
232
+
233
+ ### Supported tools
234
+
235
+ | Tool | Local | Global | Notes |
236
+ |------|-------|--------|-------|
237
+ | `claude` | `CLAUDE.md` in project | `~/.claude/CLAUDE.md` + hooks | Global installs PostToolUse re-index, PreCompact snapshot, and edit guard. |
238
+ | `cursor` | `.cursor/rules/purecontext.mdc` | `~/.cursor/rules/purecontext.mdc` | MDC frontmatter with `alwaysApply: true`. |
239
+ | `windsurf` | `.windsurf/rules/purecontext.md` | `~/.windsurf/rules/purecontext.md` | Marked block appended or replaced in place. |
240
+ | `continue` | `.continue/config.json` | `~/.continue/config.json` | JSON-aware merge; other fields are preserved. |
241
+ | `cline` | `.clinerules` | local only | No known global config path. |
242
+ | `roo-code` | `.roo/rules-code.md` | local only | No known global config path. |
243
+ | `copilot` | `.github/copilot-instructions.md` | local only | Picked up by GitHub Copilot in VS Code. |
244
+ | `claude-desktop` | always global | always global | Merges MCP server entry; leaves other servers untouched. |
245
+
246
+ In addition to the rules file above, every tool also gets the `purecontext-mcp` **MCP server** registered (pinned to your global Node), so its tools are available — not just referenced by the rules. The server is written to each agent's own MCP config (`~/.cursor/mcp.json`, `~/.codeium/windsurf/mcp_config.json`, Continue's `config.yaml`, VS Code's user `mcp.json` for Copilot, the VS Code globalStorage settings for Cline/Roo, and `claude mcp add` for Claude Code). Where a config location can't be determined, `install` prints the entry to add manually. Set `PCTX_SKIP_MCP_REGISTER=1` to install rules only.
247
+
248
+ ### Idempotency
249
+
250
+ Every writer is safe to re-run. The Markdown writers wrap their content in HTML comment markers:
251
+
252
+ ```html
253
+ <!-- purecontext-mcp-start -->
254
+ ... PureContext workflow rules ...
255
+ <!-- purecontext-mcp-end -->
256
+ ```
257
+
258
+ On re-run, the marked block is replaced in place. Anything outside the markers (your own rules, other tools' rules) is preserved. The JSON writers (`continue`, `claude-desktop`) parse and merge structurally rather than re-emitting the whole file.
259
+
260
+ ### Manual install (if you'd rather paste)
261
+
262
+ The two source-of-truth files are at the repository root:
263
+
264
+ - **`AGENT_INSTRUCTIONS.md`**the onboarding doc: mandatory workflow, tool-selection table, navigation patterns, anti-patterns. Paste into your agent's rules file for complex multi-step workflows. (`npx purecontext-mcp install <tool>` writes a compact, always-on subset automatically.)
265
+ - **`AGENT_REFERENCE.md`**the single canonical reference: a full intent→tool picker, every parameter, every navigation pattern, and known limitations. Read this when an agent needs the authoritative answer.
266
+
267
+ To use these manually:
268
+
269
+ ```bash
270
+ # Claude Code
271
+ cat AGENT_INSTRUCTIONS.md >> CLAUDE.md
272
+
273
+ # Cursor — paste into .cursorrules or via Cursor Settings → Rules
274
+ # Windsurf — paste into .windsurf/rules/purecontext.md or workspace memory
275
+ # Anything else — paste into whatever rule/memory config it supports
276
+ ```
277
+
278
+ ---
279
+
280
+ ## Verifying the installation
281
+
282
+ ```bash
283
+ purecontext-mcp --version
284
+ # 1.x.x
285
+
286
+ purecontext-mcp config --check
287
+ # ✓ Node.js 20.11.0
288
+ # ✓ SQLite (better-sqlite3 9.x)
289
+ # Grammar: tree-sitter-typescript.wasm
290
+ # ✓ Grammar: tree-sitter-javascript.wasm
291
+ # ... (all 34 grammars)
292
+ # ✓ Config: ~/.purecontext/config.json
293
+ ```
294
+
295
+ `config --check` validates the installation, verifies all grammar files are present, and reports the effective configuration.
296
+
297
+ ## Upgrading
298
+
299
+ Run the command that matches how you installed PureContext:
300
+
301
+ **Installed with Volta:**
302
+ ```bash
303
+ volta install purecontext-mcp
304
+ ```
305
+
306
+ **Installed with npm globally:**
307
+ ```bash
308
+ npm install -g purecontext-mcp@latest
309
+ ```
310
+
311
+ **Running via npx (no global install):** npx may serve a cached older version. Force the latest:
312
+ ```bash
313
+ npx purecontext-mcp@latest
314
+ ```
315
+ To always get the latest version automatically, use `purecontext-mcp@latest` in your MCP client config instead of the bare package name.
316
+
317
+ **Installed from source:**
318
+ ```bash
319
+ cd /path/to/purecontext-mcp
320
+ git pull
321
+ npm install
322
+ npm run build
323
+ ```
324
+
325
+ > **Note:** `npm update -g purecontext-mcp` does not work reliably — use `npm install -g purecontext-mcp@latest` instead.
326
+
327
+ Index files (SQLite databases) are forward-compatible within a major version. After upgrading from `1.x` to `1.y`, existing indexes continue to work. A major version upgrade (e.g., `1.x` → `2.0`) may require a re-index — the CLI will warn if it detects an incompatible index version.
328
+
329
+ ## Install from source
330
+
331
+ Use this when contributing, testing unreleased features, or running a local build.
332
+
333
+ ```bash
334
+ git clone <repository-url> purecontext-mcp
335
+ cd purecontext-mcp
336
+ npm install
337
+ npm run build
338
+ npm link # makes 'purecontext-mcp' available globally from this build
339
+ ```
340
+
341
+ ## Uninstalling
342
+
343
+ ```bash
344
+ npm uninstall -g purecontext-mcp
345
+ ```
346
+
347
+ This removes the binaries. Index files and configuration are not removed. To clean everything up:
348
+
349
+ ```bash
350
+ rm -rf ~/.purecontext # Removes indexes, config, savings stats
351
+ ```