@contextstream/mcp-server 0.4.22 → 0.4.23

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 (4) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +397 -395
  3. package/dist/index.js +171 -24
  4. package/package.json +57 -57
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 ContextStream
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ContextStream
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,328 +1,330 @@
1
- # ContextStream MCP Server
2
-
3
- Persistent memory, semantic search, and code intelligence for any MCP-compatible AI tool (Cursor, Claude Code, Windsurf, VS Code, Claude Desktop, Codex CLI, etc.).
4
-
5
- ContextStream is a shared "brain" for AI-assisted development. It stores decisions, preferences, lessons, tasks, and project context — and lets your AI tools search and analyze your codebase with consistent context across sessions.
6
-
7
- **v0.4.x:** Consolidated domain tools (~11 tools) for **~75% lower tool-registry token overhead** vs previous versions.
8
-
9
- ---
10
-
11
- ## Just Ask
12
-
13
- **You don't need to memorize tool names.** Describe what you want and your AI will call the right ContextStream tools:
14
-
15
- | You say… | ContextStream does… |
16
- |----------|---------------------|
17
- | "session summary" | Summarizes current workspace/project context |
18
- | "what did we decide about auth?" | Recalls decisions related to authentication |
19
- | "remember we're using PostgreSQL" | Captures that fact for future sessions |
20
- | "search for payment code" | Searches your codebase semantically/hybrid/keyword |
21
- | "what depends on UserService?" | Analyzes dependency graph & impact |
22
-
23
- > **Tip:** For best results, add the **recommended editor rules** so your AI reliably calls `session_init` / `context_smart` when appropriate:
24
- > https://contextstream.io/docs/quickstart
25
-
26
- ![ContextStream in action](compare1.gif)
27
-
28
- ---
29
-
30
- ## Choose Your Mode (Token Footprint)
31
-
32
- MCP clients often inject the tool catalog into the model context. v0.4.x is designed to keep that overhead small.
33
-
34
- | Mode | What it exposes | Best for | Enable |
35
- |------|-----------------|----------|--------|
36
- | **Consolidated** (default) | ~11 domain tools with `action` / `mode` dispatch | Most users (recommended) | `CONTEXTSTREAM_CONSOLIDATED=true` |
37
- | **Router** (extreme minimization) | ~2 meta-tools (`contextstream`, `contextstream_help`) | Tight context budgets / many MCP servers | `CONTEXTSTREAM_PROGRESSIVE_MODE=true` |
38
- | **Legacy** (granular tools) | Older `light/standard/complete` toolsets | Back-compat / old prompts | `CONTEXTSTREAM_CONSOLIDATED=false` |
39
-
40
- > **Note:** The env var name for Router mode is `CONTEXTSTREAM_PROGRESSIVE_MODE` (historical naming). It enables the ~2-tool "router" surface.
41
-
42
- ---
43
-
44
- ## Features
45
-
46
- - **Consolidated domain tools** (v0.4.x): short tool list with action/mode dispatch
47
- - Session-aware context loading (`session_init`, `context_smart`)
48
- - Memory capture + recall (decisions, preferences, lessons, tasks, bugs)
49
- - Code search (semantic, hybrid, keyword, pattern)
50
- - Knowledge graph + code analysis (dependencies, impact, call paths, circular deps, unused code)
51
- - Graph ingestion for full graph builds (`graph(action="ingest")`)
52
- - Local repo ingestion for indexing (`project(action="ingest_local")`)
53
- - Auto-context: on first tool call in a new session, the server can auto-initialize context
54
-
55
- ---
56
-
57
- ## Graph Tiers
58
-
59
- | Tier | Capabilities |
60
- |------|--------------|
61
- | **Pro (Graph-Lite)** | Module-level import graph, dependencies, and 1-hop impact |
62
- | **Elite/Team (Full Graph)** | Module + call + dataflow + type layers, plus full graph ingestion |
63
-
64
- ---
65
-
66
- ## Requirements
67
-
68
- - **Node.js 18+**
69
- - A **ContextStream account**
70
- - Auth via **API key** or **JWT**
71
-
72
- Default API URL: `https://api.contextstream.io`
73
-
74
- ---
75
-
76
- ## Quickstart (2 minutes)
77
-
78
- ### 1) Run the Setup Wizard (recommended)
79
-
80
- The wizard:
81
- - Authenticates (browser/device login by default)
82
- - Creates/stores an API key
83
- - Installs recommended editor rules (optional)
84
- - Writes MCP config files for supported tools
85
-
86
- ```bash
87
- npx -y @contextstream/mcp-server setup
88
- ```
89
-
90
- **Useful flags:**
91
-
92
- | Flag | Description |
93
- |------|-------------|
94
- | `--dry-run` | Preview without writing files |
95
-
96
- **Notes:**
97
- - The wizard stores credentials at `~/.contextstream/credentials.json` for convenience. Delete it to force a fresh login.
98
- - Codex CLI MCP config is global-only (`~/.codex/config.toml`), so the wizard writes Codex config globally when selected.
99
- - Some tools still require UI/CLI setup (the wizard will tell you when it can't write a config).
100
-
101
- ### 2) Run the MCP Server
102
-
103
- **Recommended** (works well with MCP configs):
104
-
105
- ```bash
106
- npx -y @contextstream/mcp-server
107
- ```
108
-
109
- **Or install globally:**
110
-
111
- ```bash
112
- npm install -g @contextstream/mcp-server
113
- contextstream-mcp
114
- ```
115
-
116
- ### 3) Keeping Updated
117
-
118
- **If you use `npx`:** Restart your AI tool/editor and run ContextStream again
119
- (or pin the version: `npx -y @contextstream/mcp-server@0.4.3`)
120
-
121
- **If you installed globally:**
122
-
123
- ```bash
124
- npm update -g @contextstream/mcp-server
125
- ```
126
-
127
- After updating, restart your AI tool/editor so it reloads the tool catalog.
128
-
129
- ---
130
-
131
- ## Configure Your MCP Client (Manual)
132
-
133
- > If you ran the setup wizard, you can usually skip this.
134
-
135
- ### Cursor / Windsurf / Claude Desktop (JSON)
136
-
137
- These clients use an `mcpServers` JSON config:
138
-
139
- | Client | Config path |
140
- |--------|-------------|
141
- | **Cursor** | `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (project) |
142
- | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` |
143
- | **Claude Desktop (macOS)** | `~/Library/Application Support/Claude/claude_desktop_config.json` |
144
- | **Claude Desktop (Windows)** | `%APPDATA%\Claude\claude_desktop_config.json` |
145
-
146
- **Consolidated (default):**
147
-
148
- ```json
149
- {
150
- "mcpServers": {
151
- "contextstream": {
152
- "command": "npx",
153
- "args": ["-y", "@contextstream/mcp-server"],
154
- "env": {
155
- "CONTEXTSTREAM_API_URL": "https://api.contextstream.io",
156
- "CONTEXTSTREAM_API_KEY": "YOUR_API_KEY"
157
- }
158
- }
159
- }
160
- }
161
- ```
162
-
163
- **Router mode (~2 meta-tools):**
164
-
165
- ```json
166
- {
167
- "mcpServers": {
168
- "contextstream": {
169
- "command": "npx",
170
- "args": ["-y", "@contextstream/mcp-server"],
171
- "env": {
172
- "CONTEXTSTREAM_API_URL": "https://api.contextstream.io",
173
- "CONTEXTSTREAM_API_KEY": "YOUR_API_KEY",
174
- "CONTEXTSTREAM_PROGRESSIVE_MODE": "true"
175
- }
176
- }
177
- }
178
- }
179
- ```
180
-
181
- ### VS Code (`.vscode/mcp.json`)
182
-
183
- VS Code uses a top-level `servers` map:
184
-
185
- ```json
186
- {
187
- "servers": {
188
- "contextstream": {
189
- "type": "stdio",
190
- "command": "npx",
191
- "args": ["-y", "@contextstream/mcp-server"],
192
- "env": {
193
- "CONTEXTSTREAM_API_URL": "https://api.contextstream.io",
194
- "CONTEXTSTREAM_API_KEY": "YOUR_API_KEY"
195
- }
196
- }
197
- }
198
- }
199
- ```
200
-
201
- **Strong recommendation:** Use `inputs` so you don't commit secrets:
202
-
203
- ```json
204
- {
205
- "servers": {
206
- "contextstream": {
207
- "type": "stdio",
208
- "command": "npx",
209
- "args": ["-y", "@contextstream/mcp-server"],
210
- "env": {
211
- "CONTEXTSTREAM_API_URL": "https://api.contextstream.io",
212
- "CONTEXTSTREAM_API_KEY": "${input:contextstreamApiKey}"
213
- }
214
- }
215
- },
216
- "inputs": [
217
- {
218
- "id": "contextstreamApiKey",
219
- "type": "promptString",
220
- "description": "ContextStream API Key",
221
- "password": true
222
- }
223
- ]
224
- }
225
- ```
226
-
227
- ### Claude Code (CLI)
228
-
229
- **User scope (all projects):**
230
-
231
- ```bash
232
- claude mcp add --transport stdio contextstream --scope user \
233
- --env CONTEXTSTREAM_API_URL=https://api.contextstream.io \
234
- --env CONTEXTSTREAM_API_KEY=YOUR_KEY \
235
- -- npx -y @contextstream/mcp-server
236
- ```
237
-
238
- **Router mode:**
239
-
240
- ```bash
241
- claude mcp add --transport stdio contextstream --scope user \
242
- --env CONTEXTSTREAM_API_URL=https://api.contextstream.io \
243
- --env CONTEXTSTREAM_API_KEY=YOUR_KEY \
244
- --env CONTEXTSTREAM_PROGRESSIVE_MODE=true \
245
- -- npx -y @contextstream/mcp-server
246
- ```
247
-
248
- > **Windows caveat** (native Windows, not WSL): if `npx` isn't found, use `cmd /c npx -y @contextstream/mcp-server` after `--`.
249
-
250
- ### Codex CLI (`~/.codex/config.toml`)
251
-
252
- ```toml
253
- [mcp_servers.contextstream]
254
- command = "npx"
255
- args = ["-y", "@contextstream/mcp-server"]
256
-
257
- [mcp_servers.contextstream.env]
258
- CONTEXTSTREAM_API_URL = "https://api.contextstream.io"
259
- CONTEXTSTREAM_API_KEY = "YOUR_API_KEY"
260
- ```
261
-
262
- ---
263
-
264
- ## Tool Overview (v0.4.x Consolidated)
265
-
266
- In consolidated mode, you call **domain tools** with `action` / `mode`:
267
-
268
- ### Core
269
-
270
- | Tool | Description |
271
- |------|-------------|
272
- | `session_init` | Initialize workspace/project context |
273
- | `context_smart` | Retrieve the best bounded context for the current message |
274
-
275
- ### Domain Tools
276
-
277
- | Tool | Description |
278
- |------|-------------|
279
- | `search` | `mode=semantic\|hybrid\|keyword\|pattern` |
280
- | `session` | `action=capture\|recall\|remember\|get_lessons\|capture_lesson\|...` |
281
- | `memory` | Events + nodes CRUD, decisions, lessons, etc. |
282
- | `graph` | Dependencies, impact, call_path, ingest, etc. |
283
- | `project` | Indexing, ingest_local, stats, files, etc. |
284
- | `workspace` | List, get, associate, bootstrap |
285
- | `reminder` | List, create, snooze, complete, dismiss |
286
- | `integration` | `provider=slack\|github`, search, activity, etc. |
287
- | `help` | Tools, auth, version, editor_rules |
288
-
289
- ### Examples
290
-
291
- ```
1
+ # ContextStream MCP Server
2
+
3
+ Persistent memory, semantic search, and code intelligence for any MCP-compatible AI tool (Cursor, Claude Code, Windsurf, VS Code, Claude Desktop, Codex CLI, etc.).
4
+
5
+ ContextStream is a shared "brain" for AI-assisted development. It stores decisions, preferences, lessons, tasks, and project context — and lets your AI tools search and analyze your codebase with consistent context across sessions.
6
+
7
+ **v0.4.x:** Consolidated domain tools (~11 tools) for **~75% lower tool-registry token overhead** vs previous versions.
8
+
9
+ ---
10
+
11
+ ## Just Ask
12
+
13
+ **You don't need to memorize tool names.** Describe what you want and your AI will call the right ContextStream tools:
14
+
15
+ | You say… | ContextStream does… |
16
+ |----------|---------------------|
17
+ | "session summary" | Summarizes current workspace/project context |
18
+ | "what did we decide about auth?" | Recalls decisions related to authentication |
19
+ | "remember we're using PostgreSQL" | Captures that fact for future sessions |
20
+ | "search for payment code" | Searches your codebase semantically/hybrid/keyword |
21
+ | "what depends on UserService?" | Analyzes dependency graph & impact |
22
+
23
+ > **Tip:** For best results, add the **recommended editor rules** so your AI reliably calls `session_init` / `context_smart` when appropriate:
24
+ > https://contextstream.io/docs/quickstart
25
+
26
+ ![ContextStream in action](compare1.gif)
27
+
28
+ ---
29
+
30
+ ## Choose Your Mode (Token Footprint)
31
+
32
+ MCP clients often inject the tool catalog into the model context. v0.4.x is designed to keep that overhead small.
33
+
34
+ | Mode | What it exposes | Best for | Enable |
35
+ |------|-----------------|----------|--------|
36
+ | **Consolidated** (default) | ~11 domain tools with `action` / `mode` dispatch | Most users (recommended) | `CONTEXTSTREAM_CONSOLIDATED=true` |
37
+ | **Router** (extreme minimization) | ~2 meta-tools (`contextstream`, `contextstream_help`) | Tight context budgets / many MCP servers | `CONTEXTSTREAM_PROGRESSIVE_MODE=true` |
38
+ | **Legacy** (granular tools) | Older `light/standard/complete` toolsets | Back-compat / old prompts | `CONTEXTSTREAM_CONSOLIDATED=false` |
39
+
40
+ > **Note:** The env var name for Router mode is `CONTEXTSTREAM_PROGRESSIVE_MODE` (historical naming). It enables the ~2-tool "router" surface.
41
+
42
+ ---
43
+
44
+ ## Features
45
+
46
+ - **Consolidated domain tools** (v0.4.x): short tool list with action/mode dispatch
47
+ - Session-aware context loading (`session_init`, `context_smart`)
48
+ - Memory capture + recall (decisions, preferences, lessons, tasks, bugs)
49
+ - Code search (semantic, hybrid, keyword, pattern)
50
+ - Knowledge graph + code analysis (dependencies, impact, call paths, circular deps, unused code)
51
+ - Graph ingestion for full graph builds (`graph(action="ingest")`)
52
+ - Local repo ingestion for indexing (`project(action="ingest_local")`)
53
+ - Auto-context: on first tool call in a new session, the server can auto-initialize context
54
+
55
+ > **⚠️ Search-First Rule:** For best results, your AI should use ContextStream `search(mode="hybrid")` **before** local tools like Glob/Grep/Read. This is enforced via editor rules and `context_smart` responses.
56
+
57
+ ---
58
+
59
+ ## Graph Tiers
60
+
61
+ | Tier | Capabilities |
62
+ |------|--------------|
63
+ | **Pro (Graph-Lite)** | Module-level import graph, dependencies, and 1-hop impact |
64
+ | **Elite/Team (Full Graph)** | Module + call + dataflow + type layers, plus full graph ingestion |
65
+
66
+ ---
67
+
68
+ ## Requirements
69
+
70
+ - **Node.js 18+**
71
+ - A **ContextStream account**
72
+ - Auth via **API key** or **JWT**
73
+
74
+ Default API URL: `https://api.contextstream.io`
75
+
76
+ ---
77
+
78
+ ## Quickstart (2 minutes)
79
+
80
+ ### 1) Run the Setup Wizard (recommended)
81
+
82
+ The wizard:
83
+ - Authenticates (browser/device login by default)
84
+ - Creates/stores an API key
85
+ - Installs recommended editor rules (optional)
86
+ - Writes MCP config files for supported tools
87
+
88
+ ```bash
89
+ npx -y @contextstream/mcp-server setup
90
+ ```
91
+
92
+ **Useful flags:**
93
+
94
+ | Flag | Description |
95
+ |------|-------------|
96
+ | `--dry-run` | Preview without writing files |
97
+
98
+ **Notes:**
99
+ - The wizard stores credentials at `~/.contextstream/credentials.json` for convenience. Delete it to force a fresh login.
100
+ - Codex CLI MCP config is global-only (`~/.codex/config.toml`), so the wizard writes Codex config globally when selected.
101
+ - Some tools still require UI/CLI setup (the wizard will tell you when it can't write a config).
102
+
103
+ ### 2) Run the MCP Server
104
+
105
+ **Recommended** (works well with MCP configs):
106
+
107
+ ```bash
108
+ npx -y @contextstream/mcp-server
109
+ ```
110
+
111
+ **Or install globally:**
112
+
113
+ ```bash
114
+ npm install -g @contextstream/mcp-server
115
+ contextstream-mcp
116
+ ```
117
+
118
+ ### 3) Keeping Updated
119
+
120
+ **If you use `npx`:** Restart your AI tool/editor and run ContextStream again
121
+ (or pin the version: `npx -y @contextstream/mcp-server@0.4.3`)
122
+
123
+ **If you installed globally:**
124
+
125
+ ```bash
126
+ npm update -g @contextstream/mcp-server
127
+ ```
128
+
129
+ After updating, restart your AI tool/editor so it reloads the tool catalog.
130
+
131
+ ---
132
+
133
+ ## Configure Your MCP Client (Manual)
134
+
135
+ > If you ran the setup wizard, you can usually skip this.
136
+
137
+ ### Cursor / Windsurf / Claude Desktop (JSON)
138
+
139
+ These clients use an `mcpServers` JSON config:
140
+
141
+ | Client | Config path |
142
+ |--------|-------------|
143
+ | **Cursor** | `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (project) |
144
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` |
145
+ | **Claude Desktop (macOS)** | `~/Library/Application Support/Claude/claude_desktop_config.json` |
146
+ | **Claude Desktop (Windows)** | `%APPDATA%\Claude\claude_desktop_config.json` |
147
+
148
+ **Consolidated (default):**
149
+
150
+ ```json
151
+ {
152
+ "mcpServers": {
153
+ "contextstream": {
154
+ "command": "npx",
155
+ "args": ["-y", "@contextstream/mcp-server"],
156
+ "env": {
157
+ "CONTEXTSTREAM_API_URL": "https://api.contextstream.io",
158
+ "CONTEXTSTREAM_API_KEY": "YOUR_API_KEY"
159
+ }
160
+ }
161
+ }
162
+ }
163
+ ```
164
+
165
+ **Router mode (~2 meta-tools):**
166
+
167
+ ```json
168
+ {
169
+ "mcpServers": {
170
+ "contextstream": {
171
+ "command": "npx",
172
+ "args": ["-y", "@contextstream/mcp-server"],
173
+ "env": {
174
+ "CONTEXTSTREAM_API_URL": "https://api.contextstream.io",
175
+ "CONTEXTSTREAM_API_KEY": "YOUR_API_KEY",
176
+ "CONTEXTSTREAM_PROGRESSIVE_MODE": "true"
177
+ }
178
+ }
179
+ }
180
+ }
181
+ ```
182
+
183
+ ### VS Code (`.vscode/mcp.json`)
184
+
185
+ VS Code uses a top-level `servers` map:
186
+
187
+ ```json
188
+ {
189
+ "servers": {
190
+ "contextstream": {
191
+ "type": "stdio",
192
+ "command": "npx",
193
+ "args": ["-y", "@contextstream/mcp-server"],
194
+ "env": {
195
+ "CONTEXTSTREAM_API_URL": "https://api.contextstream.io",
196
+ "CONTEXTSTREAM_API_KEY": "YOUR_API_KEY"
197
+ }
198
+ }
199
+ }
200
+ }
201
+ ```
202
+
203
+ **Strong recommendation:** Use `inputs` so you don't commit secrets:
204
+
205
+ ```json
206
+ {
207
+ "servers": {
208
+ "contextstream": {
209
+ "type": "stdio",
210
+ "command": "npx",
211
+ "args": ["-y", "@contextstream/mcp-server"],
212
+ "env": {
213
+ "CONTEXTSTREAM_API_URL": "https://api.contextstream.io",
214
+ "CONTEXTSTREAM_API_KEY": "${input:contextstreamApiKey}"
215
+ }
216
+ }
217
+ },
218
+ "inputs": [
219
+ {
220
+ "id": "contextstreamApiKey",
221
+ "type": "promptString",
222
+ "description": "ContextStream API Key",
223
+ "password": true
224
+ }
225
+ ]
226
+ }
227
+ ```
228
+
229
+ ### Claude Code (CLI)
230
+
231
+ **User scope (all projects):**
232
+
233
+ ```bash
234
+ claude mcp add --transport stdio contextstream --scope user \
235
+ --env CONTEXTSTREAM_API_URL=https://api.contextstream.io \
236
+ --env CONTEXTSTREAM_API_KEY=YOUR_KEY \
237
+ -- npx -y @contextstream/mcp-server
238
+ ```
239
+
240
+ **Router mode:**
241
+
242
+ ```bash
243
+ claude mcp add --transport stdio contextstream --scope user \
244
+ --env CONTEXTSTREAM_API_URL=https://api.contextstream.io \
245
+ --env CONTEXTSTREAM_API_KEY=YOUR_KEY \
246
+ --env CONTEXTSTREAM_PROGRESSIVE_MODE=true \
247
+ -- npx -y @contextstream/mcp-server
248
+ ```
249
+
250
+ > **Windows caveat** (native Windows, not WSL): if `npx` isn't found, use `cmd /c npx -y @contextstream/mcp-server` after `--`.
251
+
252
+ ### Codex CLI (`~/.codex/config.toml`)
253
+
254
+ ```toml
255
+ [mcp_servers.contextstream]
256
+ command = "npx"
257
+ args = ["-y", "@contextstream/mcp-server"]
258
+
259
+ [mcp_servers.contextstream.env]
260
+ CONTEXTSTREAM_API_URL = "https://api.contextstream.io"
261
+ CONTEXTSTREAM_API_KEY = "YOUR_API_KEY"
262
+ ```
263
+
264
+ ---
265
+
266
+ ## Tool Overview (v0.4.x Consolidated)
267
+
268
+ In consolidated mode, you call **domain tools** with `action` / `mode`:
269
+
270
+ ### Core
271
+
272
+ | Tool | Description |
273
+ |------|-------------|
274
+ | `session_init` | Initialize workspace/project context |
275
+ | `context_smart` | Retrieve the best bounded context for the current message |
276
+
277
+ ### Domain Tools
278
+
279
+ | Tool | Description |
280
+ |------|-------------|
281
+ | `search` | `mode=semantic\|hybrid\|keyword\|pattern` |
282
+ | `session` | `action=capture\|recall\|remember\|get_lessons\|capture_lesson\|...` |
283
+ | `memory` | Events + nodes CRUD, decisions, lessons, etc. |
284
+ | `graph` | Dependencies, impact, call_path, ingest, etc. |
285
+ | `project` | Indexing, ingest_local, stats, files, etc. |
286
+ | `workspace` | List, get, associate, bootstrap |
287
+ | `reminder` | List, create, snooze, complete, dismiss |
288
+ | `integration` | `provider=slack\|github`, search, activity, etc. |
289
+ | `help` | Tools, auth, version, editor_rules |
290
+
291
+ ### Examples
292
+
293
+ ```
292
294
  search(mode="semantic", query="auth middleware", limit=3)
293
- memory(action="create_node", node_type="decision", title="Auth strategy", content="...")
294
- graph(action="impact", target="UserService")
295
- ```
296
-
297
- **Full tool catalog:** https://contextstream.io/docs/mcp/tools
298
-
299
- ---
300
-
301
- ## Authentication
302
-
303
- Set **one** of:
304
-
305
- | Variable | Use case |
306
- |----------|----------|
307
- | `CONTEXTSTREAM_API_KEY` | Recommended for local/dev |
308
- | `CONTEXTSTREAM_JWT` | Useful for hosted/user-session flows |
309
-
310
- ---
311
-
312
- ## Environment Variables
313
-
314
- ### Required
315
-
316
- | Variable | Description |
317
- |----------|-------------|
318
- | `CONTEXTSTREAM_API_URL` | Base API URL (default `https://api.contextstream.io`) |
319
- | `CONTEXTSTREAM_API_KEY` | API key (unless using JWT) |
320
- | `CONTEXTSTREAM_JWT` | JWT (unless using API key) |
321
-
322
- ### Token + Tool Surface Controls
323
-
324
- | Variable | Description |
325
- |----------|-------------|
295
+ memory(action="create_node", node_type="decision", title="Auth strategy", content="...")
296
+ graph(action="impact", target="UserService")
297
+ ```
298
+
299
+ **Full tool catalog:** https://contextstream.io/docs/mcp/tools
300
+
301
+ ---
302
+
303
+ ## Authentication
304
+
305
+ Set **one** of:
306
+
307
+ | Variable | Use case |
308
+ |----------|----------|
309
+ | `CONTEXTSTREAM_API_KEY` | Recommended for local/dev |
310
+ | `CONTEXTSTREAM_JWT` | Useful for hosted/user-session flows |
311
+
312
+ ---
313
+
314
+ ## Environment Variables
315
+
316
+ ### Required
317
+
318
+ | Variable | Description |
319
+ |----------|-------------|
320
+ | `CONTEXTSTREAM_API_URL` | Base API URL (default `https://api.contextstream.io`) |
321
+ | `CONTEXTSTREAM_API_KEY` | API key (unless using JWT) |
322
+ | `CONTEXTSTREAM_JWT` | JWT (unless using API key) |
323
+
324
+ ### Token + Tool Surface Controls
325
+
326
+ | Variable | Description |
327
+ |----------|-------------|
326
328
  | `CONTEXTSTREAM_CONSOLIDATED` | `true` (default in v0.4.x) uses consolidated domain tools |
327
329
  | `CONTEXTSTREAM_PROGRESSIVE_MODE` | Enables Router mode (~2 meta-tools) |
328
330
  | `CONTEXTSTREAM_CONTEXT_PACK` | Enable Context Pack for `context_smart` (code + graph + distill). Defaults to `true` |
@@ -332,74 +334,74 @@ Set **one** of:
332
334
  | `CONTEXTSTREAM_OUTPUT_FORMAT` | Output formatting; e.g., `compact` / `pretty` |
333
335
  | `CONTEXTSTREAM_SEARCH_LIMIT` | Default MCP search limit (default: 3) |
334
336
  | `CONTEXTSTREAM_SEARCH_MAX_CHARS` | Max chars per search result content (default: 400) |
335
-
336
- ### Optional Defaults
337
-
338
- | Variable | Description |
339
- |----------|-------------|
340
- | `CONTEXTSTREAM_WORKSPACE_ID` | Default workspace fallback |
341
- | `CONTEXTSTREAM_PROJECT_ID` | Default project ID fallback |
342
- | `CONTEXTSTREAM_USER_AGENT` | Custom user agent string |
343
- | `CONTEXTSTREAM_PRO_TOOLS` | Comma-separated tool names treated as PRO |
344
- | `CONTEXTSTREAM_UPGRADE_URL` | Upgrade link for Free users calling PRO tools |
345
-
346
- ---
347
-
348
- ## Migration Notes (pre-0.4.x → 0.4.x)
349
-
350
- Most workflows **just work**, but tool names change in consolidated mode.
351
-
352
- | Before (granular) | After (consolidated) |
353
- |-------------------|----------------------|
354
- | `search_semantic(query="auth")` | `search(mode="semantic", query="auth")` |
355
- | `session_capture(...)` | `session(action="capture", ...)` |
356
- | `graph_dependencies(...)` | `graph(action="dependencies", ...)` |
357
-
358
- If you rely on granular tool names, you can temporarily set:
359
-
360
- ```bash
361
- CONTEXTSTREAM_CONSOLIDATED=false
362
- ```
363
-
364
- ---
365
-
366
- ## Troubleshooting
367
-
368
- | Issue | Solution |
369
- |-------|----------|
370
- | **Tools not appearing** | Restart the client after editing MCP config; confirm Node 18+ is available in the client runtime |
371
- | **Unauthorized / 401** | Verify `CONTEXTSTREAM_API_URL` + `CONTEXTSTREAM_API_KEY` (or JWT) |
372
- | **Wrong workspace/project** | Run `session_init` and/or associate your folder with the correct workspace |
373
- | **Client warns about tool context size** | Use Router mode (`CONTEXTSTREAM_PROGRESSIVE_MODE=true`), or keep consolidated mode and reduce schema/output verbosity |
374
-
375
- ---
376
-
377
- ## Development
378
-
379
- ```bash
380
- git clone https://github.com/contextstream/mcp-server.git
381
- cd mcp-server
382
- npm install
383
- npm run dev
384
- npm run typecheck
385
- npm run build
386
- ```
387
-
388
- ---
389
-
390
- ## Links
391
-
392
- | Resource | URL |
393
- |----------|-----|
394
- | **Website** | https://contextstream.io |
395
- | **Docs** | https://contextstream.io/docs/mcp |
396
- | **Tool Catalog** | https://contextstream.io/docs/mcp/tools |
397
- | **Pricing** | https://contextstream.io/pricing |
398
- | **npm** | https://www.npmjs.com/package/@contextstream/mcp-server |
399
- | **GitHub** | https://github.com/contextstream/mcp-server |
400
-
401
- ---
402
-
403
- ## License
404
-
405
- MIT
337
+
338
+ ### Optional Defaults
339
+
340
+ | Variable | Description |
341
+ |----------|-------------|
342
+ | `CONTEXTSTREAM_WORKSPACE_ID` | Default workspace fallback |
343
+ | `CONTEXTSTREAM_PROJECT_ID` | Default project ID fallback |
344
+ | `CONTEXTSTREAM_USER_AGENT` | Custom user agent string |
345
+ | `CONTEXTSTREAM_PRO_TOOLS` | Comma-separated tool names treated as PRO |
346
+ | `CONTEXTSTREAM_UPGRADE_URL` | Upgrade link for Free users calling PRO tools |
347
+
348
+ ---
349
+
350
+ ## Migration Notes (pre-0.4.x → 0.4.x)
351
+
352
+ Most workflows **just work**, but tool names change in consolidated mode.
353
+
354
+ | Before (granular) | After (consolidated) |
355
+ |-------------------|----------------------|
356
+ | `search_semantic(query="auth")` | `search(mode="semantic", query="auth")` |
357
+ | `session_capture(...)` | `session(action="capture", ...)` |
358
+ | `graph_dependencies(...)` | `graph(action="dependencies", ...)` |
359
+
360
+ If you rely on granular tool names, you can temporarily set:
361
+
362
+ ```bash
363
+ CONTEXTSTREAM_CONSOLIDATED=false
364
+ ```
365
+
366
+ ---
367
+
368
+ ## Troubleshooting
369
+
370
+ | Issue | Solution |
371
+ |-------|----------|
372
+ | **Tools not appearing** | Restart the client after editing MCP config; confirm Node 18+ is available in the client runtime |
373
+ | **Unauthorized / 401** | Verify `CONTEXTSTREAM_API_URL` + `CONTEXTSTREAM_API_KEY` (or JWT) |
374
+ | **Wrong workspace/project** | Run `session_init` and/or associate your folder with the correct workspace |
375
+ | **Client warns about tool context size** | Use Router mode (`CONTEXTSTREAM_PROGRESSIVE_MODE=true`), or keep consolidated mode and reduce schema/output verbosity |
376
+
377
+ ---
378
+
379
+ ## Development
380
+
381
+ ```bash
382
+ git clone https://github.com/contextstream/mcp-server.git
383
+ cd mcp-server
384
+ npm install
385
+ npm run dev
386
+ npm run typecheck
387
+ npm run build
388
+ ```
389
+
390
+ ---
391
+
392
+ ## Links
393
+
394
+ | Resource | URL |
395
+ |----------|-----|
396
+ | **Website** | https://contextstream.io |
397
+ | **Docs** | https://contextstream.io/docs/mcp |
398
+ | **Tool Catalog** | https://contextstream.io/docs/mcp/tools |
399
+ | **Pricing** | https://contextstream.io/pricing |
400
+ | **npm** | https://www.npmjs.com/package/@contextstream/mcp-server |
401
+ | **GitHub** | https://github.com/contextstream/mcp-server |
402
+
403
+ ---
404
+
405
+ ## License
406
+
407
+ MIT
package/dist/index.js CHANGED
@@ -4905,6 +4905,13 @@ function normalizeGraphTier(value) {
4905
4905
  }
4906
4906
  var AI_PLAN_TIMEOUT_MS = 5e4;
4907
4907
  var AI_PLAN_RETRIES = 0;
4908
+ var INGEST_BENEFITS = [
4909
+ "Enable semantic code search across your entire codebase",
4910
+ "Get AI-powered code understanding and context for your questions",
4911
+ "Unlock dependency analysis and impact assessment",
4912
+ "Allow the AI assistant to find relevant code without manual file navigation",
4913
+ "Build a searchable knowledge base of your codebase structure"
4914
+ ];
4908
4915
  var ContextStreamClient = class {
4909
4916
  constructor(config) {
4910
4917
  this.config = config;
@@ -5450,6 +5457,72 @@ var ContextStreamClient = class {
5450
5457
  uuidSchema.parse(projectId);
5451
5458
  return request(this.config, `/projects/${projectId}/index/status`, { method: "GET" });
5452
5459
  }
5460
+ /**
5461
+ * Check if project ingestion is recommended and return a recommendation.
5462
+ * This is used by session_init to inform the AI about the project's index status.
5463
+ *
5464
+ * @param projectId - Project UUID
5465
+ * @param folderPath - Optional folder path for generating the ingest command
5466
+ * @returns IngestRecommendation with status, reason, and benefits if recommended
5467
+ */
5468
+ async checkIngestRecommendation(projectId, folderPath) {
5469
+ try {
5470
+ const status = await this.projectIndexStatus(projectId);
5471
+ const data = status.data || status;
5472
+ const indexedFiles = data.indexed_files ?? 0;
5473
+ const lastUpdated = data.last_updated;
5474
+ const statusDetail = data.status_detail;
5475
+ const isStale = lastUpdated ? Date.now() - new Date(lastUpdated).getTime() > 24 * 60 * 60 * 1e3 : false;
5476
+ const isRecent = lastUpdated ? Date.now() - new Date(lastUpdated).getTime() < 60 * 60 * 1e3 : false;
5477
+ const ingestCommand = folderPath ? `project(action="ingest_local", path="${folderPath}")` : `project(action="ingest_local", path="<your_project_path>")`;
5478
+ if (indexedFiles === 0 || statusDetail === "no_files_indexed") {
5479
+ return {
5480
+ recommended: true,
5481
+ status: "not_indexed",
5482
+ indexed_files: 0,
5483
+ reason: "No files have been indexed yet. Ingesting your codebase will enable semantic search and AI-powered code understanding.",
5484
+ benefits: INGEST_BENEFITS,
5485
+ command: ingestCommand
5486
+ };
5487
+ }
5488
+ if (isStale) {
5489
+ return {
5490
+ recommended: true,
5491
+ status: "stale",
5492
+ indexed_files: indexedFiles,
5493
+ last_indexed: lastUpdated,
5494
+ reason: `Index is over 24 hours old (${indexedFiles} files). Re-ingesting will capture any recent changes.`,
5495
+ benefits: ["Capture recent code changes", "Update dependency analysis", "Improve search accuracy"],
5496
+ command: ingestCommand
5497
+ };
5498
+ }
5499
+ if (isRecent) {
5500
+ return {
5501
+ recommended: false,
5502
+ status: "recently_indexed",
5503
+ indexed_files: indexedFiles,
5504
+ last_indexed: lastUpdated,
5505
+ reason: `Project was recently indexed (${indexedFiles} files). No action needed.`
5506
+ };
5507
+ }
5508
+ return {
5509
+ recommended: false,
5510
+ status: "indexed",
5511
+ indexed_files: indexedFiles,
5512
+ last_indexed: lastUpdated,
5513
+ reason: `Project is indexed (${indexedFiles} files). Consider re-indexing if you've made significant changes.`
5514
+ };
5515
+ } catch (error) {
5516
+ const ingestCommand = folderPath ? `project(action="ingest_local", path="${folderPath}")` : `project(action="ingest_local", path="<your_project_path>")`;
5517
+ return {
5518
+ recommended: true,
5519
+ status: "not_indexed",
5520
+ reason: "Unable to determine index status. Ingesting will ensure your codebase is searchable.",
5521
+ benefits: INGEST_BENEFITS,
5522
+ command: ingestCommand
5523
+ };
5524
+ }
5525
+ }
5453
5526
  /**
5454
5527
  * Ingest files for indexing
5455
5528
  * This uploads files to the API for indexing
@@ -5784,20 +5857,45 @@ var ContextStreamClient = class {
5784
5857
  });
5785
5858
  }
5786
5859
  }
5787
- if (projectId && (params.auto_index === void 0 || params.auto_index === true)) {
5788
- context.indexing_status = "started";
5789
- const projectIdCopy = projectId;
5790
- const rootPathCopy = rootPath;
5791
- (async () => {
5860
+ if (projectId) {
5861
+ const autoIndex = params.auto_index === void 0 || params.auto_index === true;
5862
+ if (autoIndex) {
5863
+ context.indexing_status = "started";
5864
+ context.ingest_recommendation = {
5865
+ recommended: false,
5866
+ status: "auto_started",
5867
+ reason: "Background ingestion started automatically. Your codebase will be searchable shortly."
5868
+ };
5869
+ const projectIdCopy = projectId;
5870
+ const rootPathCopy = rootPath;
5871
+ (async () => {
5872
+ try {
5873
+ for await (const batch of readAllFilesInBatches(rootPathCopy, { batchSize: 50 })) {
5874
+ await this.ingestFiles(projectIdCopy, batch);
5875
+ }
5876
+ console.error(`[ContextStream] Background indexing completed for ${rootPathCopy}`);
5877
+ } catch (e) {
5878
+ console.error(`[ContextStream] Background indexing failed:`, e);
5879
+ }
5880
+ })();
5881
+ } else {
5792
5882
  try {
5793
- for await (const batch of readAllFilesInBatches(rootPathCopy, { batchSize: 50 })) {
5794
- await this.ingestFiles(projectIdCopy, batch);
5883
+ const recommendation = await this.checkIngestRecommendation(projectId, rootPath);
5884
+ context.ingest_recommendation = recommendation;
5885
+ if (recommendation.recommended) {
5886
+ console.error(`[ContextStream] Ingest recommended for ${rootPath}: ${recommendation.status}`);
5795
5887
  }
5796
- console.error(`[ContextStream] Background indexing completed for ${rootPathCopy}`);
5797
5888
  } catch (e) {
5798
- console.error(`[ContextStream] Background indexing failed:`, e);
5889
+ console.error(`[ContextStream] Failed to check ingest recommendation:`, e);
5890
+ context.ingest_recommendation = {
5891
+ recommended: true,
5892
+ status: "not_indexed",
5893
+ reason: "Unable to determine index status. Consider ingesting to enable code search.",
5894
+ benefits: INGEST_BENEFITS,
5895
+ command: `project(action="ingest_local", path="${rootPath}")`
5896
+ };
5799
5897
  }
5800
- })();
5898
+ }
5801
5899
  }
5802
5900
  } catch (e) {
5803
5901
  context.project_error = String(e);
@@ -5877,6 +5975,22 @@ var ContextStreamClient = class {
5877
5975
  await this._fetchSessionContextFallback(context, workspaceId, projectId, params);
5878
5976
  }
5879
5977
  }
5978
+ if (projectId && !context.ingest_recommendation) {
5979
+ try {
5980
+ const recommendation = await this.checkIngestRecommendation(projectId, rootPath);
5981
+ context.ingest_recommendation = recommendation;
5982
+ if (recommendation.recommended) {
5983
+ console.error(`[ContextStream] Ingest recommended for existing project ${projectId}: ${recommendation.status}`);
5984
+ }
5985
+ } catch (e) {
5986
+ console.error(`[ContextStream] Failed to check ingest recommendation for existing project:`, e);
5987
+ context.ingest_recommendation = {
5988
+ recommended: false,
5989
+ status: "indexed",
5990
+ reason: 'Unable to determine exact index status. Use project(action="index_status") to check.'
5991
+ };
5992
+ }
5993
+ }
5880
5994
  return context;
5881
5995
  }
5882
5996
  /**
@@ -6717,8 +6831,11 @@ var ContextStreamClient = class {
6717
6831
  let charsUsed = 0;
6718
6832
  const maxChars = maxTokens * 4;
6719
6833
  let candidateContext;
6834
+ const CS_FIRST_RULE = "\u26A0\uFE0F STOP: Before Glob/Grep/Read \u2192 search(mode=hybrid) FIRST. Local tools ONLY if 0 results.";
6835
+ const CS_FIRST_RULE_MINIFIED = "R:CS-first|Idx:project.index_status->ingest|NoLocalScanUnlessCSempty";
6720
6836
  if (format === "minified") {
6721
- const parts = [];
6837
+ const parts = [CS_FIRST_RULE_MINIFIED];
6838
+ charsUsed = CS_FIRST_RULE_MINIFIED.length + 1;
6722
6839
  for (const item of items) {
6723
6840
  const entry = `${item.type}:${item.value}`;
6724
6841
  if (charsUsed + entry.length + 1 > maxChars) break;
@@ -6726,9 +6843,10 @@ var ContextStreamClient = class {
6726
6843
  charsUsed += entry.length + 1;
6727
6844
  }
6728
6845
  context = parts.join("|");
6729
- candidateContext = items.map((i) => `${i.type}:${i.value}`).join("|");
6846
+ candidateContext = [CS_FIRST_RULE_MINIFIED, ...items.map((i) => `${i.type}:${i.value}`)].join("|");
6730
6847
  } else if (format === "structured") {
6731
- const grouped = {};
6848
+ const grouped = { R: [CS_FIRST_RULE] };
6849
+ charsUsed = CS_FIRST_RULE.length + 10;
6732
6850
  for (const item of items) {
6733
6851
  if (charsUsed > maxChars) break;
6734
6852
  if (!grouped[item.type]) grouped[item.type] = [];
@@ -6736,14 +6854,15 @@ var ContextStreamClient = class {
6736
6854
  charsUsed += item.value.length + 5;
6737
6855
  }
6738
6856
  context = JSON.stringify(grouped);
6739
- const candidateGrouped = {};
6857
+ const candidateGrouped = { R: [CS_FIRST_RULE] };
6740
6858
  for (const item of items) {
6741
6859
  if (!candidateGrouped[item.type]) candidateGrouped[item.type] = [];
6742
6860
  candidateGrouped[item.type].push(item.value);
6743
6861
  }
6744
6862
  candidateContext = JSON.stringify(candidateGrouped);
6745
6863
  } else {
6746
- const lines = ["[CTX]"];
6864
+ const lines = [CS_FIRST_RULE, "", "[CTX]"];
6865
+ charsUsed = CS_FIRST_RULE.length + 10;
6747
6866
  for (const item of items) {
6748
6867
  const line = `${item.type}:${item.value}`;
6749
6868
  if (charsUsed + line.length + 1 > maxChars) break;
@@ -6752,7 +6871,7 @@ var ContextStreamClient = class {
6752
6871
  }
6753
6872
  lines.push("[/CTX]");
6754
6873
  context = lines.join("\n");
6755
- const candidateLines = ["[CTX]"];
6874
+ const candidateLines = [CS_FIRST_RULE, "", "[CTX]"];
6756
6875
  for (const item of items) {
6757
6876
  candidateLines.push(`${item.type}:${item.value}`);
6758
6877
  }
@@ -6761,7 +6880,9 @@ var ContextStreamClient = class {
6761
6880
  }
6762
6881
  if (context.length === 0 && withDefaults.workspace_id) {
6763
6882
  const wsHint = items.find((i) => i.type === "W")?.value || withDefaults.workspace_id;
6764
- context = format === "minified" ? `W:${wsHint}|[NO_MATCHES]` : `[CTX]
6883
+ context = format === "minified" ? `${CS_FIRST_RULE_MINIFIED}|W:${wsHint}|[NO_MATCHES]` : `${CS_FIRST_RULE}
6884
+
6885
+ [CTX]
6765
6886
  W:${wsHint}
6766
6887
  [NO_MATCHES]
6767
6888
  [/CTX]`;
@@ -7619,16 +7740,18 @@ Only after this preflight, proceed with search/analysis below.
7619
7740
 
7620
7741
  ### Search & Code Intelligence (ContextStream-first)
7621
7742
 
7743
+ \u26A0\uFE0F **STOP: Before using Glob/Grep/Read/Explore** \u2192 Call \`search(mode="hybrid")\` FIRST. Use local tools ONLY if ContextStream returns 0 results.
7744
+
7622
7745
  **Search order:**
7623
7746
  1. \`session(action="smart_search", query="...")\` - context-enriched
7624
7747
  2. \`search(mode="hybrid", query="...", limit=3)\` or \`search(mode="keyword", query="<filename>", limit=3)\`
7625
7748
  3. \`project(action="files")\` - file tree/list (only when needed)
7626
7749
  4. \`graph(action="dependencies", ...)\` - code structure
7627
- 5. Local repo scans (rg/ls/find) - only if ContextStream returns no results, errors, or the user explicitly asks
7750
+ 5. Local repo scans (rg/ls/find) - ONLY if ContextStream returns no results, errors, or the user explicitly asks
7628
7751
 
7629
7752
  **Search defaults:** \`search\` returns the top 3 results with compact snippets. Use \`limit\` + \`offset\` for pagination, and \`content_max_chars\` to expand snippets when needed.
7630
7753
 
7631
- If ContextStream returns results, stop and use them. Do NOT use local Search/Explore/Read unless you need exact code edits.
7754
+ If ContextStream returns results, stop and use them. NEVER use local Search/Explore/Read unless you need exact code edits or ContextStream returned 0 results.
7632
7755
 
7633
7756
  **Code Analysis:**
7634
7757
  - Dependencies: \`graph(action="dependencies", file_path="...")\`
@@ -7739,10 +7862,13 @@ Rules Version: ${RULES_VERSION}
7739
7862
 
7740
7863
  ### Behavior Rules
7741
7864
 
7865
+ \u26A0\uFE0F **STOP: Before using Glob/Grep/Read/Explore** \u2192 Call \`search(mode="hybrid")\` FIRST. Use local tools ONLY if ContextStream returns 0 results.
7866
+
7742
7867
  - **First message**: Call \`session_init\` with context_hint, then call \`context_smart\` before any other tool or response
7868
+ - **On [INGEST_RECOMMENDED]**: Ask the user if they want to enable semantic code search. Explain: "Indexing your codebase enables AI-powered code search, dependency analysis, and better context. This takes a few minutes." If user agrees, run the provided \`project(action="ingest_local")\` command.
7743
7869
  - **Every message after**: Always call \`context_smart\` BEFORE responding (semantic search for relevant context)
7744
7870
  - **Before searching files/code**: Check \`project(action="index_status")\`; if missing/stale run \`project(action="ingest_local", path="<cwd>")\` or \`project(action="index")\`, and use \`graph(action="ingest")\` if needed
7745
- - **For discovery**: Use \`session(action="smart_search")\` or \`search(mode="hybrid")\` before any local repo scans
7871
+ - **For discovery**: Use \`session(action="smart_search")\` or \`search(mode="hybrid")\` \u2014 NEVER use local Glob/Grep/Read first
7746
7872
  - **For file/function/config lookups**: Use \`search\`/\`graph\` first; only fall back to rg/ls/find if ContextStream returns no results
7747
7873
  - **If ContextStream returns results**: Do NOT use local Search/Explore/Read; only open specific files when needed for exact edits
7748
7874
  - **For code analysis**: Use \`graph(action="dependencies")\` or \`graph(action="impact")\` for call/dependency analysis
@@ -9743,6 +9869,9 @@ Access: ${accessLabel}${showUpgrade ? ` (upgrade: ${upgradeUrl2})` : ""}`;
9743
9869
  const isPlanLimit = String(errorCode).toUpperCase() === "FORBIDDEN" && String(errorMessage).toLowerCase().includes("plan limit reached");
9744
9870
  const upgradeHint = isPlanLimit ? `
9745
9871
  Upgrade: ${upgradeUrl2}` : "";
9872
+ const isUnauthorized = String(errorCode).toUpperCase() === "UNAUTHORIZED";
9873
+ const sessionHint = isUnauthorized ? `
9874
+ Hint: Run session_init(folder_path="<your_project_path>") first to establish a session, or check that your API key is valid.` : "";
9746
9875
  const errorPayload = {
9747
9876
  success: false,
9748
9877
  error: {
@@ -9751,7 +9880,7 @@ Upgrade: ${upgradeUrl2}` : "";
9751
9880
  details: errorDetails
9752
9881
  }
9753
9882
  };
9754
- const errorText = `[${errorCode}] ${errorMessage}${upgradeHint}${errorDetails ? `: ${JSON.stringify(errorDetails)}` : ""}`;
9883
+ const errorText = `[${errorCode}] ${errorMessage}${upgradeHint}${sessionHint}${errorDetails ? `: ${JSON.stringify(errorDetails)}` : ""}`;
9755
9884
  return {
9756
9885
  content: [{ type: "text", text: errorText }],
9757
9886
  structuredContent: errorPayload,
@@ -11172,8 +11301,12 @@ Runs in the background and returns immediately; use 'projects_index_status' to m
11172
11301
  title: "Initialize conversation session",
11173
11302
  description: `Initialize a new conversation session and automatically retrieve relevant context.
11174
11303
  This is the FIRST tool AI assistants should call when starting a conversation.
11175
- Returns: workspace info, project info, recent memory, recent decisions, relevant context, and high-priority lessons.
11176
- Automatically detects the IDE workspace/project path and can auto-index code.
11304
+ Returns: workspace info, project info, recent memory, recent decisions, relevant context, high-priority lessons, and ingest_recommendation.
11305
+
11306
+ The ingest_recommendation field indicates if the project needs indexing for code search:
11307
+ - If [INGEST_RECOMMENDED] appears, ask the user if they want to enable semantic code search
11308
+ - Benefits: AI-powered code understanding, dependency analysis, better context retrieval
11309
+ - If user agrees, run: project(action="ingest_local", path="<project_path>")
11177
11310
 
11178
11311
  IMPORTANT: Pass the user's FIRST MESSAGE as context_hint to get semantically relevant context!
11179
11312
  Example: session_init(folder_path="/path/to/project", context_hint="how do I implement auth?")
@@ -11306,10 +11439,24 @@ This does semantic search on the first message. You only need context_smart on s
11306
11439
  if (versionNotice?.behind) {
11307
11440
  noticeLines.push(`[VERSION_NOTICE] current=${versionNotice.current} latest=${versionNotice.latest} upgrade="${versionNotice.upgrade_command}"`);
11308
11441
  }
11442
+ const ingestRec = result.ingest_recommendation;
11443
+ if (ingestRec?.recommended) {
11444
+ const benefitsList = ingestRec.benefits?.slice(0, 3).map((b) => ` \u2022 ${b}`).join("\n") || "";
11445
+ noticeLines.push(
11446
+ `[INGEST_RECOMMENDED] status=${ingestRec.status}`,
11447
+ `Reason: ${ingestRec.reason}`,
11448
+ ingestRec.benefits ? `Benefits:
11449
+ ${benefitsList}` : "",
11450
+ `Action: Ask the user if they want to enable code search by running:`,
11451
+ ` ${ingestRec.command || 'project(action="ingest_local", path="<project_path>")'}`
11452
+ );
11453
+ } else if (ingestRec?.status === "auto_started") {
11454
+ noticeLines.push(`[INGEST_STATUS] Background indexing started. Codebase will be searchable shortly.`);
11455
+ }
11309
11456
  if (noticeLines.length > 0) {
11310
11457
  text = `${text}
11311
11458
 
11312
- ${noticeLines.join("\n")}`;
11459
+ ${noticeLines.filter(Boolean).join("\n")}`;
11313
11460
  }
11314
11461
  return { content: [{ type: "text", text }], structuredContent: toStructured(result) };
11315
11462
  }
package/package.json CHANGED
@@ -1,57 +1,57 @@
1
- {
2
- "name": "@contextstream/mcp-server",
3
- "mcpName": "io.github.contextstreamio/mcp-server",
4
- "version": "0.4.22",
5
- "description": "ContextStream MCP server - v0.4.x with consolidated domain tools (~11 tools, ~75% token reduction). Code context, memory, search, and AI tools.",
6
- "type": "module",
7
- "license": "MIT",
8
- "main": "dist/index.js",
9
- "files": [
10
- "dist",
11
- "README.md"
12
- ],
13
- "bin": {
14
- "contextstream-mcp": "dist/index.js"
15
- },
16
- "scripts": {
17
- "dev": "tsx src/index.ts",
18
- "build": "esbuild src/index.ts --bundle --platform=node --target=node18 --outfile=dist/index.js --format=esm --external:@modelcontextprotocol/sdk --banner:js=\"#!/usr/bin/env node\" && esbuild src/test-server.ts --bundle --platform=node --target=node18 --outfile=dist/test-server.js --format=esm --external:@modelcontextprotocol/sdk",
19
- "start": "node dist/index.js",
20
- "test-server": "tsx src/test-server.ts",
21
- "test-server:start": "node dist/test-server.js",
22
- "typecheck": "tsc --noEmit"
23
- },
24
- "dependencies": {
25
- "@modelcontextprotocol/sdk": "^1.25.1",
26
- "zod": "^3.23.8"
27
- },
28
- "devDependencies": {
29
- "@types/node": "^20.10.0",
30
- "esbuild": "^0.27.0",
31
- "tsx": "^4.15.4",
32
- "typescript": "^5.6.3"
33
- },
34
- "engines": {
35
- "node": ">=18"
36
- },
37
- "keywords": [
38
- "mcp",
39
- "model-context-protocol",
40
- "contextstream",
41
- "ai",
42
- "code-context",
43
- "memory",
44
- "knowledge-graph"
45
- ],
46
- "repository": {
47
- "type": "git",
48
- "url": "git+https://github.com/contextstream/mcp-server.git"
49
- },
50
- "homepage": "https://contextstream.io/docs/mcp",
51
- "bugs": {
52
- "url": "https://github.com/contextstream/mcp-server/issues"
53
- },
54
- "overrides": {
55
- "qs": "6.14.1"
56
- }
57
- }
1
+ {
2
+ "name": "@contextstream/mcp-server",
3
+ "mcpName": "io.github.contextstreamio/mcp-server",
4
+ "version": "0.4.23",
5
+ "description": "ContextStream MCP server - v0.4.x with consolidated domain tools (~11 tools, ~75% token reduction). Code context, memory, search, and AI tools.",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "main": "dist/index.js",
9
+ "files": [
10
+ "dist",
11
+ "README.md"
12
+ ],
13
+ "bin": {
14
+ "contextstream-mcp": "dist/index.js"
15
+ },
16
+ "scripts": {
17
+ "dev": "tsx src/index.ts",
18
+ "build": "esbuild src/index.ts --bundle --platform=node --target=node18 --outfile=dist/index.js --format=esm --external:@modelcontextprotocol/sdk --banner:js=\"#!/usr/bin/env node\" && esbuild src/test-server.ts --bundle --platform=node --target=node18 --outfile=dist/test-server.js --format=esm --external:@modelcontextprotocol/sdk",
19
+ "start": "node dist/index.js",
20
+ "test-server": "tsx src/test-server.ts",
21
+ "test-server:start": "node dist/test-server.js",
22
+ "typecheck": "tsc --noEmit"
23
+ },
24
+ "dependencies": {
25
+ "@modelcontextprotocol/sdk": "^1.25.1",
26
+ "zod": "^3.23.8"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^20.10.0",
30
+ "esbuild": "^0.27.0",
31
+ "tsx": "^4.15.4",
32
+ "typescript": "^5.6.3"
33
+ },
34
+ "engines": {
35
+ "node": ">=18"
36
+ },
37
+ "keywords": [
38
+ "mcp",
39
+ "model-context-protocol",
40
+ "contextstream",
41
+ "ai",
42
+ "code-context",
43
+ "memory",
44
+ "knowledge-graph"
45
+ ],
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/contextstream/mcp-server.git"
49
+ },
50
+ "homepage": "https://contextstream.io/docs/mcp",
51
+ "bugs": {
52
+ "url": "https://github.com/contextstream/mcp-server/issues"
53
+ },
54
+ "overrides": {
55
+ "qs": "6.14.1"
56
+ }
57
+ }