@contextstream/mcp-server 0.4.17 → 0.4.19

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 +101 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7504,7 +7504,7 @@ var CONTEXTSTREAM_TOOL_NAMES = [
7504
7504
  ];
7505
7505
  function applyMcpToolPrefix(markdown, toolPrefix) {
7506
7506
  const toolPattern = CONTEXTSTREAM_TOOL_NAMES.join("|");
7507
- const toolRegex = new RegExp(`(?<!__)\\b(${toolPattern})\\b`, "g");
7507
+ const toolRegex = new RegExp(`(?<!__)\\b(${toolPattern})\\b(?=\\s*\\()`, "g");
7508
7508
  return markdown.replace(toolRegex, `${toolPrefix}$1`);
7509
7509
  }
7510
7510
  var CONTEXTSTREAM_RULES_FULL = `
@@ -7529,6 +7529,8 @@ Rules Version: ${RULES_VERSION}
7529
7529
 
7530
7530
  **Context Pack (Pro+):** If enabled, use \`context_smart(..., mode="pack", distill=true)\` for code/file queries. If unavailable, omit \`mode\` and use standard \`context_smart\`.
7531
7531
 
7532
+ **Tool naming:** Use the exact tool names exposed by your MCP client. Claude Code typically uses \`mcp__<server>__<tool>\` where \`<server>\` matches your MCP config (often \`contextstream\`). If a tool call fails with "No such tool available", refresh rules and match the tool list.
7533
+
7532
7534
  ---
7533
7535
 
7534
7536
  ## Consolidated Domain Tools Architecture
@@ -7715,6 +7717,8 @@ Rules Version: ${RULES_VERSION}
7715
7717
 
7716
7718
  **Context Pack (Pro+):** If enabled, use \`context_smart(..., mode="pack", distill=true)\` for code/file queries. If unavailable, omit \`mode\`.
7717
7719
 
7720
+ **Tool naming:** Use the exact tool names exposed by your MCP client. Claude Code typically uses \`mcp__<server>__<tool>\` where \`<server>\` matches your MCP config (often \`contextstream\`). If a tool call fails with "No such tool available", refresh rules and match the tool list.
7721
+
7718
7722
  ### Quick Reference: Domain Tools
7719
7723
 
7720
7724
  | Tool | Common Usage |
@@ -8227,11 +8231,56 @@ function getRulesNotice(folderPath, clientName) {
8227
8231
  }
8228
8232
  var CONTEXTSTREAM_START_MARKER = "<!-- BEGIN ContextStream -->";
8229
8233
  var CONTEXTSTREAM_END_MARKER = "<!-- END ContextStream -->";
8234
+ var LEGACY_CONTEXTSTREAM_HINTS = [
8235
+ "contextstream integration",
8236
+ "contextstream v0.4",
8237
+ "contextstream v0.3",
8238
+ "contextstream (standard)",
8239
+ "contextstream (consolidated",
8240
+ "contextstream mcp",
8241
+ "contextstream tools"
8242
+ ];
8243
+ var LEGACY_CONTEXTSTREAM_ALLOWED_HEADINGS = [
8244
+ "contextstream",
8245
+ "tl;dr",
8246
+ "required every message",
8247
+ "quick reference",
8248
+ "tool catalog",
8249
+ "consolidated domain tools",
8250
+ "standalone tools",
8251
+ "domain tools",
8252
+ "why context_smart",
8253
+ "recommended token budgets",
8254
+ "rules update notices",
8255
+ "preferences & lessons",
8256
+ "index & graph preflight",
8257
+ "search & code intelligence",
8258
+ "distillation",
8259
+ "when to capture",
8260
+ "behavior rules",
8261
+ "plans & tasks",
8262
+ "complete action reference"
8263
+ ];
8230
8264
  function wrapWithMarkers(content) {
8231
8265
  return `${CONTEXTSTREAM_START_MARKER}
8232
8266
  ${content.trim()}
