@contextstream/mcp-server 0.4.47 → 0.4.48

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 (2) hide show
  1. package/dist/index.js +105 -99
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12104,36 +12104,48 @@ function applyMcpToolPrefix(markdown, toolPrefix) {
12104
12104
  return markdown.replace(toolRegex, `${toolPrefix}$1`);
12105
12105
  }
12106
12106
  var CONTEXTSTREAM_RULES_DYNAMIC = `
12107
- ## ContextStream Dynamic Rules (Powered by our SmartRouter)
12107
+ # ContextStream Rules (MANDATORY)
12108
12108
 
12109
- All rules are served dynamically via \`context\`. This file is minimal by design.
12109
+ ## \u{1F6A8} CRITICAL: Call These Tools or Fail \u{1F6A8}
12110
12110
 
12111
- ### Every Message Protocol
12111
+ <contextstream_protocol>
12112
+ **EVERY response MUST start with:**
12113
+ 1. \`init()\` (1st message only) \u2192 then \`context(user_message="<msg>")\`
12114
+ 2. \`context(user_message="<msg>")\` (EVERY subsequent message)
12112
12115
 
12113
- | Message | What to Call |
12114
- |---------|--------------|
12115
- | **1st message** | \`init()\` then \`context(user_message="<msg>")\` |
12116
- | **2nd+ messages** | \`context(user_message="<msg>")\` |
12116
+ **BEFORE Glob/Grep/Read/Search/Explore:**
12117
+ \u2192 \`search(mode="hybrid", query="...")\` FIRST \u2014 local tools ONLY if 0 results
12117
12118
 
12118
- Note: \`init()\` auto-detects folder from IDE. Only pass \`folder_path\` if auto-detection fails.
12119
+ **HOOKS: Follow \`<system-reminder>\` instructions \u2014 they ARE the rules**
12120
+ </contextstream_protocol>
12119
12121
 
12120
- ### Follow the Instructions Field
12122
+ ### Why This Matters
12121
12123
 
12122
- The \`context\` response includes an \`instructions\` field with context-aware guidance.
12123
- **Follow these instructions.** They are dynamically matched to your query and include:
12124
- - Search guidance (when/how to search)
12125
- - Git workflow rules (commit, PR, safety)
12126
- - Planning rules (use ContextStream plans, not file-based)
12127
- - Media/code analysis guidance
12128
- - Lessons from past mistakes
12129
- - And more...
12124
+ - **\`context()\`** = Your rules, lessons, and relevant memories delivered dynamically
12125
+ - **\`search()\`** = Indexed search (1 call) vs Grep\u2192Read\u2192Read (4+ calls)
12126
+ - **Hooks inject \`<system-reminder>\` tags** = Follow these instructions, they enforce ContextStream-first
12127
+ - **Skipping these = missing context, repeated mistakes, slow searches**
12130
12128
 
12131
- ### Notices
12129
+ ### Protocol
12132
12130
 
12133
- Handle notices from \`context\` response:
12134
- - **[VERSION_NOTICE]**: Tell user to update MCP
12135
- - **[RULES_NOTICE]**: Run \`generate_rules()\`
12136
- - **[LESSONS_WARNING]**: Apply lessons immediately
12131
+ | When | Do This |
12132
+ |------|---------|
12133
+ | 1st message | \`init()\` \u2192 \`context(user_message="...")\` |
12134
+ | Every message after | \`context(user_message="...")\` |
12135
+ | Before ANY file search | \`search(mode="hybrid")\` first |
12136
+ | On \`<system-reminder>\` | **Follow the instructions inside** |
12137
+ | Save decisions | \`session(action="capture", ...)\` |
12138
+
12139
+ ### Handle Notices from context()
12140
+
12141
+ - **[LESSONS_WARNING]** \u2192 Tell user about past mistakes BEFORE proceeding
12142
+ - **[RULES_NOTICE]** \u2192 Run \`generate_rules()\` to update
12143
+ - **[VERSION_NOTICE]** \u2192 Tell user to update MCP
12144
+
12145
+ ### Fast Path (Skip context only for these)
12146
+
12147
+ Simple utility commands: "list workspaces", "show version", "list reminders"
12148
+ \u2192 Just execute directly: \`workspace(action="list")\`, \`help(action="version")\`
12137
12149
 
12138
12150
  Rules Version: ${RULES_VERSION}
12139
12151
  `.trim();
