contextpro-mcp 1.4.0 → 1.5.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.
- package/CHANGELOG.md +9 -0
- package/INSTALL.md +154 -64
- package/INSTRUCTIONS.md +1 -1
- package/README.md +54 -129
- package/SECURITY.md +4 -2
- package/agent-guide.md +33 -2
- package/build/core/agent-setup.d.ts +1 -1
- package/build/core/agent-setup.d.ts.map +1 -1
- package/build/core/agent-setup.js +3 -2
- package/build/core/agent-setup.js.map +1 -1
- package/build/core/data-dir.d.ts.map +1 -1
- package/build/core/data-dir.js +9 -1
- package/build/core/data-dir.js.map +1 -1
- package/build/core/root-guard.d.ts +1 -0
- package/build/core/root-guard.d.ts.map +1 -1
- package/build/core/root-guard.js +15 -4
- package/build/core/root-guard.js.map +1 -1
- package/build/index.js +67 -32
- package/build/index.js.map +1 -1
- package/build/tools/context.js +1 -1
- package/build/tools/context.js.map +1 -1
- package/build/tools/exact-references.d.ts.map +1 -1
- package/build/tools/exact-references.js +3 -1
- package/build/tools/exact-references.js.map +1 -1
- package/build/tools/reindex.js +1 -1
- package/docs/README.md +25 -16
- package/docs/configuration.md +30 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@ All notable changes to this project are recorded here. The project follows [Sema
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [1.5.0] - 2026-10-31
|
|
8
|
+
|
|
9
|
+
- `contextpro-mcp --help` and `--version` print usage and the version instead of starting a server on a folder named after the flag. Unknown options and a `--root` that does not exist now fail with a one-line error instead of creating directories.
|
|
10
|
+
- `init` writes a minimal config (`CONTEXTPRO_TOOL_PROFILE=lean`, no Ollama settings). `init vscode` uses VS Code's `servers` format, and `init vscode`/`init cursor` pass `--root ${workspaceFolder}`; an unexpanded `${...}` root falls back to the launch directory.
|
|
11
|
+
- A Git repository directly inside the home folder (for example `~/myapp`) is accepted as a project root.
|
|
12
|
+
- ContextPro writes `.contextpro/.gitignore`, so its local index state stays out of Git without editing the project's `.gitignore`.
|
|
13
|
+
- An empty `exact_references` result is labelled unverified when the compiler could not check some files, with a hint to install the project's dependencies.
|
|
14
|
+
- The README is now a one-minute quick start with verified commands for Claude Code, Codex, Cursor and OpenCode; internals moved to the configuration and agent guides.
|
|
15
|
+
|
|
7
16
|
## [1.4.0] - 2026-10-29
|
|
8
17
|
|
|
9
18
|
- Upgraded zod to 4.6.7 to resolve GHSA-mrhx-c7xc-m3w5 (memory exhaustion when validating oversized constrained collections); tool behavior is unchanged, and nested object schemas are now advertised without `additionalProperties: false`.
|
package/INSTALL.md
CHANGED
|
@@ -1,110 +1,197 @@
|
|
|
1
1
|
# Install ContextPro
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ContextPro is published on npm as `contextpro-mcp`, and every client below starts it with `npx`. To run unreleased code from a checkout, see [Run from source](#run-from-source).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js 20–26 (24 LTS recommended) and npm. No API key or Ollama needed.
|
|
8
|
+
- For TypeScript/JavaScript compiler references, install the target project's dependencies (`npm install`). Without them, `tsconfig` `extends` and type packages don't resolve, and files can't be checked.
|
|
9
|
+
|
|
10
|
+
The examples use the unpinned package so they don't go stale. Teams that want reproducible setups can pin a release with `contextpro-mcp@<version>`.
|
|
11
|
+
|
|
12
|
+
## Connect your client
|
|
13
|
+
|
|
14
|
+
The "project root" is the repository ContextPro indexes. Without `--root`, the root is the directory the client starts the server in. ContextPro refuses to start in `/` or in your home folder itself. A project folder directly inside your home folder (for example `~/myapp`) is accepted when it is a Git repository (has `.git`); a non-repository folder there (for example `~/Downloads`) is refused unless `CONTEXTPRO_ALLOW_UNSAFE_ROOT=true`. Global configs and GUI apps often start servers from your home folder, so they should pass `--root`.
|
|
15
|
+
|
|
16
|
+
### Claude Code
|
|
17
|
+
|
|
18
|
+
Just for you, in one project:
|
|
6
19
|
|
|
7
20
|
```sh
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
npm run build
|
|
12
|
-
node build/index.js doctor --root /absolute/path/to/target-project
|
|
21
|
+
cd your-project
|
|
22
|
+
claude mcp add contextpro -e CONTEXTPRO_TOOL_PROFILE=lean -- npx -y contextpro-mcp --root "$PWD"
|
|
23
|
+
claude mcp list # contextpro: ... ✔ Connected
|
|
13
24
|
```
|
|
14
25
|
|
|
15
|
-
|
|
26
|
+
Put the server name before `-e`. The `-e` flag takes several values, so a name after it is read as an environment variable and the command fails with `Invalid environment variable format`.
|
|
16
27
|
|
|
17
|
-
|
|
28
|
+
For a team, commit the config and the agent instructions:
|
|
18
29
|
|
|
19
|
-
|
|
30
|
+
```sh
|
|
31
|
+
cd your-project
|
|
32
|
+
npx -y contextpro-mcp init claude # writes .mcp.json, AGENTS.md and CLAUDE.md
|
|
33
|
+
claude
|
|
34
|
+
```
|
|
20
35
|
|
|
21
|
-
|
|
36
|
+
Claude Code asks once to approve servers from a project `.mcp.json`. Until you start `claude` in the project and accept, `claude mcp list` shows "Pending approval". The generated config has no `--root`, so the root is the directory where you start `claude`: start it in the repository root. Started in a subdirectory, ContextPro silently indexes only that subdirectory. The same applies to any config without `--root`, such as OpenCode's `opencode.json`.
|
|
22
37
|
|
|
23
38
|
### Codex
|
|
24
39
|
|
|
25
|
-
|
|
40
|
+
```sh
|
|
41
|
+
codex mcp add contextpro --env CONTEXTPRO_TOOL_PROFILE=lean -- npx -y contextpro-mcp --root /absolute/path/to/project
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Codex reads `~/.codex/config.toml` by default (`$CODEX_HOME/config.toml` if set), which is global, so `--root` pins the project. Tool calls can still pass another `root`. The command writes:
|
|
26
45
|
|
|
27
46
|
```toml
|
|
28
47
|
[mcp_servers.contextpro]
|
|
29
|
-
command = "
|
|
30
|
-
args = ["
|
|
48
|
+
command = "npx"
|
|
49
|
+
args = ["-y", "contextpro-mcp", "--root", "/absolute/path/to/project"]
|
|
31
50
|
|
|
32
51
|
[mcp_servers.contextpro.env]
|
|
33
|
-
CONTEXTPRO_TOOL_PROFILE = "
|
|
34
|
-
CONTEXTPRO_PROVIDER = "ollama"
|
|
35
|
-
CONTEXTPRO_EMBED_MODEL = "nomic-embed-text:latest"
|
|
52
|
+
CONTEXTPRO_TOOL_PROFILE = "lean"
|
|
36
53
|
```
|
|
37
54
|
|
|
38
|
-
|
|
55
|
+
`codex mcp list` only prints the config; it does not start the server. Use the [smoke test](#verify) to check it starts. `Auth: Unsupported` is normal for a local (stdio) server.
|
|
39
56
|
|
|
40
|
-
|
|
57
|
+
### Cursor and other `mcpServers` JSON clients
|
|
58
|
+
|
|
59
|
+
`npx -y contextpro-mcp init cursor` writes `.cursor/mcp.json` with `--root ${workspaceFolder}`. That form has not yet been verified inside Cursor; the hand-written JSON below, with an absolute `--root`, is the verified path. Put it in `.cursor/mcp.json` or the client's own config file:
|
|
41
60
|
|
|
42
61
|
```json
|
|
43
62
|
{
|
|
44
63
|
"mcpServers": {
|
|
45
64
|
"contextpro": {
|
|
46
|
-
"command": "
|
|
47
|
-
"args": ["
|
|
48
|
-
"env": {
|
|
49
|
-
"CONTEXTPRO_TOOL_PROFILE": "workflow",
|
|
50
|
-
"CONTEXTPRO_PROVIDER": "ollama",
|
|
51
|
-
"CONTEXTPRO_EMBED_MODEL": "nomic-embed-text:latest"
|
|
52
|
-
}
|
|
65
|
+
"command": "npx",
|
|
66
|
+
"args": ["-y", "contextpro-mcp", "--root", "/absolute/path/to/project"],
|
|
67
|
+
"env": { "CONTEXTPRO_TOOL_PROFILE": "lean" }
|
|
53
68
|
}
|
|
54
69
|
}
|
|
55
70
|
}
|
|
56
71
|
```
|
|
57
72
|
|
|
73
|
+
Keep `--root`: GUI apps may start servers from your home folder, where ContextPro refuses to start. If a client passes an unexpanded `${...}` variable as `--root`, ContextPro ignores it and uses the launch directory.
|
|
74
|
+
|
|
58
75
|
### OpenCode
|
|
59
76
|
|
|
60
|
-
|
|
77
|
+
```sh
|
|
78
|
+
cd your-project
|
|
79
|
+
npx -y contextpro-mcp init opencode # writes opencode.json and AGENTS.md
|
|
80
|
+
opencode mcp list
|
|
81
|
+
```
|
|
61
82
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"command": ["/absolute/path/to/node", "/absolute/path/to/contextpro-mcp/build/index.js", "--root", "/absolute/path/to/target-project"],
|
|
68
|
-
"enabled": true,
|
|
69
|
-
"environment": {
|
|
70
|
-
"CONTEXTPRO_TOOL_PROFILE": "workflow",
|
|
71
|
-
"CONTEXTPRO_PROVIDER": "ollama",
|
|
72
|
-
"CONTEXTPRO_EMBED_MODEL": "nomic-embed-text:latest"
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
83
|
+
### VS Code
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
cd your-project
|
|
87
|
+
npx -y contextpro-mcp init vscode # writes .vscode/mcp.json
|
|
77
88
|
```
|
|
78
89
|
|
|
79
|
-
|
|
90
|
+
The generated file uses VS Code's format (`servers`, `type: "stdio"`, `--root ${workspaceFolder}`). This setup has not yet been verified inside VS Code.
|
|
91
|
+
|
|
92
|
+
### What `init` does
|
|
93
|
+
|
|
94
|
+
`npx -y contextpro-mcp init <claude|cursor|vscode|windsurf|opencode>` writes the client's project config with the `lean` profile and adds a managed ContextPro section to `AGENTS.md` (and `CLAUDE.md` for Claude). The VS Code and Cursor targets write `--root ${workspaceFolder}`; the Claude and OpenCode targets write no `--root`. The Windsurf target writes `.windsurf/mcp.json` and has not been verified inside Windsurf.
|
|
95
|
+
|
|
96
|
+
- It merges JSON without replacing other servers or an existing customized ContextPro entry.
|
|
97
|
+
- It also creates `.contextpro/config.json` (provider defaults and project identity), which the auto-written `.contextpro/.gitignore` covers.
|
|
98
|
+
- `AGENTS.md` gets a managed block at the top and existing content is preserved. `CLAUDE.md` gets the same block, so Claude Code may read it twice.
|
|
99
|
+
- Running it again is idempotent and preserves your own rules outside the managed markers.
|
|
100
|
+
- `--no-agent-instructions` skips `AGENTS.md`/`CLAUDE.md`; `--runner bunx` uses Bun instead of npx; `--root <dir>` targets another directory.
|
|
80
101
|
|
|
81
|
-
|
|
102
|
+
The agent instructions matter: the MCP config exposes the tools, while `AGENTS.md`/`CLAUDE.md` tells the agent when to use them. The full workflow is served on demand as `contextpro://instructions`. To add the instructions by hand, copy [INSTRUCTIONS.md](INSTRUCTIONS.md). A separate skill is optional; it does not enable tools or repair retrieval.
|
|
82
103
|
|
|
83
|
-
|
|
104
|
+
ContextPro keeps its local state in `.contextpro/` and writes a `.contextpro/.gitignore` itself, so you don't need to change your `.gitignore`. Older versions: add `.contextpro/` to your .gitignore.
|
|
105
|
+
|
|
106
|
+
## Verify
|
|
107
|
+
|
|
108
|
+
Smoke test for any client. Run it in your project; it starts the server, lists its tools and exits:
|
|
84
109
|
|
|
85
110
|
```sh
|
|
86
|
-
|
|
87
|
-
|
|
111
|
+
printf '%s\n' \
|
|
112
|
+
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"smoke","version":"0"}}}' \
|
|
113
|
+
'{"jsonrpc":"2.0","method":"notifications/initialized"}' \
|
|
114
|
+
'{"jsonrpc":"2.0","id":2,"method":"tools/list"}' \
|
|
115
|
+
| CONTEXTPRO_TOOL_PROFILE=lean npx -y contextpro-mcp --root "$PWD" 2>/dev/null | grep -o '"name":"[a-z_]*"'
|
|
116
|
+
# expect four lines: "name":"contextpro" (the server info), then "name":"context", "name":"discover_tools", "name":"exact_references"
|
|
88
117
|
```
|
|
89
118
|
|
|
90
|
-
|
|
119
|
+
Check storage with `doctor`:
|
|
91
120
|
|
|
92
|
-
|
|
121
|
+
```sh
|
|
122
|
+
npx -y contextpro-mcp doctor --root /absolute/path/to/project
|
|
123
|
+
```
|
|
93
124
|
|
|
94
|
-
|
|
125
|
+
Expect `Before: ok | storage=true | dbOpen=true` and `After: ok | …`. "Fix Applied: no" only means you didn't pass `--fix`.
|
|
95
126
|
|
|
96
|
-
|
|
97
|
-
2. Call `status` to inspect the root and index. In lean mode, enable it with `discover_tools(enable:["status"])`.
|
|
98
|
-
3. Read a known small source target with `context` in lean mode, or `explain` in workflow mode.
|
|
99
|
-
4. For first-time indexing or reported drift requiring a rebuild, enable/call `reindex`. `no_embed:true` builds structural evidence without eager corpus embeddings.
|
|
127
|
+
`npx -y contextpro-mcp --help` lists the commands, and `--version` prints the installed version.
|
|
100
128
|
|
|
101
|
-
|
|
129
|
+
In the client, a first read looks like this. Use a line range: a whole file larger than `max_tokens` is omitted rather than cut.
|
|
102
130
|
|
|
103
|
-
|
|
131
|
+
```js
|
|
132
|
+
context({ root: "/absolute/path/to/project", targets: [{ file: "src/index.ts", start: 1, end: 40 }], max_tokens: 1500 })
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Replace `src/index.ts` with a file in your project. For callers of a symbol:
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
exact_references({ root: "/absolute/path/to/project", file: "src/lib/foo.ts", symbol_name: "foo" })
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Without Ollama, `context()` results include a "Discovery used lexical fallback" notice. That is expected and doesn't affect `exact_references`.
|
|
142
|
+
|
|
143
|
+
To inspect the index, enable `status` with `discover_tools(enable:["status"])`. If the tool doesn't appear (some clients don't refresh their tool list), call it through `discover_tools({ root, call: { name: "status", arguments: {} } })`. For first-time indexing, or drift that needs a rebuild, enable and call `reindex`; `no_embed:true` builds structural data without embeddings. This is installation diagnosis, not something to run on every task.
|
|
144
|
+
|
|
145
|
+
## Optional setup
|
|
146
|
+
|
|
147
|
+
### Workflow profile
|
|
148
|
+
|
|
149
|
+
`CONTEXTPRO_TOOL_PROFILE` picks the starting tool list. `lean` (3 tools) is recommended. `workflow` (14 tools for discovery, reads, impact and validation) is the server default when no profile is set; `core` has 39 and `full` all 68. See [profiles](docs/configuration.md#profiles).
|
|
150
|
+
|
|
151
|
+
### Semantic search with Ollama
|
|
152
|
+
|
|
153
|
+
Embeddings are optional. ContextPro tries a local Ollama at `OLLAMA_HOST` (default `http://127.0.0.1:11434`) automatically and falls back to keyword search when it's unavailable. Compiler references and structural search work either way. To enable semantic search, install Ollama and run `ollama pull nomic-embed-text`.
|
|
154
|
+
|
|
155
|
+
The defaults are already provider `ollama` and model `nomic-embed-text:latest`; set them explicitly only to pin or change them:
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
"env": {
|
|
159
|
+
"CONTEXTPRO_TOOL_PROFILE": "lean",
|
|
160
|
+
"CONTEXTPRO_PROVIDER": "ollama",
|
|
161
|
+
"CONTEXTPRO_EMBED_MODEL": "nomic-embed-text:latest"
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The `CONTEXTPRO_PROVIDER` and `CONTEXTPRO_EMBED_MODEL` lines above are the defaults. ContextPro needs its own embedding endpoint; it does not reuse a Claude or Codex session. Reindex after changing the model. For structural-only indexing with no embeddings, set `CONTEXTPRO_REINDEX_NO_EMBED=true` or pass `no_embed:true` to `reindex`.
|
|
166
|
+
|
|
167
|
+
Chat-assisted operations are optional. Leave `CONTEXTPRO_CHAT_RERANK` and `CONTEXTPRO_AUTO_HUBS` off unless needed. Hosted credentials can make a default chat model available even without an explicit chat-model setting, so omitting that setting is not a network-off switch. See [provider settings](docs/configuration.md#providers).
|
|
104
168
|
|
|
105
|
-
|
|
169
|
+
## Run from source
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
git clone https://github.com/AlaeddineMessadi/contextpro-mcp.git
|
|
173
|
+
cd contextpro-mcp
|
|
174
|
+
npm ci
|
|
175
|
+
npm run build
|
|
176
|
+
node build/index.js doctor --root /absolute/path/to/your-project
|
|
177
|
+
node -p 'process.execPath'
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Use the printed Node executable and your checkout path in the client config. Using the same executable in every client avoids differences between your shell's Node and a desktop client's PATH. For example, in a Claude Code `.mcp.json`:
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"mcpServers": {
|
|
185
|
+
"contextpro": {
|
|
186
|
+
"command": "/absolute/path/to/node",
|
|
187
|
+
"args": ["/absolute/path/to/contextpro-mcp/build/index.js", "--root", "/absolute/path/to/your-project"],
|
|
188
|
+
"env": { "CONTEXTPRO_TOOL_PROFILE": "lean" }
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
106
193
|
|
|
107
|
-
|
|
194
|
+
Restart the client after changes. A reconnect can reuse a cached launch command; `health` (enable it through `discover_tools`) shows the running executable and parser backend. The server repairs incompatible SQLite bindings in an isolated cache for the launching Node ABI; the first repair needs npm and network access.
|
|
108
195
|
|
|
109
196
|
## Native-module recovery
|
|
110
197
|
|
|
@@ -120,9 +207,12 @@ Do not rebuild shared `node_modules` merely to satisfy one client: clients using
|
|
|
120
207
|
|
|
121
208
|
## Worktrees and common problems
|
|
122
209
|
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
126
|
-
- **
|
|
127
|
-
- **
|
|
128
|
-
- **
|
|
210
|
+
- **`npm warn deprecated prebuild-install@7.1.3` from npx:** expected; it comes from a native dependency and does not affect ContextPro.
|
|
211
|
+
- **`Unsafe project root` at startup:** the server was started in `/`, in your home folder, or in a non-Git folder directly inside it, usually without `--root`. Add `--root /absolute/path/to/project`. If your project sits directly in your home folder and is not a Git repository, move it one level deeper, run `git init`, or set `CONTEXTPRO_ALLOW_UNSAFE_ROOT=true`.
|
|
212
|
+
- **`exact_references` finds nothing and warns that files could not be checked:** install the target project's dependencies (`npm install`) and retry.
|
|
213
|
+
- **Tools absent after a startup failure:** run the configured command directly to read stderr. From source, `ERR_MODULE_NOT_FOUND` with a missing `node_modules` means the checkout is incomplete: run `npm ci` and `npm run build` with the configured Node, then restart the client. Keep the checkout's dependencies and build while clients use it.
|
|
214
|
+
- **Wrong repository or worktree:** subagents must pass their absolute worktree `root` on every call. A shell `cd` does not retarget a shared MCP server. Linked worktrees require explicit roots, including for `reindex`. Client-advertised roots may describe the parent agent.
|
|
215
|
+
- **Local state:** `.contextpro/` in the project holds the index, memory and restore points. It is not entirely disposable; follow [maintenance](docs/maintenance.md) before deleting it. `~/.contextpro` holds the workspace registry and `~/.cache/contextpro` the native-binding cache.
|
|
216
|
+
- **Stale embeddings:** check provider and model settings, then reindex. Interactive search does not rebuild the whole vector corpus.
|
|
217
|
+
- **Slow or failed calls:** inspect `health` and `status`; use bounded results and keyword-only discovery when the provider is unavailable. Do not loop on connection errors.
|
|
218
|
+
- **Agent ignores ContextPro:** install the project rules with `init` or from [INSTRUCTIONS.md](INSTRUCTIONS.md).
|
package/INSTRUCTIONS.md
CHANGED
|
@@ -4,7 +4,7 @@ Append the following policy to your client's project rules, such as `AGENTS.md`
|
|
|
4
4
|
|
|
5
5
|
## Choose the smallest useful request
|
|
6
6
|
|
|
7
|
-
Use ContextPro for unfamiliar repository discovery, structural context and cross-file evidence. With the lean profile, use `context(query:...)` to find and read evidence together, or `context(targets:[...])` to batch known source targets. With the default
|
|
7
|
+
Use ContextPro for unfamiliar repository discovery, structural context and cross-file evidence. With the lean profile, use `context(query:...)` to find and read evidence together, or `context(targets:[...])` to batch known source targets. With the workflow profile (the server default when no profile is set; init installs lean), use `task_pack` or compact `search`; use `explain` for known symbols and `skeleton(exported_only:true)` for TS/JS public APIs.
|
|
8
8
|
|
|
9
9
|
Pass the absolute active repository/worktree as `root` on every call. For `context`, use `max_tokens` from 512 to 12000 (default 4000, estimated UTF-8 bytes/4) and at most six exact targets. Include a known relative directory and concrete route or symbol names in discovery questions. Directory and named-usage hints influence ranking; they are not exhaustive scope or compiler references. Ask explicitly for an overview when you want a UI inventory. If evidence is omitted, narrow to exact targets or a native scope search instead of repeating the same broad query.
|
|
10
10
|
|
package/README.md
CHANGED
|
@@ -1,165 +1,90 @@
|
|
|
1
1
|
# ContextPro
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/contextpro-mcp)
|
|
4
|
+
[](https://github.com/AlaeddineMessadi/contextpro-mcp/actions/workflows/ci.yml)
|
|
5
|
+
[](LICENSE)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
**Exact find-all-references for your coding agent on TypeScript/JavaScript repos — answered by the TypeScript compiler, not grep.**
|
|
6
8
|
|
|
7
|
-
[
|
|
9
|
+
ContextPro is a local [MCP](https://modelcontextprotocol.io) server for agents such as Claude Code, Codex, Cursor and OpenCode. Its compiler-backed "find all references" means a rename or refactor is far less likely to miss callers that import the function under another name or through a re-export (within the files the compiler can check). It also serves source reads with a size limit, so the agent gets the lines it needs instead of whole files. It runs on your machine and needs no API key.
|
|
8
10
|
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
- **Renames and refactors in TS/JS codebases.** `exact_references` resolves bindings with the compiler and reports per-file call totals, reference kinds and truncation, so an agent knows what it has not seen.
|
|
12
|
-
- **Parallel agents on one repository.** Indexes are scoped per Git worktree, check saved-file drift and reconcile in the background.
|
|
13
|
-
- **A small tool catalog.** The lean profile exposes three of the 68 tools; the rest are discovered only when needed.
|
|
14
|
-
- **Inspectable evidence.** Responses separate compiler-resolved references, textual candidates and heuristic fallbacks, and report freshness.
|
|
11
|
+
## Quick start
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
Requirements: Node.js 20–26 (24 LTS recommended). No API key or Ollama needed. For compiler references, install the target project's dependencies first (`npm install`); otherwise files can't be checked.
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
**Fastest try (Claude Code):**
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
```sh
|
|
18
|
+
cd your-project
|
|
19
|
+
claude mcp add contextpro -e CONTEXTPRO_TOOL_PROFILE=lean -- npx -y contextpro-mcp --root "$PWD"
|
|
20
|
+
claude mcp list # contextpro: ... ✔ Connected
|
|
21
|
+
```
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
| --- | --- |
|
|
24
|
-
| Compiler reference checks on two fixtures (barrel aliases, same-named bindings) | 24 of 24 timed queries passed |
|
|
25
|
-
| Response size on six retrieval tasks vs a scripted `rg`/`git` baseline | about 41% fewer response tokens, but about 6.8× slower per call |
|
|
26
|
-
| Matched agent trials (2 read-only tasks), lean profile vs native tools | **23.8% more** total input, **19.2% more** wall time |
|
|
27
|
-
| Matched agent trials (2 read-only tasks), workflow profile vs native tools | **128.7% more** total input |
|
|
28
|
-
| Eight paired coding tasks, previous ContextPro build vs connected-retrieval candidate | previous build 1/8, candidate 0/8 (six on private repositories; see connected-evidence report) |
|
|
23
|
+
Keep the server name before `-e`, which would otherwise swallow it.
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
**Claude Code, whole team** (commits `.mcp.json` plus agent instructions in `AGENTS.md` and `CLAUDE.md`):
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
```sh
|
|
28
|
+
npx -y contextpro-mcp init claude
|
|
29
|
+
claude # start it in the repository root and approve "contextpro" once
|
|
30
|
+
```
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
**Codex:**
|
|
35
33
|
|
|
36
34
|
```sh
|
|
37
|
-
|
|
38
|
-
cd contextpro-mcp
|
|
39
|
-
npm ci
|
|
40
|
-
npm run build
|
|
41
|
-
node build/index.js doctor --root /absolute/path/to/your-project
|
|
42
|
-
node -p 'process.execPath'
|
|
35
|
+
codex mcp add contextpro --env CONTEXTPRO_TOOL_PROFILE=lean -- npx -y contextpro-mcp --root /absolute/path/to/project
|
|
43
36
|
```
|
|
44
37
|
|
|
45
|
-
|
|
38
|
+
**Cursor and other clients that read `mcpServers` JSON** (`.cursor/mcp.json` or the client's config file):
|
|
46
39
|
|
|
47
40
|
```json
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
"args": ["/absolute/path/to/contextpro-mcp/build/index.js", "--root", "/absolute/path/to/your-project"],
|
|
53
|
-
"env": { "CONTEXTPRO_TOOL_PROFILE": "lean" }
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
41
|
+
{ "mcpServers": { "contextpro": {
|
|
42
|
+
"command": "npx",
|
|
43
|
+
"args": ["-y", "contextpro-mcp", "--root", "/absolute/path/to/project"],
|
|
44
|
+
"env": { "CONTEXTPRO_TOOL_PROFILE": "lean" } } } }
|
|
57
45
|
```
|
|
58
46
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Install the project instructions as well as the server: connecting MCP exposes tools,
|
|
62
|
-
while `AGENTS.md` / `CLAUDE.md` teaches the agent when to use them. The detailed
|
|
63
|
-
workflow is available on demand through `contextpro://instructions`. A separate
|
|
64
|
-
skill is optional; it does not enable tools or repair retrieval.
|
|
47
|
+
**OpenCode:** run `npx -y contextpro-mcp init opencode`, then `opencode mcp list`.
|
|
65
48
|
|
|
66
|
-
|
|
49
|
+
**Try it.** Ask your agent:
|
|
67
50
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
| Locate unfamiliar code and read evidence | `context(query:...)` | Retrieval is a ranked selection, not an exhaustive search |
|
|
71
|
-
| Read several known targets | `context(targets:[...])` | Follow explicit omissions if more evidence is needed |
|
|
72
|
-
| Find TS/JS references | `exact_references` | Declared scope, reference kinds and truncation |
|
|
73
|
-
| Inspect an exported API | Discover `skeleton`, then use `exported_only:true` | Signatures do not prove behavior |
|
|
74
|
-
| Assess a change | Discover `blast_radius` or `validate_scope` | Text matches are candidates; recommended checks still need to run |
|
|
75
|
-
| Preserve a decision | Discover `memory_record_task` | Keep supporting evidence and revisit stale assumptions |
|
|
76
|
-
| Inspect compiler errors or rename a binding | Discover `compiler_diagnostics` / `rename_preview` | TS/JS compiler or configured Pyright; inspect before `rename_apply` |
|
|
77
|
-
| Record executed checks | `validate_scope`, then discover `validation_record` | Run checks in the coding host; receipts become stale when inputs change |
|
|
51
|
+
- "Use contextpro to find every caller of `<function>` in `<file>`."
|
|
52
|
+
- "Use contextpro to show me how `<feature>` works."
|
|
78
53
|
|
|
79
|
-
|
|
54
|
+
[INSTALL.md](INSTALL.md) covers VS Code, team approval, a smoke test that works without any client, running from source and troubleshooting.
|
|
80
55
|
|
|
81
|
-
|
|
82
|
-
| --- | --- |
|
|
83
|
-
| `lean` | `context`, `exact_references`, `discover_tools` |
|
|
84
|
-
| `workflow` (default) | 14 tools for discovery, reads, impact and validation |
|
|
85
|
-
| `core` | 39 tools: common workflows plus editing and graphs |
|
|
86
|
-
| `full` | All 68 registered tools, including 5 deprecated aliases |
|
|
87
|
-
|
|
88
|
-
Set `CONTEXTPRO_TOOL_PROFILE` in the server environment. `discover_tools(enable:[...])` enables tools without executing them. If the client cannot refresh its catalog, use the supported `discover_tools({root,call:{name,arguments}})` dispatcher with the returned expert schema.
|
|
89
|
-
|
|
90
|
-
Experimental connected retrieval (`CONTEXTPRO_CONNECTED_CONTEXT=true`) combines ranked source, one-hop imports/callers and relevant tests in `context` and `task_pack`. It remains opt-in while task-level performance is evaluated. Discover `feature_brief` for a cached, source-cited feature map; model-written interpretations require a separate opt-in. Query-based `context` packets accept `previous_context_id` while the agent still holds that packet; omit it after context loss. Exact target reads remain stateless. See [configuration and freshness rules](docs/configuration.md).
|
|
91
|
-
|
|
92
|
-
The optional `context.intent` hint (`lookup`, `change`, `debug`, `review`, `overview`, or `auto`) enables question-aware source and document retrieval for one query. Shared indexing/compiler work is also opt-in through `contextpro daemon start` and `CONTEXTPRO_DAEMON=true`. Evidence-backed memory and handoffs build on the existing SQLite/artifact architecture; experimental features such as local task coordination are documented in configuration. [Configuration](docs/configuration.md#experimental-development-context) explains setup, limits and rollback; these features do not establish a measured coding-speed improvement.
|
|
93
|
-
|
|
94
|
-
## Ask for the source you need
|
|
95
|
-
|
|
96
|
-
Pass the absolute active repository or worktree as `root` on every call. Query
|
|
97
|
-
budgets use `max_tokens` (512–12000, default 4000; estimated UTF-8 bytes divided by
|
|
98
|
-
four). Exact batches accept up to six targets.
|
|
99
|
-
|
|
100
|
-
This example uses ContextPro's own repository. In another project, use paths and
|
|
101
|
-
declaration names observed in its source rather than guessed symbols.
|
|
102
|
-
|
|
103
|
-
```js
|
|
104
|
-
context({
|
|
105
|
-
root: "/absolute/path/to/contextpro-mcp",
|
|
106
|
-
query: "src/core/agent-setup.ts mergeAgentInstructions preserve existing project rules",
|
|
107
|
-
intent: "change",
|
|
108
|
-
max_tokens: 2500
|
|
109
|
-
})
|
|
110
|
-
context({
|
|
111
|
-
root: "/absolute/path/to/contextpro-mcp",
|
|
112
|
-
targets: [{file: "src/core/agent-setup.ts", symbol: "mergeAgentInstructions"}],
|
|
113
|
-
max_tokens: 1500
|
|
114
|
-
})
|
|
115
|
-
// Use compiler references when binding identity or cross-file callers matter.
|
|
116
|
-
exact_references({
|
|
117
|
-
root: "/absolute/path/to/contextpro-mcp",
|
|
118
|
-
file: "src/core/agent-setup.ts",
|
|
119
|
-
symbol_name: "mergeAgentInstructions",
|
|
120
|
-
limit: 20
|
|
121
|
-
})
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
These are task-dependent choices, not a checklist: stop when enough evidence is
|
|
125
|
-
available. If a broad query favors documentation, read the discovered source
|
|
126
|
-
symbol or a narrow line range directly. If references time out, continue with
|
|
127
|
-
bounded source/native tracing and disclose its limits; lowering `limit` changes
|
|
128
|
-
the display window, not compiler workspace scope. Read each tool's schema:
|
|
129
|
-
`max_tokens` is a `context` budget, not an argument for `status` or `exact_references`.
|
|
130
|
-
|
|
131
|
-
Known directory prefixes and route topics help query discovery retain the requested
|
|
132
|
-
implementation. A named component or compound error code supplies additional local
|
|
133
|
-
text evidence. These are bounded ranking hints, not hard directory filters or
|
|
134
|
-
compiler-resolved references; connected dependencies may still come from elsewhere.
|
|
135
|
-
For a UI inventory, ask explicitly for an overview. For a bug, name the affected
|
|
136
|
-
symbol and source area. Check citations and omissions, then narrow to exact targets
|
|
137
|
-
when needed rather than repeating the same broad query.
|
|
56
|
+
## What it is good at
|
|
138
57
|
|
|
139
|
-
|
|
58
|
+
- **Safe renames and refactors.** The compiler tells apart aliased imports, re-exports and different functions that share a name, and the answer says how many results exist and whether any were cut off.
|
|
59
|
+
- **Reading just enough source.** The agent asks for a file, a symbol or a line range under a size budget and is told what was left out.
|
|
60
|
+
- **Several agents on one repository.** Each Git worktree gets its own index, kept up to date as files change.
|
|
61
|
+
- **A small tool list.** The recommended `lean` setup shows the agent three tools (`context`, `exact_references` and `discover_tools`); the other 65 stay hidden until the agent asks for them.
|
|
140
62
|
|
|
141
|
-
|
|
63
|
+
Python references work through a configured Pyright; other languages fall back to structural and text search.
|
|
142
64
|
|
|
143
|
-
|
|
65
|
+
## Honest results
|
|
144
66
|
|
|
145
|
-
|
|
67
|
+
ContextPro has not been shown to make agents finish tasks faster. Our own trials, published in [docs/benchmarks](docs/benchmarks/README.md), include the losses.
|
|
146
68
|
|
|
147
|
-
|
|
69
|
+
It is worth trying for renames and refactors where aliased or re-exported callers matter, or when you don't know where the code lives.
|
|
148
70
|
|
|
149
|
-
|
|
71
|
+
| Measured | Result |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| Compiler reference checks on two fixtures (barrel aliases, same-named bindings) | 24 of 24 timed queries passed |
|
|
74
|
+
| Response size on six retrieval tasks vs a scripted `rg`/`git` baseline | about 41% fewer response tokens, but about 6.8× slower per call |
|
|
75
|
+
| Matched agent trials (2 read-only tasks), lean profile vs native tools | **23.8% more** total input, **19.2% more** wall time |
|
|
76
|
+
| Matched agent trials (2 read-only tasks), workflow profile vs native tools | **128.7% more** total input |
|
|
150
77
|
|
|
151
|
-
|
|
152
|
-
npm run build
|
|
153
|
-
npm test
|
|
154
|
-
npm run docs:check
|
|
155
|
-
npm run release:check
|
|
156
|
-
npm run pack:check
|
|
157
|
-
```
|
|
78
|
+
For simple lookups, plain grep is cheaper. We welcome reproducible comparisons, including ones where another tool wins; see [how we compare](docs/comparison.md).
|
|
158
79
|
|
|
159
|
-
|
|
80
|
+
## Learn more
|
|
160
81
|
|
|
161
|
-
|
|
82
|
+
- [Install and troubleshoot](INSTALL.md)
|
|
83
|
+
- [Agent guide](agent-guide.md): how agents should call the tools, with examples
|
|
84
|
+
- [Configuration](docs/configuration.md): tool profiles, providers and environment variables
|
|
85
|
+
- [Security model](SECURITY.md): what runs locally and what a hosted provider would see
|
|
86
|
+
- [All documentation](docs/README.md) · [Contributing](CONTRIBUTING.md) · [Support](SUPPORT.md)
|
|
162
87
|
|
|
163
88
|
## License and origins
|
|
164
89
|
|
|
165
|
-
ContextPro began as a fork of [Context+](https://github.com/ForLoopCodes/contextplus) by ForLoop and has since been largely rewritten
|
|
90
|
+
ContextPro began as a fork of [Context+](https://github.com/ForLoopCodes/contextplus) by ForLoop and has since been largely rewritten. It is distributed under the [MIT license](LICENSE); the original ForLoop copyright notice is preserved, see [NOTICE](NOTICE).
|
package/SECURITY.md
CHANGED
|
@@ -12,16 +12,18 @@ Include the affected version or commit, Node/OS/client versions, a minimal redac
|
|
|
12
12
|
|
|
13
13
|
## Supported versions
|
|
14
14
|
|
|
15
|
-
Security fixes target the latest maintained release and `main`.
|
|
15
|
+
Security fixes target the latest maintained release and `main`. Identify reports by npm version or Git commit. Older versions do not have a promised backport window. Node.js 24 LTS is recommended; CI also checks the Node 20 engine floor. The package's older engine floor is a compatibility declaration, not a promise to maintain end-of-life runtimes.
|
|
16
16
|
|
|
17
17
|
## Trust and data boundaries
|
|
18
18
|
|
|
19
19
|
- **Same-user permissions.** ContextPro is a local stdio MCP process, not a sandbox. Filesystem, edit and command-related operations can use the launching user's access. Choose a trusted project root and review your client's tool permissions.
|
|
20
20
|
- **Untrusted repositories.** Code, comments, docs, tool results and memory can contain malicious instructions. Agents must treat them as data. Installing dependencies or running a repository's tests, hooks, linters or commands may execute its code.
|
|
21
|
-
- **Local state.** `.contextpro/` can contain indexed source, task artifacts, history, memory and restore points.
|
|
21
|
+
- **Local state.** `.contextpro/` can contain indexed source, task artifacts, history, memory and restore points. ContextPro writes `.contextpro/.gitignore` to keep it out of Git; protect it like the repository. It is not entirely disposable cache. The workspace registry can reveal local project paths.
|
|
22
22
|
- **Providers.** Hosted embedding/chat endpoints receive their request inputs, which may include source code. Local Ollama is an option. Structural tools do not require an embedding endpoint; use direct reads or keyword-only retrieval to avoid query-embedding attempts. Merely omitting a chat-model setting is not a network-off guarantee when hosted credentials are present.
|
|
23
23
|
- **Native dependency recovery.** Automatic ABI repair may invoke npm and download dependencies into an isolated cache. Set `CONTEXTPRO_NATIVE_AUTO_REPAIR=false` when installation must be managed explicitly.
|
|
24
24
|
- **Diagnostics.** Opt-in tool traces and agent benchmark transcripts can reveal paths, arguments, source and usage metadata. Keep them private and redact before sharing. Do not upload `.env` files or account credentials.
|
|
25
25
|
- **Correctness limits.** Freshness and scope checks reduce errors; they do not prove an arbitrary change safe. Unsaved buffers, concurrent edits, dynamic calls and incomplete imported indexes require verification.
|
|
26
|
+
- **Evidence labels.** Responses distinguish source evidence, compiler-resolved references, textual candidates and heuristic fallbacks. Freshness checks cover saved files, not unsaved editor buffers, and per-file reconciliation is not an atomic snapshot of a repository being edited concurrently. Configured Python uses Pyright LSP; unconfigured Python heuristics and imported SCIP data keep their own provenance labels.
|
|
27
|
+
- **Worker isolation.** Parser and TypeScript workers run in bounded child processes, so a worker failure is reported and recovered from without necessarily stopping the MCP server. This is fault isolation, not a security sandbox.
|
|
26
28
|
|
|
27
29
|
See [configuration](docs/configuration.md) and [maintenance](docs/maintenance.md) for provider controls and safe cleanup. A clean dependency audit or secret scan is a point-in-time check, not a security certification.
|