@contextstream/mcp-server 0.3.31 → 0.3.32

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 +50 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6860,6 +6860,8 @@ function getVersion() {
6860
6860
  var VERSION = getVersion();
6861
6861
 
6862
6862
  // src/tools.ts
6863
+ var LESSON_DEDUP_WINDOW_MS = 2 * 60 * 1e3;
6864
+ var recentLessonCaptures = /* @__PURE__ */ new Map();
6863
6865
  function formatContent(data) {
6864
6866
  return JSON.stringify(data, null, 2);
6865
6867
  }
@@ -6869,6 +6871,35 @@ function toStructured(data) {
6869
6871
  }
6870
6872
  return void 0;
6871
6873
  }
6874
+ function normalizeLessonField(value) {
6875
+ return value.trim().toLowerCase().replace(/\s+/g, " ");
6876
+ }
6877
+ function buildLessonSignature(input, workspaceId, projectId) {
6878
+ return [
6879
+ workspaceId,
6880
+ projectId || "global",
6881
+ input.category,
6882
+ input.title,
6883
+ input.trigger,
6884
+ input.impact,
6885
+ input.prevention
6886
+ ].map(normalizeLessonField).join("|");
6887
+ }
6888
+ function isDuplicateLessonCapture(signature) {
6889
+ const now = Date.now();
6890
+ for (const [key, ts] of recentLessonCaptures) {
6891
+ if (now - ts > LESSON_DEDUP_WINDOW_MS) {
6892
+ recentLessonCaptures.delete(key);
6893
+ }
6894
+ }
6895
+ const last = recentLessonCaptures.get(signature);
6896
+ if (last && now - last < LESSON_DEDUP_WINDOW_MS) {
6897
+ recentLessonCaptures.set(signature, now);
6898
+ return true;
6899
+ }
6900
+ recentLessonCaptures.set(signature, now);
6901
+ return false;
6902
+ }
6872
6903
  function registerTools(server, client, sessionManager) {
6873
6904
  const upgradeUrl = process.env.CONTEXTSTREAM_UPGRADE_URL || "https://contextstream.io/pricing";
6874
6905
  const defaultProTools = /* @__PURE__ */ new Set([
@@ -8286,6 +8317,25 @@ The lesson will be tagged with 'lesson' and stored with structured metadata for
8286
8317
  isError: true
8287
8318
  };
8288
8319
  }
8320
+ const lessonSignature = buildLessonSignature({
8321
+ title: input.title,
8322
+ category: input.category,
8323
+ trigger: input.trigger,
8324
+ impact: input.impact,
8325
+ prevention: input.prevention
8326
+ }, workspaceId, projectId);
8327
+ if (isDuplicateLessonCapture(lessonSignature)) {
8328
+ return {
8329
+ content: [{
8330
+ type: "text",
8331
+ text: `\u2139\uFE0F Duplicate lesson capture ignored: "${input.title}" was already recorded recently.`
8332
+ }],
8333
+ structuredContent: {
8334
+ deduped: true,
8335
+ title: input.title
8336
+ }
8337
+ };
8338
+ }
8289
8339
  const lessonContent = [
8290
8340
  `## ${input.title}`,
8291
8341
  "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contextstream/mcp-server",
3
- "version": "0.3.31",
3
+ "version": "0.3.32",
4
4
  "description": "MCP server exposing ContextStream public API - code context, memory, search, and AI tools for developers",
5
5
  "type": "module",
6
6
  "license": "MIT",