@context-engine-bridge/context-engine-mcp-bridge 0.0.65 → 0.0.68

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/package.json +1 -1
  2. package/src/mcpServer.js +35 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@context-engine-bridge/context-engine-mcp-bridge",
3
- "version": "0.0.65",
3
+ "version": "0.0.68",
4
4
  "description": "Context Engine MCP bridge (http/stdio proxy combining indexer + memory servers)",
5
5
  "bin": {
6
6
  "ctxce": "bin/ctxce.js",
package/src/mcpServer.js CHANGED
@@ -1292,7 +1292,8 @@ async function createBridgeServer(options) {
1292
1292
  if (shouldFanOut) {
1293
1293
  const fanOutCallTimeoutMs = Math.min(timeoutMs, 10000);
1294
1294
  const fanOutDeadlineMs = Math.round(fanOutCallTimeoutMs * 0.8);
1295
- const fanOutPromises = additionalCollections.map(col => {
1295
+ const allFanOutCollections = [defaultCollection || primaryCollection, ...additionalCollections].filter(Boolean);
1296
+ const fanOutPromises = allFanOutCollections.map(col => {
1296
1297
  const colArgs = { ...args, collection: col, output_format: "json", compact: false };
1297
1298
  return targetClient.callTool(
1298
1299
  { name, arguments: colArgs },
@@ -1883,22 +1884,33 @@ function _mergeResults(primaryText, additionalTexts) {
1883
1884
  for (const addText of additionalTexts) {
1884
1885
  try {
1885
1886
  const additional = JSON.parse(addText);
1886
- if (!additional || !additional.ok) continue;
1887
+ if (!additional || !additional.ok) {
1888
+ primary._merge_skip = { ok: additional?.ok, keys: additional ? Object.keys(additional).slice(0, 10) : [] };
1889
+ continue;
1890
+ }
1887
1891
 
1888
1892
  const aInner = _unwrapSearchEnvelope(additional);
1889
1893
  const pResults = _getResultsArray(pInner);
1890
1894
  const aResults = _getResultsArray(aInner);
1891
1895
  if (pResults && aResults) {
1896
+ primary._merge_branch = "both_arrays";
1897
+ const beforeLen = pResults.length;
1892
1898
  const existingPaths = new Set(
1893
1899
  pResults.map(r => `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`)
1894
1900
  );
1901
+ let added = 0;
1895
1902
  for (const r of aResults) {
1896
1903
  const key = `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`;
1897
1904
  if (!existingPaths.has(key)) {
1898
1905
  pResults.push(r);
1899
1906
  existingPaths.add(key);
1907
+ added++;
1900
1908
  }
1901
1909
  }
1910
+ primary._merge_added = added;
1911
+ primary._merge_pre_sort = pResults.length;
1912
+ primary._merge_before_len = beforeLen;
1913
+ primary._merge_a_len = aResults.length;
1902
1914
  if (Array.isArray(pInner.results_json)) {
1903
1915
  pInner.results_json = pResults;
1904
1916
  } else if (Array.isArray(pInner.results)) {
@@ -1906,6 +1918,14 @@ function _mergeResults(primaryText, additionalTexts) {
1906
1918
  } else {
1907
1919
  pInner.results_json = pResults;
1908
1920
  }
1921
+ } else if (!pResults && aResults) {
1922
+ primary._merge_branch = "only_additional";
1923
+ primary._merge_added = aResults.length;
1924
+ pInner.results_json = [...aResults];
1925
+ } else {
1926
+ primary._merge_branch = "no_merge";
1927
+ primary._merge_p_type = pResults ? "array" : typeof pInner.results;
1928
+ primary._merge_a_type = aResults ? "array" : typeof aInner.results;
1909
1929
  }
1910
1930
 
1911
1931
  if (typeof pInner.total === "number" && typeof aInner.total === "number") {
@@ -1916,7 +1936,9 @@ function _mergeResults(primaryText, additionalTexts) {
1916
1936
  const arr = _getResultsArray(pInner);
1917
1937
  pInner.count = Array.isArray(arr) ? arr.length : pInner.count + aInner.count;
1918
1938
  }
1919
- } catch (_) {}
1939
+ } catch (mergeErr) {
1940
+ primary._merge_error = String(mergeErr);
1941
+ }
1920
1942
  }
1921
1943
 
1922
1944
  const resultsArr = _getResultsArray(pInner);
@@ -1937,20 +1959,18 @@ function _mergeResults(primaryText, additionalTexts) {
1937
1959
  }
1938
1960
 
1939
1961
  primary._cross_collection = true;
1940
- const _aFirst = additionalTexts.length > 0 ? (() => { try { const a = JSON.parse(additionalTexts[0]); const ai = _unwrapSearchEnvelope(a); return { keys: Object.keys(ai), results_type: typeof ai.results, results_json_type: typeof ai.results_json, results_is_array: Array.isArray(ai.results), results_json_is_array: Array.isArray(ai.results_json) }; } catch(_) { return "parse_error"; } })() : null;
1962
+ const finalArr = _getResultsArray(pInner);
1941
1963
  primary._fanout_debug = {
1942
- additional_texts_count: additionalTexts.length,
1943
- additional_ok_count: additionalTexts.filter(t => { try { return JSON.parse(t).ok; } catch(_) { return false; } }).length,
1944
- final_results_count: Array.isArray(resultsArr) ? resultsArr.length : 0,
1945
- original_limit: originalLimit || null,
1946
- envelope: pInner !== primary,
1947
- p_inner_keys: Object.keys(pInner),
1948
- p_results_type: typeof pInner.results,
1949
- p_results_json_type: typeof pInner.results_json,
1950
- p_results_is_array: Array.isArray(pInner.results),
1951
- p_results_json_is_array: Array.isArray(pInner.results_json),
1952
- a_first: _aFirst,
1964
+ additional_count: additionalTexts.length,
1965
+ merged_count: Array.isArray(finalArr) ? finalArr.length : 0,
1966
+ branch: primary._merge_branch || "none",
1967
+ added: primary._merge_added || 0,
1953
1968
  };
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
+ delete primary._merge_branch; delete primary._merge_added; delete primary._merge_pre_sort;
1972
+ delete primary._merge_before_len; delete primary._merge_a_len; delete primary._merge_error;
1973
+ delete primary._merge_skip; delete primary._merge_p_type; delete primary._merge_a_type;
1954
1974
  return JSON.stringify(primary);
1955
1975
  } catch (_) {
1956
1976
  return primaryText;