@contextstream/mcp-server 0.3.53 → 0.3.54
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.
- package/dist/index.js +56 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4701,6 +4701,8 @@ import { createRequire } from "module";
|
|
|
4701
4701
|
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
4702
4702
|
import { homedir } from "os";
|
|
4703
4703
|
import { join as join3 } from "path";
|
|
4704
|
+
var UPGRADE_COMMAND = "npm update -g @contextstream/mcp-server";
|
|
4705
|
+
var NPM_LATEST_URL = "https://registry.npmjs.org/@contextstream/mcp-server/latest";
|
|
4704
4706
|
function getVersion() {
|
|
4705
4707
|
try {
|
|
4706
4708
|
const require2 = createRequire(import.meta.url);
|
|
@@ -4724,6 +4726,7 @@ function compareVersions(v1, v2) {
|
|
|
4724
4726
|
return 0;
|
|
4725
4727
|
}
|
|
4726
4728
|
var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
4729
|
+
var latestVersionPromise = null;
|
|
4727
4730
|
function getCacheFilePath() {
|
|
4728
4731
|
return join3(homedir(), ".contextstream", "version-cache.json");
|
|
4729
4732
|
}
|
|
@@ -4752,33 +4755,40 @@ function writeCache(latestVersion) {
|
|
|
4752
4755
|
} catch {
|
|
4753
4756
|
}
|
|
4754
4757
|
}
|
|
4755
|
-
async function
|
|
4756
|
-
const currentVersion = VERSION;
|
|
4757
|
-
if (currentVersion === "unknown") return;
|
|
4758
|
+
async function fetchLatestVersion() {
|
|
4758
4759
|
try {
|
|
4759
|
-
const cached = readCache();
|
|
4760
|
-
if (cached) {
|
|
4761
|
-
if (compareVersions(currentVersion, cached.latestVersion) < 0) {
|
|
4762
|
-
showUpdateWarning(currentVersion, cached.latestVersion);
|
|
4763
|
-
}
|
|
4764
|
-
return;
|
|
4765
|
-
}
|
|
4766
4760
|
const controller = new AbortController();
|
|
4767
4761
|
const timeout = setTimeout(() => controller.abort(), 5e3);
|
|
4768
|
-
const response = await fetch(
|
|
4762
|
+
const response = await fetch(NPM_LATEST_URL, {
|
|
4769
4763
|
signal: controller.signal,
|
|
4770
4764
|
headers: { "Accept": "application/json" }
|
|
4771
4765
|
});
|
|
4772
4766
|
clearTimeout(timeout);
|
|
4773
|
-
if (!response.ok) return;
|
|
4767
|
+
if (!response.ok) return null;
|
|
4774
4768
|
const data = await response.json();
|
|
4775
|
-
|
|
4776
|
-
if (typeof latestVersion !== "string") return;
|
|
4777
|
-
writeCache(latestVersion);
|
|
4778
|
-
if (compareVersions(currentVersion, latestVersion) < 0) {
|
|
4779
|
-
showUpdateWarning(currentVersion, latestVersion);
|
|
4780
|
-
}
|
|
4769
|
+
return typeof data.version === "string" ? data.version : null;
|
|
4781
4770
|
} catch {
|
|
4771
|
+
return null;
|
|
4772
|
+
}
|
|
4773
|
+
}
|
|
4774
|
+
async function resolveLatestVersion() {
|
|
4775
|
+
const cached = readCache();
|
|
4776
|
+
if (cached) return cached.latestVersion;
|
|
4777
|
+
if (!latestVersionPromise) {
|
|
4778
|
+
latestVersionPromise = fetchLatestVersion().finally(() => {
|
|
4779
|
+
latestVersionPromise = null;
|
|
4780
|
+
});
|
|
4781
|
+
}
|
|
4782
|
+
const latestVersion = await latestVersionPromise;
|
|
4783
|
+
if (latestVersion) {
|
|
4784
|
+
writeCache(latestVersion);
|
|
4785
|
+
}
|
|
4786
|
+
return latestVersion;
|
|
4787
|
+
}
|
|
4788
|
+
async function checkForUpdates() {
|
|
4789
|
+
const notice = await getUpdateNotice();
|
|
4790
|
+
if (notice?.behind) {
|
|
4791
|
+
showUpdateWarning(notice.current, notice.latest);
|
|
4782
4792
|
}
|
|
4783
4793
|
}
|
|
4784
4794
|
function showUpdateWarning(currentVersion, latestVersion) {
|
|
@@ -4786,12 +4796,30 @@ function showUpdateWarning(currentVersion, latestVersion) {
|
|
|
4786
4796
|
console.error("\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");
|
|
4787
4797
|
console.error(`\u26A0\uFE0F Update available: v${currentVersion} \u2192 v${latestVersion}`);
|
|
4788
4798
|
console.error("");
|
|
4789
|
-
console.error(
|
|
4799
|
+
console.error(` Run: ${UPGRADE_COMMAND}`);
|
|
4790
4800
|
console.error("");
|
|
4791
4801
|
console.error(" Then restart your AI tool to use the new version.");
|
|
4792
4802
|
console.error("\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");
|
|
4793
4803
|
console.error("");
|
|
4794
4804
|
}
|
|
4805
|
+
async function getUpdateNotice() {
|
|
4806
|
+
const currentVersion = VERSION;
|
|
4807
|
+
if (currentVersion === "unknown") return null;
|
|
4808
|
+
try {
|
|
4809
|
+
const latestVersion = await resolveLatestVersion();
|
|
4810
|
+
if (!latestVersion) return null;
|
|
4811
|
+
if (compareVersions(currentVersion, latestVersion) < 0) {
|
|
4812
|
+
return {
|
|
4813
|
+
current: currentVersion,
|
|
4814
|
+
latest: latestVersion,
|
|
4815
|
+
behind: true,
|
|
4816
|
+
upgrade_command: UPGRADE_COMMAND
|
|
4817
|
+
};
|
|
4818
|
+
}
|
|
4819
|
+
} catch {
|
|
4820
|
+
}
|
|
4821
|
+
return null;
|
|
4822
|
+
}
|
|
4795
4823
|
|
|
4796
4824
|
// src/client.ts
|
|
4797
4825
|
var uuidSchema = external_exports.string().uuid();
|
|
@@ -6611,6 +6639,11 @@ W:${wsHint}
|
|
|
6611
6639
|
[/CTX]`;
|
|
6612
6640
|
candidateContext = context;
|
|
6613
6641
|
}
|
|
6642
|
+
let versionNotice = null;
|
|
6643
|
+
try {
|
|
6644
|
+
versionNotice = await getUpdateNotice();
|
|
6645
|
+
} catch {
|
|
6646
|
+
}
|
|
6614
6647
|
this.trackTokenSavings({
|
|
6615
6648
|
tool: "context_smart",
|
|
6616
6649
|
workspace_id: withDefaults.workspace_id,
|
|
@@ -6631,6 +6664,7 @@ W:${wsHint}
|
|
|
6631
6664
|
token_estimate: Math.ceil(context.length / 4),
|
|
6632
6665
|
format,
|
|
6633
6666
|
sources_used: items.filter((i) => context.includes(i.value.slice(0, 20))).length,
|
|
6667
|
+
...versionNotice ? { version_notice: versionNotice } : {},
|
|
6634
6668
|
...errors.length > 0 && { errors }
|
|
6635
6669
|
// Include errors for debugging
|
|
6636
6670
|
};
|
|
@@ -10180,8 +10214,10 @@ This saves ~80% tokens compared to including full chat history.`,
|
|
|
10180
10214
|
const footer = `
|
|
10181
10215
|
---
|
|
10182
10216
|
\u{1F3AF} ${result.sources_used} sources | ~${result.token_estimate} tokens | format: ${result.format}`;
|
|
10217
|
+
const versionNoticeLine = result.version_notice?.behind ? `
|
|
10218
|
+
[VERSION_NOTICE] current=${result.version_notice.current} latest=${result.version_notice.latest} upgrade="${result.version_notice.upgrade_command}"` : "";
|
|
10183
10219
|
return {
|
|
10184
|
-
content: [{ type: "text", text: result.context + footer }],
|
|
10220
|
+
content: [{ type: "text", text: result.context + footer + versionNoticeLine }],
|
|
10185
10221
|
structuredContent: toStructured(result)
|
|
10186
10222
|
};
|
|
10187
10223
|
}
|
package/package.json
CHANGED