@@ -12591,83 +12603,71 @@ memory(action="create_task", title="<task title>", plan_id="<plan_id from step 1
12591
12603
  See full documentation: https://contextstream.io/docs/mcp/tools
12592
12604
  `.trim();
12593
12605
  var CONTEXTSTREAM_RULES_MINIMAL = `
12594
- ## ContextStream Rules
12606
+ # ContextStream Rules (MANDATORY)
12595
12607
 
12596
- <contextstream_rules>
12597
- 1. **SIMPLE UTILITY?** (list/show/version) \u2192 Just execute, skip context calls
12598
- 2. **CODING TASK?** \u2192 init \u2192 context \u2192 work \u2192 capture
12599
- 3. **SEARCH FIRST:** Before Glob/Grep/Read \u2192 \`search(mode="hybrid")\` FIRST
12600
- </contextstream_rules>
12608
+ ## \u{1F6A8} CRITICAL: These Rules Are Non-Negotiable \u{1F6A8}
12601
12609
 
12602
- **Display this block at the start of responses to keep rules in context.**
12610
+ <contextstream_protocol>
12611
+ **EVERY coding response MUST start with:**
12612
+ 1. \`init()\` (1st message only) \u2192 then \`context(user_message="<msg>")\`
12613
+ 2. \`context(user_message="<msg>")\` (EVERY subsequent message)
12603
12614
 
12604
- ---
12615
+ **BEFORE Glob/Grep/Read/Search/Explore:**
12616
+ \u2192 \`search(mode="hybrid", query="...")\` FIRST \u2014 local tools ONLY if 0 results
12605
12617
 
12606
- ## ContextStream v0.4.x (Hooks Enforced)
12618
+ **HOOKS: \`<system-reminder>\` tags contain instructions \u2014 FOLLOW THEM**
12619
+ </contextstream_protocol>
12607
12620
 
12608
12621
  Rules Version: ${RULES_VERSION}
12609
- **Note:** PreToolUse hooks block Glob/Grep/Search when ContextStream is available.
12610
12622
 
12611
- ### For Coding Tasks
12623
+ ---
12612
12624
 
12613
- | Action | Tool Call |
12614
- |--------|-----------|
12615
- | **1st message** | \`init(folder_path="<cwd>", context_hint="<msg>")\` then \`context(...)\` |
12616
- | **2nd+ messages** | \`context(user_message="<msg>", format="minified", max_tokens=400)\` |
12617
- | **Code search** | \`search(mode="hybrid", query="...")\` \u2014 BEFORE any local tools |
12618
- | **Save decisions** | \`session(action="capture", event_type="decision", ...)\` |
12625
+ ## Why ContextStream First?
12619
12626
 
12620
- ### Search Modes
12627
+ | \u274C WRONG | \u2705 CORRECT |
12628
+ |----------|-----------|
12629
+ | \`Grep \u2192 Read \u2192 Read \u2192 Read\` (4+ calls) | \`search(mode="hybrid")\` (1 call) |
12630
+ | Missing past decisions & lessons | \`context()\` = rules + lessons + memory |
12631
+ | Ignoring \`<system-reminder>\` hooks | Hooks enforce ContextStream-first |
12632
+
12633
+ **\`context()\` delivers: rules, lessons from past mistakes, relevant decisions, semantic matches**
12634
+ **\`search()\` is indexed: faster, returns context, one call vs many**
12635
+ **Hooks inject \`<system-reminder>\` tags: these ARE the rules, follow them**
12636
+
12637
+ ---
12621
12638
 
12622
- | Mode | Use Case |
12623
- |------|----------|
12624
- | \`hybrid\` | General code search (default) |
12625
- | \`keyword\` | Exact symbol/string match |
12626
- | \`exhaustive\` | Find ALL matches (grep-like) |
12639
+ ## Protocol
12640
+
12641
+ | When | Call |
12642
+ |------|------|
12643
+ | 1st message | \`init()\` \u2192 \`context(user_message="...")\` |
12644
+ | Every message after | \`context(user_message="...")\` |
12645
+ | Before ANY file discovery | \`search(mode="hybrid", query="...")\` |
12646
+ | On \`<system-reminder>\` | **Follow instructions inside** |
12647
+ | Save important decisions | \`session(action="capture", event_type="decision", ...)\` |
12648
+ | Check past mistakes | \`session(action="get_lessons", query="...")\` |
12649
+
12650
+ ## Search Modes
12651
+
12652
+ | Mode | When |
12653
+ |------|------|
12654
+ | \`hybrid\` | Default \u2014 semantic + keyword |
12655
+ | \`keyword\` | Exact symbol match |
12656
+ | \`exhaustive\` | Find ALL occurrences |
12627
12657
  | \`semantic\` | Conceptual questions |
12628
12658
 
12629
- ### Why ContextStream First?
12659
+ ## Handle Notices from context()
12630
12660
 
12631
- \u274C **WRONG:** \`Grep \u2192 Read \u2192 Read \u2192 Read\` (4+ tool calls, slow)
12632
- \u2705 **CORRECT:** \`search(mode="hybrid")\` (1 call, returns context)
12661
+ - **[LESSONS_WARNING]** \u2192 Tell user about past mistakes BEFORE proceeding
12662
+ - **[RULES_NOTICE]** \u2192 Run \`generate_rules()\`
12663
+ - **[VERSION_NOTICE]** \u2192 Tell user to update MCP
12633
12664
 
12634
- ContextStream search is **indexed** and returns semantic matches + context in ONE call.
12665
+ ## Fast Path (Simple Utilities Only)
12635
12666
 
12636
- ### Quick Reference
12667
+ Skip init/context ONLY for: "list workspaces", "show version", "list reminders"
12668
+ \u2192 Just call: \`workspace(action="list")\`, \`help(action="version")\`, etc.
12637
12669
 
12638
- | Tool | Example |
12639
- |------|---------|
12640
- | \`search\` | \`search(mode="hybrid", query="auth", limit=3)\` |
12641
- | \`session\` | \`session(action="capture", event_type="decision", title="...", content="...")\` |
12642
- | \`memory\` | \`memory(action="list_events", limit=10)\` |
12643
- | \`graph\` | \`graph(action="dependencies", file_path="...")\` |
12644
-
12645
- ### \u{1F680} FAST PATH: Simple Utility Operations
12646
-
12647
- **For simple utility commands, SKIP the ceremony and just execute directly:**
12648
-
12649
- | Command Type | Just Call | Skip |
12650
- |--------------|-----------|------|
12651
- | List workspaces | \`workspace(action="list")\` | init, context, capture |
12652
- | List projects | \`project(action="list")\` | init, context, capture |
12653
- | Show version | \`help(action="version")\` | init, context, capture |
12654
- | List reminders | \`reminder(action="list")\` | init, context, capture |
12655
- | Check auth | \`help(action="auth")\` | init, context, capture |
12656
-
12657
- **Detect simple operations by these patterns:**
12658
- - "list ...", "show ...", "what are my ...", "get ..."
12659
- - Single-action queries with no context dependency
12660
- - User just wants data, not analysis or coding help
12661
-
12662
- **DO NOT add overhead for utility operations:**
12663
- - \u274C Don't call init just to list workspaces
12664
- - \u274C Don't call context for simple queries
12665
- - \u274C Don't capture "listed workspaces" as an event (that's noise)
12666
-
12667
- **Use full context ceremony ONLY for:**
12668
- - Coding tasks (edit, create, refactor, debug)
12669
- - Search/discovery (finding code, understanding architecture)
12670
- - Tasks where past decisions or lessons matter
12670
+ Everything else = full protocol (init \u2192 context \u2192 search \u2192 work)
12671
12671
 
12672
12672
  ### Lessons (Past Mistakes)
12673
12673
 
@@ -21120,13 +21120,19 @@ ${formatContent(result)}`
21120
21120
  if (!workspaceId) {
21121
21121
  return errorResult("create_doc requires workspace_id. Call session_init first.");
21122
21122
  }
21123
+ const detectedEditor = getDetectedClientName();
21124
+ const aiMetadata = detectedEditor ? {
21125
+ created_by_ai: true,
21126
+ ai_editor: detectedEditor,
21127
+ ...input.metadata || {}
21128
+ } : input.metadata;
21123
21129
  const docResult = await client.docsCreate({
21124
21130
  workspace_id: workspaceId,
21125
21131
  project_id: projectId,
21126
21132
  title: input.title,
21127
21133
  content: input.content,
21128
21134
  doc_type: input.doc_type,
21129
- metadata: input.metadata,
21135
+ metadata: aiMetadata,
21130
21136
  is_personal: input.is_personal
21131
21137
  });
21132
21138
  return {
@@ -23207,7 +23213,7 @@ function registerLimitedTools(server) {
23207
23213
  text: `ContextStream: API key not configured.
23208
23214
 
23209
23215
  To set up (creates key + configures your editor):
23210
- npx -y @contextstream/mcp-server setup
23216
+ npx --prefer-online -y @contextstream/mcp-server@latest setup
23211
23217
 
23212
23218
  This will:
23213
23219
  - Start a 5-day Pro trial
@@ -23215,7 +23221,7 @@ This will:
23215
23221
  - Write rules files for better AI assistance
23216
23222
 
23217
23223
  Preview first:
23218
- npx -y @contextstream/mcp-server setup --dry-run
23224
+ npx --prefer-online -y @contextstream/mcp-server@latest setup --dry-run
23219
23225
 
23220
23226
  After setup, restart your editor to enable all ContextStream tools.`
23221
23227
  }
@@ -25354,13 +25360,13 @@ function buildContextStreamMcpServer(params) {
25354
25360
  if (IS_WINDOWS) {
25355
25361
  return {
25356
25362
  command: "cmd",
25357
- args: ["/c", "npx", "-y", "@contextstream/mcp-server"],
25363
+ args: ["/c", "npx", "--prefer-online", "-y", "@contextstream/mcp-server@latest"],
25358
25364
  env
25359
25365
  };
25360
25366
  }
25361
25367
  return {
25362
25368
  command: "npx",
25363
- args: ["-y", "@contextstream/mcp-server"],
25369
+ args: ["--prefer-online", "-y", "@contextstream/mcp-server@latest"],
25364
25370
  env
25365
25371
  };
25366
25372
  }
@@ -25383,14 +25389,14 @@ function buildContextStreamVsCodeServer(params) {
25383
25389
  return {
25384
25390
  type: "stdio",
25385
25391
  command: "cmd",
25386
- args: ["/c", "npx", "-y", "@contextstream/mcp-server"],
25392
+ args: ["/c", "npx", "--prefer-online", "-y", "@contextstream/mcp-server@latest"],
25387
25393
  env
25388
25394
  };
25389
25395
  }
25390
25396
  return {
25391
25397
  type: "stdio",
25392
25398
  command: "npx",
25393
- args: ["-y", "@contextstream/mcp-server"],
25399
+ args: ["--prefer-online", "-y", "@contextstream/mcp-server@latest"],
25394
25400
  env
25395
25401
  };
25396
25402
  }
@@ -25484,9 +25490,9 @@ async function upsertCodexTomlConfig(filePath, params) {
25484
25490
  const showTimingLine = params.showTiming ? `CONTEXTSTREAM_SHOW_TIMING = "true"
25485
25491
  ` : "";
25486
25492
  const commandLine = IS_WINDOWS ? `command = "cmd"
25487
- args = ["/c", "npx", "-y", "@contextstream/mcp-server"]
25493
+ args = ["/c", "npx", "--prefer-online", "-y", "@contextstream/mcp-server@latest"]
25488
25494
  ` : `command = "npx"
25489
- args = ["-y", "@contextstream/mcp-server"]
25495
+ args = ["--prefer-online", "-y", "@contextstream/mcp-server@latest"]
25490
25496
  `;
25491
25497
  const block = `
25492
25498
 
@@ -25634,7 +25640,7 @@ async function runSetupWizard(args) {
25634
25640
  console.log(` Latest version is v${versionNotice.latest}`);
25635
25641
  console.log("");
25636
25642
  console.log(" To use the latest version, exit and run:");
25637
- console.log(" npx -y @contextstream/mcp-server@latest setup");
25643
+ console.log(" npx --prefer-online -y @contextstream/mcp-server@latest setup");
25638
25644
  console.log("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");
25639
25645
  console.log("");
25640
25646
  const continueAnyway = normalizeInput(
@@ -25989,10 +25995,10 @@ Detected plan: ${planLabel} (graph: ${graphTierLabel})`);
25989
25995
  const envHint = toolset === "router" ? " --env CONTEXTSTREAM_PROGRESSIVE_MODE=true" : "";
25990
25996
  const packHint = contextPackEnabled === false ? " --env CONTEXTSTREAM_CONTEXT_PACK=false" : " --env CONTEXTSTREAM_CONTEXT_PACK=true";
25991
25997
  console.log(
25992
- ` macOS/Linux: claude mcp add --transport stdio contextstream --scope user --env CONTEXTSTREAM_API_URL=... --env CONTEXTSTREAM_API_KEY=...${envHint}${packHint} -- npx -y @contextstream/mcp-server`
25998
+ ` macOS/Linux: claude mcp add --transport stdio contextstream --scope user --env CONTEXTSTREAM_API_URL=... --env CONTEXTSTREAM_API_KEY=...${envHint}${packHint} -- npx --prefer-online -y @contextstream/mcp-server@latest`
25993
25999
  );
25994
26000
  console.log(
25995
- " Windows (native): use `cmd /c npx -y @contextstream/mcp-server` after `--` if `npx` is not found."
26001
+ " Windows (native): use `cmd /c npx --prefer-online -y @contextstream/mcp-server@latest` after `--` if `npx` is not found."
25996
26002
  );
25997
26003
  continue;
25998
26004
  }
