@context-engine-bridge/context-engine-mcp-bridge 0.0.68 → 0.0.70
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/package.json +1 -1
- package/src/mcpServer.js +27 -28
package/package.json
CHANGED
package/src/mcpServer.js
CHANGED
|
@@ -717,12 +717,12 @@ async function createBridgeServer(options) {
|
|
|
717
717
|
const explicitCollection = options.collection;
|
|
718
718
|
|
|
719
719
|
const config = loadConfig(workspace);
|
|
720
|
+
const configCollection = config && typeof config.default_collection === "string"
|
|
721
|
+
? config.default_collection : null;
|
|
720
722
|
const defaultCollection =
|
|
721
723
|
explicitCollection && typeof explicitCollection === "string"
|
|
722
724
|
? explicitCollection
|
|
723
|
-
:
|
|
724
|
-
? config.default_collection
|
|
725
|
-
: null;
|
|
725
|
+
: configCollection;
|
|
726
726
|
const defaultMode =
|
|
727
727
|
config && typeof config.default_mode === "string" ? config.default_mode : null;
|
|
728
728
|
const defaultUnder =
|
|
@@ -1262,6 +1262,10 @@ async function createBridgeServer(options) {
|
|
|
1262
1262
|
debugLog(`[ctxce] Fan-out: ${name} across ${additionalCollections.length} additional collection(s): ${additionalCollections.join(", ")}`);
|
|
1263
1263
|
}
|
|
1264
1264
|
|
|
1265
|
+
if (shouldFanOut && args && typeof args === "object") {
|
|
1266
|
+
args = { ...args, output_format: "json", compact: false };
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1265
1269
|
const timeoutMs = getBridgeToolTimeoutMs();
|
|
1266
1270
|
const maxAttempts = getBridgeRetryAttempts();
|
|
1267
1271
|
const retryDelayMs = getBridgeRetryDelayMs();
|
|
@@ -1292,11 +1296,13 @@ async function createBridgeServer(options) {
|
|
|
1292
1296
|
if (shouldFanOut) {
|
|
1293
1297
|
const fanOutCallTimeoutMs = Math.min(timeoutMs, 10000);
|
|
1294
1298
|
const fanOutDeadlineMs = Math.round(fanOutCallTimeoutMs * 0.8);
|
|
1295
|
-
const allFanOutCollections = [
|
|
1299
|
+
const allFanOutCollections = [...additionalCollections].filter(Boolean);
|
|
1296
1300
|
const fanOutPromises = allFanOutCollections.map(col => {
|
|
1297
|
-
const
|
|
1301
|
+
const fanOutToolName = (name === "search" || name === "context_search") ? "repo_search" : name;
|
|
1302
|
+
const { session: _s, ...argsNoSession } = (args && typeof args === "object") ? args : {};
|
|
1303
|
+
const colArgs = { ...argsNoSession, collection: col, output_format: "json", compact: false };
|
|
1298
1304
|
return targetClient.callTool(
|
|
1299
|
-
{ name, arguments: colArgs },
|
|
1305
|
+
{ name: fanOutToolName, arguments: colArgs },
|
|
1300
1306
|
undefined,
|
|
1301
1307
|
{ timeout: fanOutCallTimeoutMs },
|
|
1302
1308
|
).catch(err => {
|
|
@@ -1881,11 +1887,13 @@ function _mergeResults(primaryText, additionalTexts) {
|
|
|
1881
1887
|
|
|
1882
1888
|
const pInner = _unwrapSearchEnvelope(primary);
|
|
1883
1889
|
|
|
1890
|
+
const _perCall = [];
|
|
1891
|
+
let _totalAdded = 0;
|
|
1884
1892
|
for (const addText of additionalTexts) {
|
|
1885
1893
|
try {
|
|
1886
1894
|
const additional = JSON.parse(addText);
|
|
1887
1895
|
if (!additional || !additional.ok) {
|
|
1888
|
-
|
|
1896
|
+
_perCall.push({ ok: false, error: additional?.error || "not ok" });
|
|
1889
1897
|
continue;
|
|
1890
1898
|
}
|
|
1891
1899
|
|
|
@@ -1907,10 +1915,8 @@ function _mergeResults(primaryText, additionalTexts) {
|
|
|
1907
1915
|
added++;
|
|
1908
1916
|
}
|
|
1909
1917
|
}
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
primary._merge_before_len = beforeLen;
|
|
1913
|
-
primary._merge_a_len = aResults.length;
|
|
1918
|
+
_totalAdded += added;
|
|
1919
|
+
_perCall.push({ ok: true, a_len: aResults.length, added, before: beforeLen, after: pResults.length });
|
|
1914
1920
|
if (Array.isArray(pInner.results_json)) {
|
|
1915
1921
|
pInner.results_json = pResults;
|
|
1916
1922
|
} else if (Array.isArray(pInner.results)) {
|
|
@@ -1920,12 +1926,12 @@ function _mergeResults(primaryText, additionalTexts) {
|
|
|
1920
1926
|
}
|
|
1921
1927
|
} else if (!pResults && aResults) {
|
|
1922
1928
|
primary._merge_branch = "only_additional";
|
|
1923
|
-
|
|
1929
|
+
_totalAdded += aResults.length;
|
|
1930
|
+
_perCall.push({ ok: true, a_len: aResults.length, added: aResults.length, branch: "only_additional" });
|
|
1924
1931
|
pInner.results_json = [...aResults];
|
|
1925
1932
|
} else {
|
|
1926
1933
|
primary._merge_branch = "no_merge";
|
|
1927
|
-
|
|
1928
|
-
primary._merge_a_type = aResults ? "array" : typeof aInner.results;
|
|
1934
|
+
_perCall.push({ ok: true, branch: "no_merge", p_type: pResults ? "array" : typeof pInner.results, a_type: aResults ? "array" : typeof aInner.results });
|
|
1929
1935
|
}
|
|
1930
1936
|
|
|
1931
1937
|
if (typeof pInner.total === "number" && typeof aInner.total === "number") {
|
|
@@ -1945,17 +1951,11 @@ function _mergeResults(primaryText, additionalTexts) {
|
|
|
1945
1951
|
if (Array.isArray(resultsArr) && resultsArr.length > 1) {
|
|
1946
1952
|
resultsArr.sort((a, b) => (b.score || 0) - (a.score || 0));
|
|
1947
1953
|
}
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
pInner.results_json = sliced;
|
|
1954
|
-
} else {
|
|
1955
|
-
pInner.results = sliced;
|
|
1956
|
-
}
|
|
1957
|
-
if (typeof pInner.total === "number") pInner.total = sliced.length;
|
|
1958
|
-
if (typeof pInner.count === "number") pInner.count = sliced.length;
|
|
1954
|
+
if (typeof pInner.total === "number" && Array.isArray(resultsArr)) {
|
|
1955
|
+
pInner.total = resultsArr.length;
|
|
1956
|
+
}
|
|
1957
|
+
if (typeof pInner.count === "number" && Array.isArray(resultsArr)) {
|
|
1958
|
+
pInner.count = resultsArr.length;
|
|
1959
1959
|
}
|
|
1960
1960
|
|
|
1961
1961
|
primary._cross_collection = true;
|
|
@@ -1963,11 +1963,10 @@ function _mergeResults(primaryText, additionalTexts) {
|
|
|
1963
1963
|
primary._fanout_debug = {
|
|
1964
1964
|
additional_count: additionalTexts.length,
|
|
1965
1965
|
merged_count: Array.isArray(finalArr) ? finalArr.length : 0,
|
|
1966
|
-
|
|
1967
|
-
|
|
1966
|
+
total_added: _totalAdded,
|
|
1967
|
+
per_call: _perCall,
|
|
1968
1968
|
};
|
|
1969
1969
|
if (primary._merge_error) primary._fanout_debug.error = primary._merge_error;
|
|
1970
|
-
if (primary._merge_skip) primary._fanout_debug.skip = primary._merge_skip;
|
|
1971
1970
|
delete primary._merge_branch; delete primary._merge_added; delete primary._merge_pre_sort;
|
|
1972
1971
|
delete primary._merge_before_len; delete primary._merge_a_len; delete primary._merge_error;
|
|
1973
1972
|
delete primary._merge_skip; delete primary._merge_p_type; delete primary._merge_a_type;
|