purecontext-mcp 1.7.0 → 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 (156) 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/FULL-INSTALLATION-GUIDE.md +351 -341
  6. package/README.md +411 -339
  7. package/REFACTORING-SAFELY.md +338 -279
  8. package/SAFE-CHANGES.md +208 -156
  9. package/USER-GUIDE.md +3 -1
  10. package/WHY-PURECONTEXT.md +103 -73
  11. package/WORKFLOW-PR-REVIEW.md +245 -199
  12. package/dist/bin.d.ts +16 -0
  13. package/dist/bin.d.ts.map +1 -0
  14. package/dist/bin.js +21 -0
  15. package/dist/bin.js.map +1 -0
  16. package/dist/cli/hooks.d.ts.map +1 -1
  17. package/dist/cli/hooks.js +20 -15
  18. package/dist/cli/hooks.js.map +1 -1
  19. package/dist/cli/install-writers.d.ts.map +1 -1
  20. package/dist/cli/install-writers.js +281 -36
  21. package/dist/cli/install-writers.js.map +1 -1
  22. package/dist/cli/resolve-node.d.ts +53 -0
  23. package/dist/cli/resolve-node.d.ts.map +1 -0
  24. package/dist/cli/resolve-node.js +84 -0
  25. package/dist/cli/resolve-node.js.map +1 -0
  26. package/dist/config/config-loader.js +24 -0
  27. package/dist/config/config-loader.js.map +1 -1
  28. package/dist/config/config-schema.d.ts +71 -0
  29. package/dist/config/config-schema.d.ts.map +1 -1
  30. package/dist/config/config-schema.js +102 -0
  31. package/dist/config/config-schema.js.map +1 -1
  32. package/dist/core/db/api-keys.d.ts +1 -1
  33. package/dist/core/db/api-keys.d.ts.map +1 -1
  34. package/dist/core/db/api-keys.js +39 -39
  35. package/dist/core/db/api-keys.js.map +1 -1
  36. package/dist/core/db/co-change-store.d.ts +34 -0
  37. package/dist/core/db/co-change-store.d.ts.map +1 -0
  38. package/dist/core/db/co-change-store.js +78 -0
  39. package/dist/core/db/co-change-store.js.map +1 -0
  40. package/dist/core/db/schema.d.ts +3 -3
  41. package/dist/core/db/schema.d.ts.map +1 -1
  42. package/dist/core/db/schema.js +12 -30
  43. package/dist/core/db/schema.js.map +1 -1
  44. package/dist/core/db/sqlite-loader.d.ts +51 -0
  45. package/dist/core/db/sqlite-loader.d.ts.map +1 -0
  46. package/dist/core/db/sqlite-loader.js +94 -0
  47. package/dist/core/db/sqlite-loader.js.map +1 -0
  48. package/dist/core/db/wasm-sqlite.d.ts +4 -0
  49. package/dist/core/db/wasm-sqlite.d.ts.map +1 -0
  50. package/dist/core/db/wasm-sqlite.js +270 -0
  51. package/dist/core/db/wasm-sqlite.js.map +1 -0
  52. package/dist/core/diff-parser.d.ts.map +1 -1
  53. package/dist/core/diff-parser.js +6 -1
  54. package/dist/core/diff-parser.js.map +1 -1
  55. package/dist/core/git-log-reader.d.ts +28 -0
  56. package/dist/core/git-log-reader.d.ts.map +1 -1
  57. package/dist/core/git-log-reader.js +74 -3
  58. package/dist/core/git-log-reader.js.map +1 -1
  59. package/dist/core/index-manager.d.ts.map +1 -1
  60. package/dist/core/index-manager.js +20 -1
  61. package/dist/core/index-manager.js.map +1 -1
  62. package/dist/graph/path-resolver.js +86 -17
  63. package/dist/graph/path-resolver.js.map +1 -1
  64. package/dist/index.d.ts +1 -0
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +9 -1
  67. package/dist/index.js.map +1 -1
  68. package/dist/node-guard.d.ts +15 -0
  69. package/dist/node-guard.d.ts.map +1 -0
  70. package/dist/node-guard.js +33 -0
  71. package/dist/node-guard.js.map +1 -0
  72. package/dist/server/admin-api.d.ts +1 -1
  73. package/dist/server/admin-api.d.ts.map +1 -1
  74. package/dist/server/admin-api.js +2 -2
  75. package/dist/server/admin-api.js.map +1 -1
  76. package/dist/server/auth/api-key.d.ts +1 -1
  77. package/dist/server/auth/api-key.d.ts.map +1 -1
  78. package/dist/server/mcp-server.d.ts.map +1 -1
  79. package/dist/server/mcp-server.js +25 -0
  80. package/dist/server/mcp-server.js.map +1 -1
  81. package/dist/server/tools/analyze-diff.d.ts +8 -0
  82. package/dist/server/tools/analyze-diff.d.ts.map +1 -1
  83. package/dist/server/tools/analyze-diff.js +80 -16
  84. package/dist/server/tools/analyze-diff.js.map +1 -1
  85. package/dist/server/tools/change-synthesis.d.ts +90 -0
  86. package/dist/server/tools/change-synthesis.d.ts.map +1 -0
  87. package/dist/server/tools/change-synthesis.js +236 -0
  88. package/dist/server/tools/change-synthesis.js.map +1 -0
  89. package/dist/server/tools/co-change.d.ts +65 -0
  90. package/dist/server/tools/co-change.d.ts.map +1 -0
  91. package/dist/server/tools/co-change.js +146 -0
  92. package/dist/server/tools/co-change.js.map +1 -0
  93. package/dist/server/tools/compare-change-impact.d.ts +58 -0
  94. package/dist/server/tools/compare-change-impact.d.ts.map +1 -0
  95. package/dist/server/tools/compare-change-impact.js +0 -0
  96. package/dist/server/tools/compare-change-impact.js.map +1 -0
  97. package/dist/server/tools/find-refactoring-opportunities.d.ts +1 -1
  98. package/dist/server/tools/get-architecture-snapshot.d.ts.map +1 -1
  99. package/dist/server/tools/get-architecture-snapshot.js +28 -14
  100. package/dist/server/tools/get-architecture-snapshot.js.map +1 -1
  101. package/dist/server/tools/get-churn-metrics.d.ts.map +1 -1
  102. package/dist/server/tools/get-churn-metrics.js +1 -12
  103. package/dist/server/tools/get-churn-metrics.js.map +1 -1
  104. package/dist/server/tools/get-co-change.d.ts +37 -0
  105. package/dist/server/tools/get-co-change.d.ts.map +1 -0
  106. package/dist/server/tools/get-co-change.js +120 -0
  107. package/dist/server/tools/get-co-change.js.map +1 -0
  108. package/dist/server/tools/get-context-bundle.d.ts.map +1 -1
  109. package/dist/server/tools/get-context-bundle.js +56 -3
  110. package/dist/server/tools/get-context-bundle.js.map +1 -1
  111. package/dist/server/tools/get-entry-points.d.ts +1 -1
  112. package/dist/server/tools/get-symbol-risk.d.ts +25 -0
  113. package/dist/server/tools/get-symbol-risk.d.ts.map +1 -0
  114. package/dist/server/tools/get-symbol-risk.js +60 -0
  115. package/dist/server/tools/get-symbol-risk.js.map +1 -0
  116. package/dist/server/tools/get-symbol-source.d.ts +2 -0
  117. package/dist/server/tools/get-symbol-source.d.ts.map +1 -1
  118. package/dist/server/tools/get-symbol-source.js +18 -1
  119. package/dist/server/tools/get-symbol-source.js.map +1 -1
  120. package/dist/server/tools/prepare-change.d.ts +61 -0
  121. package/dist/server/tools/prepare-change.d.ts.map +1 -0
  122. package/dist/server/tools/prepare-change.js +262 -0
  123. package/dist/server/tools/prepare-change.js.map +1 -0
  124. package/dist/server/tools/search-symbols.d.ts +2 -0
  125. package/dist/server/tools/search-symbols.d.ts.map +1 -1
  126. package/dist/server/tools/search-symbols.js +33 -0
  127. package/dist/server/tools/search-symbols.js.map +1 -1
  128. package/dist/server/tools/symbol-lines.d.ts +25 -0
  129. package/dist/server/tools/symbol-lines.d.ts.map +1 -0
  130. package/dist/server/tools/symbol-lines.js +40 -0
  131. package/dist/server/tools/symbol-lines.js.map +1 -0
  132. package/dist/server/tools/symbol-risk.d.ts +109 -0
  133. package/dist/server/tools/symbol-risk.d.ts.map +1 -0
  134. package/dist/server/tools/symbol-risk.js +251 -0
  135. package/dist/server/tools/symbol-risk.js.map +1 -0
  136. package/dist/server/tools/verify-change.d.ts +40 -0
  137. package/dist/server/tools/verify-change.d.ts.map +1 -0
  138. package/dist/server/tools/verify-change.js +149 -0
  139. package/dist/server/tools/verify-change.js.map +1 -0
  140. package/dist/version.d.ts +1 -1
  141. package/dist/version.d.ts.map +1 -1
  142. package/dist/version.js +1 -1
  143. package/dist/version.js.map +1 -1
  144. package/docs/01-introduction.md +2 -2
  145. package/docs/02-installation.md +97 -89
  146. package/docs/03-quick-start.md +138 -135
  147. package/docs/04-configuration.md +247 -214
  148. package/docs/05-cli-reference.md +236 -219
  149. package/docs/06-tools-reference.md +902 -499
  150. package/docs/14-transport-modes.md +170 -167
  151. package/docs/18-git-history.md +43 -0
  152. package/docs/23-performance.md +123 -121
  153. package/docs/26-troubleshooting.md +249 -234
  154. package/grammars/README.md +88 -0
  155. package/package.json +7 -25
  156. package/AGENT_INSTRUCTIONS_SHORT.md +0 -150