@@ -26327,7 +26333,7 @@ function printHelp() {
26327
26333
  console.log(`ContextStream MCP Server (contextstream-mcp) v${VERSION}
26328
26334
 
26329
26335
  Usage:
26330
- npx -y @contextstream/mcp-server
26336
+ npx --prefer-online -y @contextstream/mcp-server@latest
26331
26337
  contextstream-mcp
26332
26338
  contextstream-mcp setup
26333
26339
  contextstream-mcp http
@@ -26374,10 +26380,10 @@ Environment variables:
26374
26380
  Examples:
26375
26381
  CONTEXTSTREAM_API_URL="https://api.contextstream.io" \\
26376
26382
  CONTEXTSTREAM_API_KEY="your_api_key" \\
26377
- npx -y @contextstream/mcp-server
26383
+ npx --prefer-online -y @contextstream/mcp-server@latest
26378
26384
 
26379
26385
  Setup wizard:
26380
- npx -y @contextstream/mcp-server setup
26386
+ npx --prefer-online -y @contextstream/mcp-server@latest setup
26381
26387
 
26382
26388
  Notes:
26383
26389
  - When used from an MCP client (e.g. Codex, Cursor, VS Code),
@@ -26391,7 +26397,7 @@ async function runLimitedModeServer() {
26391
26397
  });
26392
26398
  registerLimitedTools(server);
26393
26399
  console.error(`ContextStream MCP server v${VERSION} (limited mode)`);
26394
- console.error('Run "npx -y @contextstream/mcp-server setup" to enable all tools.');
26400
+ console.error('Run "npx --prefer-online -y @contextstream/mcp-server@latest setup" to enable all tools.');
26395
26401
  const transport = new StdioServerTransport();
26396
26402
  await server.connect(transport);
26397
26403
  console.error("ContextStream MCP server connected (limited mode - setup required)");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contextstream/mcp-server",
3
3
  "mcpName": "io.github.contextstreamio/mcp-server",
4
- "version": "0.4.47",
4
+ "version": "0.4.48",
5
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
6
  "type": "module",
7
7
  "license": "MIT",