8233
8267
  ${CONTEXTSTREAM_END_MARKER}`;
8234
8268
  }
8269
+ function isLegacyContextStreamRules(content) {
8270
+ const lower = content.toLowerCase();
8271
+ if (!lower.includes("contextstream")) return false;
8272
+ if (!LEGACY_CONTEXTSTREAM_HINTS.some((hint) => lower.includes(hint))) return false;
8273
+ const headingRegex = /^#{1,6}\s+(.+)$/gm;
8274
+ let hasHeading = false;
8275
+ let match;
8276
+ while ((match = headingRegex.exec(content)) !== null) {
8277
+ hasHeading = true;
8278
+ const heading = match[1].trim().toLowerCase();
8279
+ const allowed = LEGACY_CONTEXTSTREAM_ALLOWED_HEADINGS.some((prefix) => heading.startsWith(prefix));
8280
+ if (!allowed) return false;
8281
+ }
8282
+ return hasHeading;
8283
+ }
8235
8284
  async function upsertRuleFile(filePath, content) {
8236
8285
  await fs3.promises.mkdir(path4.dirname(filePath), { recursive: true });
8237
8286
  const wrappedContent = wrapWithMarkers(content);
@@ -8253,6 +8302,10 @@ async function upsertRuleFile(filePath, content) {
8253
8302
  await fs3.promises.writeFile(filePath, updated.trim() + "\n", "utf8");
8254
8303
  return "updated";
8255
8304
  }
8305
+ if (isLegacyContextStreamRules(existing)) {
8306
+ await fs3.promises.writeFile(filePath, wrappedContent + "\n", "utf8");
8307
+ return "updated";
8308
+ }
8256
8309
  const joined = existing.trimEnd() + "\n\n" + wrappedContent + "\n";
8257
8310
  await fs3.promises.writeFile(filePath, joined, "utf8");
8258
8311
  return "appended";
@@ -15738,11 +15791,56 @@ async function fileExists(filePath) {
15738
15791
  }
15739
15792
  var CONTEXTSTREAM_START_MARKER2 = "<!-- BEGIN ContextStream -->";
15740
15793
  var CONTEXTSTREAM_END_MARKER2 = "<!-- END ContextStream -->";
15794
+ var LEGACY_CONTEXTSTREAM_HINTS2 = [
15795
+ "contextstream integration",
15796
+ "contextstream v0.4",
15797
+ "contextstream v0.3",
15798
+ "contextstream (standard)",
15799
+ "contextstream (consolidated",
15800
+ "contextstream mcp",
15801
+ "contextstream tools"
15802
+ ];
15803
+ var LEGACY_CONTEXTSTREAM_ALLOWED_HEADINGS2 = [
15804
+ "contextstream",
15805
+ "tl;dr",
15806
+ "required every message",
15807
+ "quick reference",
15808
+ "tool catalog",
15809
+ "consolidated domain tools",
15810
+ "standalone tools",
15811
+ "domain tools",
15812
+ "why context_smart",
15813
+ "recommended token budgets",
15814
+ "rules update notices",
15815
+ "preferences & lessons",
15816
+ "index & graph preflight",
15817
+ "search & code intelligence",
15818
+ "distillation",
15819
+ "when to capture",
15820
+ "behavior rules",
15821
+ "plans & tasks",
15822
+ "complete action reference"
15823
+ ];
15741
15824
  function wrapWithMarkers2(content) {
15742
15825
  return `${CONTEXTSTREAM_START_MARKER2}
15743
15826
  ${content.trim()}
15744
15827
  ${CONTEXTSTREAM_END_MARKER2}`;
15745
15828
  }
15829
+ function isLegacyContextStreamRules2(content) {
15830
+ const lower = content.toLowerCase();
15831
+ if (!lower.includes("contextstream")) return false;
15832
+ if (!LEGACY_CONTEXTSTREAM_HINTS2.some((hint) => lower.includes(hint))) return false;
15833
+ const headingRegex = /^#{1,6}\s+(.+)$/gm;
15834
+ let hasHeading = false;
15835
+ let match;
15836
+ while ((match = headingRegex.exec(content)) !== null) {
15837
+ hasHeading = true;
15838
+ const heading = match[1].trim().toLowerCase();
15839
+ const allowed = LEGACY_CONTEXTSTREAM_ALLOWED_HEADINGS2.some((prefix) => heading.startsWith(prefix));
15840
+ if (!allowed) return false;
15841
+ }
15842
+ return hasHeading;
15843
+ }
15746
15844
  async function upsertTextFile(filePath, content, _marker) {
15747
15845
  await fs5.mkdir(path6.dirname(filePath), { recursive: true });
15748
15846
  const exists = await fileExists(filePath);
@@ -15761,9 +15859,8 @@ async function upsertTextFile(filePath, content, _marker) {
15761
15859
  await fs5.writeFile(filePath, updated.trim() + "\n", "utf8");
15762
15860
  return "updated";
15763
15861
  }
15764
- if (existing.includes("ContextStream")) {
15765
- const joined2 = existing.trimEnd() + "\n\n" + wrappedContent + "\n";
15766
- await fs5.writeFile(filePath, joined2, "utf8");
15862
+ if (isLegacyContextStreamRules2(existing)) {
15863
+ await fs5.writeFile(filePath, wrappedContent + "\n", "utf8");
15767
15864
  return "updated";
15768
15865
  }
15769
15866
  const joined = existing.trimEnd() + "\n\n" + wrappedContent + "\n";
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.17",
4
+ "version": "0.4.19",
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",