@contextstream/mcp-server 0.3.20 → 0.3.22

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 (3) hide show
  1. package/README.md +79 -334
  2. package/dist/index.js +738 -524
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,95 +1,43 @@
1
1
  # ContextStream MCP Server
2
2
 
3
- [![npm version](https://badge.fury.io/js/@contextstream%2Fmcp-server.svg)](https://www.npmjs.com/package/@contextstream/mcp-server)
4
- [![GitHub](https://img.shields.io/github/license/contextstream/mcp-server)](https://github.com/contextstream/mcp-server)
5
- [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-purple)](https://modelcontextprotocol.io)
3
+ Persistent memory, semantic search, and code intelligence for any MCP-compatible AI tool.
6
4
 
7
- > **Persistent memory + semantic search + dependency/impact analysis for Cursor, Claude Code, Windsurf, VS Code, Codex CLI, and any MCP client.**
5
+ ContextStream is a shared “brain” for your AI workflows. It stores decisions, preferences, and lessons, and lets your AI tools search and analyze your codebase with consistent context across sessions.
8
6
 
9
- <div align="center">
7
+ ## Features
10
8
 
11
- ## 🧠 Your AI Finally Remembers
9
+ - Session-aware context loading (`session_init`, `context_smart`)
10
+ - Memory capture and recall (decisions, preferences, tasks, bugs, lessons)
11
+ - Code search (semantic, hybrid, keyword, pattern)
12
+ - Knowledge graph and code analysis (dependencies, impact, call paths, circular deps, unused code)
13
+ - Local repo ingestion for indexing (`projects_ingest_local`)
14
+ - Auto-context: on the first tool call in a new session, the server can auto-initialize context
12
15
 
13
- **The universal memory layer for AI coding tools.**
16
+ ## Requirements
14
17
 
15
- One integration. Every AI editor. Persistent memory that never forgets.
18
+ - Node.js 18+
19
+ - A ContextStream account and either an API key or a JWT
16
20
 
17
- [Get Started](https://contextstream.io) · [Documentation](https://contextstream.io/docs/mcp) · [npm Package](https://www.npmjs.com/package/@contextstream/mcp-server)
21
+ ## Quickstart
18
22
 
19
- </div>
23
+ Run directly (recommended for MCP configs):
20
24
 
21
- > ⭐ **If this saves you time, please star the repo — it helps others find it!**
22
-
23
- <div align="center">
24
-
25
- <a href="https://contextstream.io">
26
- <img src="https://raw.githubusercontent.com/contextstream/mcp-server/main/mcp.gif.gif" alt="ContextStream Demo - AI that remembers across sessions" width="600" />
27
- </a>
28
-
29
- <sub>Your AI remembers decisions, preferences, and context — across sessions and tools.</sub>
30
-
31
- </div>
32
-
33
- ---
34
-
35
- ## The Real Cost of AI Amnesia
36
-
37
- Every developer using AI tools has felt this frustration:
38
-
39
- **Monday morning.** You've spent 3 hours with Claude explaining your authentication architecture, the edge cases, why you chose JWT over sessions, the rate limiting strategy. The AI finally *gets it*. You ship great code together.
40
-
41
- **Monday afternoon.** New chat window. The AI has no idea what JWT is in your context. It suggests sessions. You explain everything again.
42
-
43
- **Tuesday.** You switch to Cursor for a quick refactor. Start from zero. "We use TypeScript with strict mode." "Our API follows REST conventions." "The user service is in `/src/services`." Again.
44
-
45
- **A week later.** "Why did we build it this way?" Nobody remembers. The decision rationale is buried in a closed Slack thread. The AI certainly doesn't know.
46
-
47
- **A month later.** New team member joins. Days of onboarding conversations. Explaining the same architectural decisions. Documenting tribal knowledge that should already exist.
48
-
49
- **This isn't a minor inconvenience. It's death by a thousand cuts.**
50
-
51
- Every re-explanation is lost productivity. Every forgotten decision is technical debt. Every context switch is cognitive load. Every new teammate is weeks of redundant knowledge transfer.
52
-
53
- Your AI is brilliant for 30 minutes at a time—then it's a goldfish.
54
-
55
- ---
56
-
57
- ## What If Your AI Actually Learned?
58
-
59
- **ContextStream gives your AI a permanent brain.**
60
-
61
- ```
62
- You: "Initialize session. Remember: we use PostgreSQL, TypeScript strict mode,
63
- and JWT for auth. Rate limits are 100 req/min per user."
64
-
65
- ...3 weeks later, different tool, new conversation...
66
-
67
- You: "What database do we use?"
68
- AI: "You're using PostgreSQL. You also prefer TypeScript with strict mode
69
- and JWT authentication with 100 req/min rate limiting per user."
25
+ ```bash
26
+ npx -y @contextstream/mcp-server
70
27
  ```
71
28
 
72
- It remembers. **Across sessions. Across tools. Forever.**
29
+ Or install globally:
73
30
 
74
- Not just facts—**decisions, context, and reasoning**:
75
-
76
- ```
77
- You: "Why did we choose PostgreSQL over MongoDB?"
78
- AI: "Based on your captured decision from March 15th: 'Chose PostgreSQL for
79
- ACID compliance and complex joins in the reporting module. MongoDB
80
- considered but rejected due to transaction requirements.'"
31
+ ```bash
32
+ npm install -g @contextstream/mcp-server
33
+ contextstream-mcp
81
34
  ```
82
35
 
83
- ---
84
-
85
- ## 🚀 2-Minute Setup
36
+ ## Configure your MCP client
86
37
 
87
- ### 1. Get Your API Key
88
- Sign up at [contextstream.io](https://contextstream.io) → Settings → API Keys → Create
38
+ ### Cursor / VS Code / Windsurf / Claude Desktop (JSON)
89
39
 
90
- ### 2. Add to Your MCP Config
91
-
92
- **Claude Code / Cursor / Windsurf / VS Code:**
40
+ Add to your MCP config:
93
41
 
94
42
  ```json
95
43
  {
@@ -106,7 +54,8 @@ Sign up at [contextstream.io](https://contextstream.io) → Settings → API Key
106
54
  }
107
55
  ```
108
56
 
109
- **Codex CLI** (`~/.codex/config.toml`):
57
+ ### Codex CLI (`~/.codex/config.toml`)
58
+
110
59
  ```toml
111
60
  [mcp_servers.contextstream]
112
61
  command = "npx"
@@ -117,296 +66,92 @@ CONTEXTSTREAM_API_URL = "https://api.contextstream.io"
117
66
  CONTEXTSTREAM_API_KEY = "your_api_key"
118
67
  ```
119
68
 
120
- > Codex expects snake_case `mcp_servers` keys. After editing, fully restart Codex.
121
-
122
- > For workspace-pooled rate limiting (Team/Enterprise), the MCP server sends `X-Workspace-Id` based on the active repo/session (or explicit `workspace_id` in tool calls). You can optionally set `CONTEXTSTREAM_WORKSPACE_ID` as a fallback default, but it’s not required and isn’t a good fit if you frequently switch workspaces.
123
-
124
- ### AI Rules Files (Recommended)
125
-
126
- Adding rules files ensures your AI automatically uses ContextStream for memory on every conversation.
127
-
128
- > ⚠️ **Critical: Tool Naming Convention**
129
- >
130
- > | AI Tool | Tool Name Format | Example |
131
- > |---------|-----------------|---------|
132
- > | **Claude Code** | `mcp__<server>__<tool>` | `mcp__contextstream__session_init` |
133
- > | **All Others** (Codex, Cursor, Windsurf, Cline, etc.) | `<tool>` (raw) | `session_init` |
134
-
135
- **For Claude Code** — Create `CLAUDE.md` in your project root:
136
- ```markdown
137
- ## ContextStream Integration
138
-
139
- | Message | What to Call |
140
- |---------|--------------|
141
- | **1st message** | `mcp__contextstream__session_init(folder_path="...", context_hint="<user's message>")` |
142
- | **2nd+ messages** | `mcp__contextstream__context_smart(user_message="<user's message>")` |
143
- | **After tasks** | `mcp__contextstream__session_capture(...)` |
144
-
145
- **NO EXCEPTIONS.** Call these tools before responding.
146
- ```
147
-
148
- **For Codex CLI** — Create `AGENTS.md` in `~/.codex/` (global) or project root:
149
- ```markdown
150
- ## ContextStream Integration
151
-
152
- | Message | What to Call |
153
- |---------|--------------|
154
- | **1st message** | `session_init(folder_path="...", context_hint="<user's message>")` |
155
- | **2nd+ messages** | `context_smart(user_message="<user's message>")` |
156
- | **After tasks** | `session_capture(...)` |
157
-
158
- **NO EXCEPTIONS.** Call these tools before responding.
159
- ```
160
-
161
- **For other editors** — See [full templates in the docs](https://contextstream.io/docs/mcp).
162
-
163
- ### 3. Experience Memory
164
-
165
- ```
166
- You: "Initialize session and remember I prefer functional React components"
167
- ```
168
-
169
- Open a **new conversation** (even in a different tool):
170
-
171
- ```
172
- You: "What's my React preference?"
173
- AI: "You prefer functional React components."
174
- ```
175
-
176
- ✨ **That's it. Your AI remembers now.**
177
-
178
- ### 4. (Optional) Connect GitHub + Slack for richer context
179
-
180
- MCP gives your AI memory. Integrations make that memory richer by pulling in PRs, issues, and team conversations.
181
-
182
- - GitHub App setup + connect flow: https://contextstream.io/docs/integrations/github
183
- - Slack app setup + connect flow: https://contextstream.io/docs/integrations/slack
184
-
185
- After you connect, try prompts like:
186
- ```
187
- "Search our Slack messages for the decision about rate limiting."
188
- "What did we decide in GitHub issues about the auth flow?"
189
- ```
190
-
191
- ---
192
-
193
- ## Beyond Memory: Intelligence That Compounds
194
-
195
- Memory is just the foundation. ContextStream understands your codebase at a deeper level.
196
-
197
- ### 🔴 Lessons Learned — Never Repeat Mistakes
198
-
199
- When your AI makes a mistake—wrong approach, broken build, production issue—capture it as a lesson:
200
-
201
- ```
202
- You: "Capture lesson: Always run tests before pushing to main"
203
- ```
204
-
205
- **These lessons surface automatically in future sessions.** Before the AI takes a similar action, it sees the warning. Your AI learns from mistakes just like you do.
206
-
207
- | Trigger | Example |
208
- |---------|---------|
209
- | User correction | "No, we use PostgreSQL not MySQL" |
210
- | Production issue | "That deploy broke the API" |
211
- | Workflow mistake | "You forgot to run the linter" |
212
-
213
- Lessons are categorized by severity (`critical`, `high`, `medium`, `low`) and automatically retrieved when relevant context is detected.
214
-
215
- ### 📊 Impact Analysis
216
-
217
- ```
218
- You: "What breaks if I change the UserService class?"
219
- ```
220
-
221
- See all dependencies and side effects **before** you refactor. No more surprise breakages.
222
-
223
- ### 🔍 Semantic Code Search
224
-
225
- ```
226
- You: "Find where we handle authentication errors"
227
- ```
228
-
229
- Search by **meaning**, not keywords. Find code by what it does, not what it's named.
230
-
231
- ### 🧬 Knowledge Graph
232
-
233
- Decisions, code, and documentation—all connected. Ask "why" and get answers with full context.
234
-
235
- ### 🤖 Auto-Context Loading
236
-
237
- Context loads **automatically** on first interaction. No manual setup:
238
-
239
- ```
240
- ═══════════════════════════════════════════
241
- 🧠 AUTO-CONTEXT LOADED (ContextStream)
242
- ═══════════════════════════════════════════
243
- 📁 Workspace: acme-corp
244
- 📂 Project: backend-api
245
-
246
- 📋 Recent Decisions:
247
- • Use PostgreSQL for persistence
248
- • JWT for authentication
249
-
250
- ⚠️ Active Lessons:
251
- • Always run tests before pushing
252
-
253
- 🧠 Recent Context:
254
- • [decision] API rate limiting strategy
255
- • [preference] TypeScript strict mode
256
- ═══════════════════════════════════════════
257
- ```
258
-
259
- ---
260
-
261
- ## 71 MCP Tools
262
-
263
- ### Session & Memory
264
- | Tool | What It Does |
265
- |------|--------------|
266
- | `session_init` | Initialize with auto-context loading |
267
- | `context_smart` | Get relevant context for any message |
268
- | `session_remember` | Natural language: "Remember X" |
269
- | `session_recall` | Natural language: "What did we decide about X?" |
270
- | `session_capture` | Store decisions, insights, preferences |
271
- | `session_capture_lesson` | **Capture mistakes to prevent repeating them** |
272
- | `session_get_lessons` | Retrieve relevant lessons |
273
-
274
- ### Code Intelligence
275
- | Tool | What It Does |
276
- |------|--------------|
277
- | `search_semantic` | Find code by meaning |
278
- | `search_hybrid` | Semantic + keyword combined |
279
- | `graph_dependencies` | See what depends on what |
280
- | `graph_impact` | Understand change impact |
281
- | `graph_call_path` | Trace execution flows |
282
- | `graph_unused_code` | Find dead code |
283
-
284
- ### AI Integration
285
- | Tool | What It Does |
286
- |------|--------------|
287
- | `ai_context` | Build LLM-ready context |
288
- | `ai_context_budget` | Context within token limits |
289
- | `ai_plan` | Generate development plans |
290
- | `ai_tasks` | Break work into tasks |
69
+ After editing, restart your MCP client so it reloads the server configuration.
291
70
 
292
- [**View all 71 tools →**](https://contextstream.io/docs/mcp)
71
+ ## Authentication
293
72
 
294
- ---
73
+ You can authenticate using either:
295
74
 
296
- ## Why Not Built-in Memory?
75
+ - `CONTEXTSTREAM_API_KEY` (recommended for local/dev)
76
+ - `CONTEXTSTREAM_JWT` (useful for hosted or user-session flows)
297
77
 
298
- | Built-in "Memory" | ContextStream |
299
- |-------------------|---------------|
300
- | 🔒 Locked to one vendor | 🌐 **Universal** — works with Cursor, Claude, Windsurf, any MCP client |
301
- | ⏱️ Expires or resets | ♾️ **Persistent** — never lose context |
302
- | 📝 Basic key-value | 🧠 **Semantic** — understands meaning and relationships |
303
- | 👤 Personal only | 👥 **Team-ready** — shared workspace, instant onboarding |
304
- | ❌ No lessons | ✅ **Learns from mistakes** — captures and surfaces lessons |
305
- | ❌ No code understanding | 🔍 **Deep analysis** — dependencies, impact, knowledge graph |
306
- | 🤷 Hope it remembers | 🎯 **Deterministic** — you control what's stored |
78
+ ## Environment variables
307
79
 
308
- ---
309
-
310
- ## Privacy & Security
311
-
312
- - **🔐 Encrypted at rest** AES-256 encryption for all stored data
313
- - **🚫 Never trains on your data** Your code is yours. Period.
314
- - **🎛️ You control access** Workspace permissions, API key management
315
- - **🗑️ Delete anytime** Full data deletion on request
316
-
317
- ---
318
-
319
- ## Works Everywhere
320
-
321
- ContextStream uses the [Model Context Protocol](https://modelcontextprotocol.io)—the emerging standard for AI tool integrations.
322
-
323
- **Supported today:**
324
- - Claude Code
325
- - Cursor
326
- - Windsurf
327
- - VS Code (with MCP extension)
328
- - Codex CLI
329
- - Cline
330
- - Kilo Code
331
- - Roo Code
332
- - Any MCP-compatible client
80
+ | Variable | Required | Description |
81
+ |----------|----------|-------------|
82
+ | `CONTEXTSTREAM_API_URL` | Yes | Base API URL (e.g. `https://api.contextstream.io`) |
83
+ | `CONTEXTSTREAM_API_KEY` | Yes* | API key (*required unless `CONTEXTSTREAM_JWT` is set) |
84
+ | `CONTEXTSTREAM_JWT` | Yes* | JWT (*required unless `CONTEXTSTREAM_API_KEY` is set) |
85
+ | `CONTEXTSTREAM_WORKSPACE_ID` | No | Default workspace ID fallback |
86
+ | `CONTEXTSTREAM_PROJECT_ID` | No | Default project ID fallback |
87
+ | `CONTEXTSTREAM_USER_AGENT` | No | Custom user agent string |
88
+ | `CONTEXTSTREAM_PRO_TOOLS` | No | Comma-separated tool names treated as PRO (default: `ai_context,ai_enhanced_context,ai_context_budget,ai_embeddings,ai_plan,ai_tasks`) |
89
+ | `CONTEXTSTREAM_UPGRADE_URL` | No | Upgrade link shown when Free users call PRO tools (default: `https://contextstream.io/pricing`) |
333
90
 
334
- **One integration. Every tool. Same memory.**
91
+ ## Usage patterns
335
92
 
336
- ---
93
+ ### Recommended flow for AI tools
337
94
 
338
- ## Quick Reference
95
+ 1. Start of a conversation: call `session_init(folder_path="...", context_hint="<first user message>")`
96
+ 2. Before subsequent responses: call `context_smart(user_message="<current user message>")`
97
+ 3. After important outcomes: call `session_capture(...)` or `session_capture_lesson(...)`
339
98
 
340
- ### Environment Variables
99
+ ### Omit workspace/project IDs (recommended)
341
100
 
342
- | Variable | Required | Description |
343
- |----------|----------|-------------|
344
- | `CONTEXTSTREAM_API_URL` | Yes | `https://api.contextstream.io` |
345
- | `CONTEXTSTREAM_API_KEY` | Yes | Your API key |
101
+ Most tools accept omitted `workspace_id` / `project_id` and will use the current session defaults.
346
102
 
347
- ### Essential Commands
103
+ - If you see “workspace_id is required”, call `session_init` first (or pass the ID explicitly).
104
+ - If you regularly work in the same repo, use `workspace_associate` once so the server can auto-select the right workspace for that folder.
348
105
 
349
- ```bash
350
- # Install globally
351
- npm install -g @contextstream/mcp-server
106
+ ### First-time setup (no workspaces yet)
352
107
 
353
- # Or run via npx (recommended for MCP configs)
354
- npx @contextstream/mcp-server
355
- ```
108
+ If your account has no workspaces, ContextStream will prompt your AI assistant to ask you for a workspace name.
356
109
 
357
- ### First Session Checklist
110
+ - Provide a workspace name (e.g., your company/team/product)
111
+ - The current folder is created as a project inside that workspace
112
+ - Recommended: call `workspace_bootstrap(workspace_name="...", folder_path="...")`
358
113
 
359
- 1. Add MCP config to your editor
360
- 2. ✅ Start a conversation: "Initialize session for [project-name]"
361
- 3. ✅ Tell it your preferences: "Remember we use TypeScript strict mode"
362
- 4. ✅ Make a decision: "Capture decision: Using PostgreSQL for the user database"
363
- 5. ✅ Open a new conversation and ask: "What are my preferences?"
114
+ ### Slash commands (prompts)
364
115
 
365
- ---
116
+ Most MCP clients expose ContextStream prompts as `/contextstream:...` slash commands.
366
117
 
367
- ## Links
118
+ - Prompts are parameter-free: selecting a command should immediately insert the template.
119
+ - Templates avoid asking for workspace/project IDs and instead rely on `session_init` + session defaults.
368
120
 
369
- | Resource | URL |
370
- |----------|-----|
371
- | Website | [contextstream.io](https://contextstream.io) |
372
- | Documentation | [contextstream.io/docs](https://contextstream.io/docs) |
373
- | MCP Setup Guide | [contextstream.io/docs/mcp](https://contextstream.io/docs/mcp) |
374
- | npm Package | [@contextstream/mcp-server](https://www.npmjs.com/package/@contextstream/mcp-server) |
375
- | GitHub | [contextstream/mcp-server](https://github.com/contextstream/mcp-server) |
121
+ ## Free vs PRO tools
376
122
 
377
- ---
123
+ Tools are labeled as `(Free)` or `(PRO)` in the MCP tool list.
378
124
 
379
- ## Contributing
125
+ - Default PRO tools: `ai_context`, `ai_enhanced_context`, `ai_context_budget`, `ai_embeddings`, `ai_plan`, `ai_tasks`
126
+ - If a Free-plan user calls a PRO tool, the server returns an upgrade message with a link.
127
+ - Override the PRO list via `CONTEXTSTREAM_PRO_TOOLS` and the upgrade link via `CONTEXTSTREAM_UPGRADE_URL`.
380
128
 
381
- We welcome contributions:
129
+ ## Troubleshooting
382
130
 
383
- 1. **Report bugs** [Open an issue](https://github.com/contextstream/mcp-server/issues)
384
- 2. **Request features** Share ideas in GitHub Issues
385
- 3. **Submit PRs** Fork, branch, and submit
131
+ - Prompts/tools not appearing: restart the client after editing MCP config; confirm Node 18+ is available to the client runtime.
132
+ - Slash commands do nothing: update to the latest `@contextstream/mcp-server` and restart your MCP client (prompts are parameter-free and should insert immediately).
133
+ - Unauthorized errors: verify `CONTEXTSTREAM_API_URL` and `CONTEXTSTREAM_API_KEY` (or `CONTEXTSTREAM_JWT`).
134
+ - Wrong workspace/project: use `workspace_associate` to map the current repo folder to the correct workspace.
386
135
 
387
- ### Development
136
+ ## Development
388
137
 
389
138
  ```bash
390
139
  git clone https://github.com/contextstream/mcp-server.git
391
140
  cd mcp-server
392
141
  npm install
393
- npm run dev # Development mode
394
- npm run build # Production build
142
+ npm run dev
395
143
  npm run typecheck
144
+ npm run build
396
145
  ```
397
146
 
398
- ---
147
+ ## Links
148
+
149
+ - Website: https://contextstream.io
150
+ - Docs: https://contextstream.io/docs/mcp
151
+ - Pricing: https://contextstream.io/pricing
152
+ - npm: https://www.npmjs.com/package/@contextstream/mcp-server
153
+ - GitHub: https://github.com/contextstream/mcp-server
399
154
 
400
155
  ## License
401
156
 
402
157
  MIT
403
-
404
- ---
405
-
406
- <div align="center">
407
-
408
- **Stop re-explaining. Start building.**
409
-
410
- [Get Started →](https://contextstream.io)
411
-
412
- </div>