@@ -1,219 +1,236 @@
1
- # CLI Reference
2
-
3
-
4
- ## Synopsis
5
-
6
- ```
7
- purecontext-mcp [command] [options]
8
- npx purecontext-mcp [command] [options]
9
- ```
10
-
11
- ## Commands
12
-
13
- ### (default — no command)
14
-
15
- Start the MCP server. The default transport is `stdio` (for Claude Code).
16
-
17
- ```bash
18
- purecontext-mcp
19
- purecontext-mcp --transport http --port 3001
20
- purecontext-mcp --transport both
21
- ```
22
-
23
- CLI flags override the corresponding `config.json` fields.
24
-
25
- ### `config`
26
-
27
- Manage configuration.
28
-
29
- ```bash
30
- # Generate ~/.purecontext/config.json with defaults and comments
31
- purecontext-mcp config --init
32
-
33
- # Validate config + check all prerequisites (grammars, DB, API keys)
34
- purecontext-mcp config --check
35
-
36
- # Print effective configuration as JSON (defaults merged with overrides)
37
- purecontext-mcp config
38
- ```
39
-
40
- ### `install`
41
-
42
- Write PureContext workflow rules into the conventions file each AI tool expects.
43
-
44
- ```bash
45
- # Auto-detect installed tools and install rules for all of them
46
- npx purecontext-mcp install all
47
-
48
- # Install for a specific tool
49
- npx purecontext-mcp install cursor
50
- npx purecontext-mcp install windsurf
51
- npx purecontext-mcp install continue
52
- npx purecontext-mcp install cline
53
- npx purecontext-mcp install roo-code
54
- npx purecontext-mcp install vscode
55
- npx purecontext-mcp install claude
56
- npx purecontext-mcp install claude-desktop
57
- ```
58
-
59
- When no `--scope` flag is given, the CLI prompts interactively:
60
-
61
- ```
62
- Where should PureContext be installed?
63
- 1) Local — this project only
64
- 2) Global — all projects (user-level config)
65
- 3) Both
66
- ```
67
-
68
- Pass `--scope` to skip the prompt:
69
-
70
- ```bash
71
- npx purecontext-mcp install all --scope=global # user-level for all IDEs
72
- npx purecontext-mcp install cursor --scope=both # project + home dir
73
- npx purecontext-mcp install all --scope=local # this project only
74
- ```
75
-
76
- Useful flags:
77
-
78
- ```bash
79
- npx purecontext-mcp install --list # show detection state, write nothing
80
- npx purecontext-mcp install all --dry-run # preview which writers would run
81
- npx purecontext-mcp install all --scope=global # install globally without prompt
82
- ```
83
-
84
- **Scope behaviour per tool:**
85
-
86
- | Tool | Local | Global |
87
- |------|-------|--------|
88
- | `claude` | `CLAUDE.md` in project | `~/.claude/CLAUDE.md` + hooks |
89
- | `cursor` | `.cursor/rules/purecontext.mdc` | `~/.cursor/rules/purecontext.mdc` |
90
- | `windsurf` | `.windsurfrules` | `~/.windsurfrules` |
91
- | `continue` | `.continue/config.json` | `~/.continue/config.json` |
92
- | `cline` | `.clinerules` | local only (no global path) |
93
- | `roo-code` | `.roo/rules-code.md` | local only (no global path) |
94
- | `vscode` | `.github/copilot-instructions.md` | local only (no global path) |
95
- | `claude-desktop` | always global | always global |
96
-
97
- All writers are idempotent: re-running updates the marked block in place without touching anything outside it.
98
-
99
- ### `hooks`
100
-
101
- Install or inspect Claude Code hook registrations.
102
-
103
- ```bash
104
- # Register all PureContext hooks in ~/.claude/settings.json
105
- npx purecontext-mcp hooks --install
106
-
107
- # List current hook registration status
108
- npx purecontext-mcp hooks --list
109
- ```
110
-
111
- Hooks are registered as CLI commands in `~/.claude/settings.json`. Re-running `--install` is safe — it replaces existing PureContext entries (including any old `.mjs`-path style entries from earlier versions) while leaving other tools' hooks untouched.
112
-
113
- ### `hook-*` (Claude Code hook handlers)
114
-
115
- These are the hook handlers invoked by Claude Code. They are not meant to be called directly; they are registered by `hooks --install` and executed automatically by Claude Code as events fire.
116
-
117
- | Command | Hook event | What it does |
118
- |---------|-----------|--------------|
119
- | `hook-posttooluse` | `PostToolUse` | Re-indexes files modified by Edit/Write/MultiEdit |
120
- | `hook-pretooluse` | `PreToolUse` | Soft edit guard — suggests read tools before editing |
121
- | `hook-precompact` | `PreCompact` | Injects the list of indexed repos before context compaction |
122
- | `hook-worktree-create` | `WorktreeCreate` | Auto-indexes a newly created agent worktree |
123
- | `hook-worktree-remove` | `WorktreeRemove` | Fires when an agent worktree is removed (no-op, reserved) |
124
- | `hook-taskcompleted` | `TaskCompleted` | Post-task diagnostics: complexity hotspots, TODO count, tool suggestions |
125
- | `hook-subagentstart` | `SubagentStart` | Injects condensed repo orientation for newly spawned subagents |
126
-
127
- All handlers read from stdin (the JSON payload Claude Code sends) and write a `systemMessage` JSON object to stdout when they have context to inject. They always exit 0 and never block tool execution.
128
-
129
- ### `keys`
130
-
131
- Manage API keys for hosted deployments.
132
-
133
- ```bash
134
- # Create a key for a tenant/workspace
135
- purecontext-mcp keys create --tenant <tenantId> --permissions read,write --label "alice-laptop"
136
-
137
- # List keys for a tenant
138
- purecontext-mcp keys list --tenant <tenantId>
139
-
140
- # Revoke a key by prefix
141
- purecontext-mcp keys revoke <key-prefix>
142
- ```
143
-
144
- ## Global options
145
-
146
- | Flag | Default | Description |
147
- |------|---------|-------------|
148
- | `--version` | | Print version and exit |
149
- | `--help` | — | Print help and exit |
150
- | `--log-level` | `info` | Log verbosity: `debug`, `info`, `warn`, `error` |
151
- | `--config <path>` | `~/.purecontext/config.json` | Path to config file |
152
- | `--transport` | `stdio` | `stdio`, `http`, or `both` |
153
- | `--port <n>` | `3000` | HTTP port (overrides `http.port`) |
154
- | `--host <addr>` | `127.0.0.1` | Bind address (overrides `http.host`) |
155
-
156
- ## Health check
157
-
158
- ```bash
159
- purecontext-mcp --health
160
- ```
161
-
162
- Checks server health without starting the MCP server. Output is JSON:
163
-
164
- ```json
165
- {
166
- "status": "ok",
167
- "version": "1.2.0",
168
- "uptime": 0,
169
- "nodeVersion": "20.11.0",
170
- "platform": "linux",
171
- "indexDir": "/home/user/.purecontext/indexes",
172
- "repoCount": 3,
173
- "grammars": {
174
- "tree-sitter-typescript.wasm": true,
175
- "tree-sitter-javascript.wasm": true
176
- }
177
- }
178
- ```
179
-
180
- If anything is wrong, the corresponding field is `false` and the exit code is non-zero.
181
-
182
- HTTP health check (when running in server mode):
183
-
184
- ```bash
185
- curl http://localhost:3000/health
186
- ```
187
-
188
- ## Exit codes
189
-
190
- | Code | Meaning |
191
- |------|---------|
192
- | `0` | Success |
193
- | `1` | Configuration error |
194
- | `2` | Fatal startup error (missing grammar, SQLite failure, etc.) |
195
-
196
- ## Examples
197
-
198
- ```bash
199
- # Start MCP server for Claude Code (default)
200
- purecontext-mcp
201
-
202
- # Start HTTP server for Web UI or team use
203
- purecontext-mcp --transport http --port 3000
204
-
205
- # Start both stdio and HTTP simultaneously (development)
206
- purecontext-mcp --transport both
207
-
208
- # Generate a config file
209
- purecontext-mcp config --init
210
-
211
- # Validate everything before deploying
212
- purecontext-mcp config --check
213
-
214
- # Debug startup issues
215
- purecontext-mcp --log-level debug
216
-
217
- # Check health without starting the server
218
- purecontext-mcp --health
219
- ```
1
+ # CLI Reference
2
+
3
+
4
+ ## Synopsis
5
+
6
+ ```
7
+ purecontext-mcp [command] [options]
8
+ npx purecontext-mcp [command] [options]
9
+ ```
10
+
11
+ ## Commands
12
+
13
+ ### (default — no command)
14
+
15
+ Start the MCP server. The default transport is `stdio` (for Claude Code).
16
+
17
+ ```bash
18
+ purecontext-mcp
19
+ purecontext-mcp --transport http --port 3001
20
+ purecontext-mcp --transport both
21
+ ```
22
+
23
+ CLI flags override the corresponding `config.json` fields.
24
+
25
+ ### `config`
26
+
27
+ Manage configuration.
28
+
29
+ ```bash
30
+ # Generate ~/.purecontext/config.json with defaults and comments
31
+ purecontext-mcp config --init
32
+
33
+ # Validate config + check all prerequisites (grammars, DB, API keys)
34
+ purecontext-mcp config --check
35
+
36
+ # Print effective configuration as JSON (defaults merged with overrides)
37
+ purecontext-mcp config
38
+ ```
39
+
40
+ ### `install`
41
+
42
+ Set up PureContext for an AI tool: write its workflow-rules/instructions file **and** register the `purecontext-mcp` MCP server so its tools are actually available (not merely referenced by the rules). The server is pinned to your global Node — see [MCP server registration](#mcp-server-registration) below.
43
+
44
+ ```bash
45
+ # Auto-detect installed tools and set up each
46
+ npx purecontext-mcp install all
47
+
48
+ # Install for a specific tool
49
+ npx purecontext-mcp install cursor
50
+ npx purecontext-mcp install windsurf
51
+ npx purecontext-mcp install continue
52
+ npx purecontext-mcp install cline
53
+ npx purecontext-mcp install roo-code
54
+ npx purecontext-mcp install copilot
55
+ npx purecontext-mcp install claude
56
+ npx purecontext-mcp install claude-desktop
57
+ ```
58
+
59
+ When no `--scope` flag is given, the CLI prompts interactively:
60
+
61
+ ```
62
+ Where should PureContext be installed?
63
+ 1) Local — this project only
64
+ 2) Global — all projects (user-level config)
65
+ 3) Both
66
+ ```
67
+
68
+ Pass `--scope` to skip the prompt:
69
+
70
+ ```bash
71
+ npx purecontext-mcp install all --scope=global # user-level for all IDEs
72
+ npx purecontext-mcp install cursor --scope=both # project + home dir
73
+ npx purecontext-mcp install all --scope=local # this project only
74
+ ```
75
+
76
+ Useful flags:
77
+
78
+ ```bash
79
+ npx purecontext-mcp install --list # show detection state, write nothing
80
+ npx purecontext-mcp install all --dry-run # preview which writers would run
81
+ npx purecontext-mcp install all --scope=global # install globally without prompt
82
+ ```
83
+
84
+ **Rules/instructions file per tool:**
85
+
86
+ | Tool | Local | Global |
87
+ |------|-------|--------|
88
+ | `claude` | `CLAUDE.md` in project | `~/.claude/CLAUDE.md` + hooks |
89
+ | `cursor` | `.cursor/rules/purecontext.mdc` | `~/.cursor/rules/purecontext.mdc` |
90
+ | `windsurf` | `.windsurf/rules/purecontext.md` | `~/.windsurf/rules/purecontext.md` |
91
+ | `continue` | `.continue/config.json` | `~/.continue/config.json` |
92
+ | `cline` | `.clinerules` | local only (no global path) |
93
+ | `roo-code` | `.roo/rules-code.md` | local only (no global path) |
94
+ | `copilot` | `.github/copilot-instructions.md` | local only (no global path) |
95
+ | `claude-desktop` | always global | always global |
96
+
97
+ These writers are idempotent: re-running updates the marked block in place without touching anything outside it.
98
+
99
+ #### MCP server registration
100
+
101
+ Besides the rules file, `install` registers the `purecontext-mcp` server with each agent so its tools are actually available. The server command is **pinned to your global/default Node** (Volta's default, else the system Node), independent of any project's Node pin, so it works in every project. Registration is at user scope and merges into existing config (other servers are preserved):
102
+
103
+ | Tool | MCP config written |
104
+ |------|--------------------|
105
+ | `claude` | `claude mcp add --scope user` (`--scope local` for a `--scope=local` install) |
106
+ | `claude-desktop` | `claude_desktop_config.json` |
107
+ | `cursor` | `~/.cursor/mcp.json` |
108
+ | `windsurf` | `~/.codeium/windsurf/mcp_config.json` |
109
+ | `cline` | VS Code `globalStorage/.../cline_mcp_settings.json` |
110
+ | `roo-code` | VS Code `globalStorage/.../mcp_settings.json` |
111
+ | `continue` | `~/.continue/config.yaml` (`mcpServers` list) |
112
+ | `copilot` | VS Code user `mcp.json` (`servers` map, `"type": "stdio"`) |
113
+
114
+ For `claude`, registration uses the `claude` CLI (falling back to printing the command if it isn't on PATH). For `cline`, `roo-code`, `continue`, and `copilot` — whose config locations vary by editor and version — `install` writes only when the target config/dir already exists; otherwise it prints the entry to add manually rather than guess a path. Set `PCTX_SKIP_MCP_REGISTER=1` to skip server registration (rules only).
115
+
116
+ ### `hooks`
117
+
118
+ Install or inspect Claude Code hook registrations.
119
+
120
+ ```bash
121
+ # Register all PureContext hooks in ~/.claude/settings.json
122
+ npx purecontext-mcp hooks --install
123
+
124
+ # List current hook registration status
125
+ npx purecontext-mcp hooks --list
126
+ ```
127
+
128
+ Hooks are registered as CLI commands in `~/.claude/settings.json`. Re-running `--install` is safe — it replaces existing PureContext entries (including any old `.mjs`-path style entries from earlier versions) while leaving other tools' hooks untouched.
129
+
130
+ ### `hook-*` (Claude Code hook handlers)
131
+
132
+ These are the hook handlers invoked by Claude Code. They are not meant to be called directly; they are registered by `hooks --install` and executed automatically by Claude Code as events fire.
133
+
134
+ | Command | Hook event | What it does |
135
+ |---------|-----------|--------------|
136
+ | `hook-posttooluse` | `PostToolUse` | Re-indexes files modified by Edit/Write/MultiEdit |
137
+ | `hook-pretooluse` | `PreToolUse` | Soft edit guard — suggests read tools before editing |
138
+ | `hook-precompact` | `PreCompact` | Injects the list of indexed repos before context compaction |
139
+ | `hook-worktree-create` | `WorktreeCreate` | Auto-indexes a newly created agent worktree |
140
+ | `hook-worktree-remove` | `WorktreeRemove` | Fires when an agent worktree is removed (no-op, reserved) |
141
+ | `hook-taskcompleted` | `TaskCompleted` | Post-task diagnostics: complexity hotspots, TODO count, tool suggestions |
142
+ | `hook-subagentstart` | `SubagentStart` | Injects condensed repo orientation for newly spawned subagents |
143
+
144
+ All handlers read from stdin (the JSON payload Claude Code sends) and write a `systemMessage` JSON object to stdout when they have context to inject. They always exit 0 and never block tool execution.
145
+
146
+ ### `keys`
147
+
148
+ Manage API keys for hosted deployments.
149
+
150
+ ```bash
151
+ # Create a key for a tenant/workspace
152
+ purecontext-mcp keys create --tenant <tenantId> --permissions read,write --label "alice-laptop"
153
+
154
+ # List keys for a tenant
155
+ purecontext-mcp keys list --tenant <tenantId>
156
+
157
+ # Revoke a key by prefix
158
+ purecontext-mcp keys revoke <key-prefix>
159
+ ```
160
+
161
+ ## Global options
162
+
163
+ | Flag | Default | Description |
164
+ |------|---------|-------------|
165
+ | `--version` | — | Print version and exit |
166
+ | `--help` | — | Print help and exit |
167
+ | `--log-level` | `info` | Log verbosity: `debug`, `info`, `warn`, `error` |
168
+ | `--config <path>` | `~/.purecontext/config.json` | Path to config file |
169
+ | `--transport` | `stdio` | `stdio`, `http`, or `both` |
170
+ | `--port <n>` | `3000` | HTTP port (overrides `http.port`) |
171
+ | `--host <addr>` | `127.0.0.1` | Bind address (overrides `http.host`) |
172
+
173
+ ## Health check
174
+
175
+ ```bash
176
+ purecontext-mcp --health
177
+ ```
178
+
179
+ Checks server health without starting the MCP server. Output is JSON:
180
+
181
+ ```json
182
+ {
183
+ "status": "ok",
184
+ "version": "1.2.0",
185
+ "uptime": 0,
186
+ "nodeVersion": "20.11.0",
187
+ "platform": "linux",
188
+ "indexDir": "/home/user/.purecontext/indexes",
189
+ "repoCount": 3,
190
+ "grammars": {
191
+ "tree-sitter-typescript.wasm": true,
192
+ "tree-sitter-javascript.wasm": true
193
+ }
194
+ }
195
+ ```
196
+
197
+ If anything is wrong, the corresponding field is `false` and the exit code is non-zero.
198
+
199
+ HTTP health check (when running in server mode):
200
+
201
+ ```bash
202
+ curl http://localhost:3000/health
203
+ ```
204
+
205
+ ## Exit codes
206
+
207
+ | Code | Meaning |
208
+ |------|---------|
209
+ | `0` | Success |
210
+ | `1` | Configuration error |
211
+ | `2` | Fatal startup error (missing grammar, SQLite failure, etc.) |
212
+
213
+ ## Examples
214
+
215
+ ```bash
216
+ # Start MCP server for Claude Code (default)
217
+ purecontext-mcp
218
+
219
+ # Start HTTP server for Web UI or team use
220
+ purecontext-mcp --transport http --port 3000
221
+
222
+ # Start both stdio and HTTP simultaneously (development)
223
+ purecontext-mcp --transport both
224
+
225
+ # Generate a config file
226
+ purecontext-mcp config --init
227
+
228
+ # Validate everything before deploying
229
+ purecontext-mcp config --check
230
+
231
+ # Debug startup issues
232
+ purecontext-mcp --log-level debug
233
+
234
+ # Check health without starting the server
235
+ purecontext-mcp --health
236
+ ```