@context-engine-bridge/context-engine-mcp-bridge 0.0.58 → 0.0.60

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 +37 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@context-engine-bridge/context-engine-mcp-bridge",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
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
@@ -1257,8 +1257,9 @@ async function createBridgeServer(options) {
1257
1257
  : [];
1258
1258
  const shouldFanOut = additionalCollections.length > 0 && indexerClient;
1259
1259
 
1260
+ debugLog(`[ctxce] Fan-out check: tool=${name}, inFanoutSet=${_FANOUT_TOOLS.has(name)}, workspace=${workspace}, hint=${fanOutCollectionHint}, additional=[${additionalCollections.join(",")}], shouldFanOut=${shouldFanOut}`);
1260
1261
  if (shouldFanOut) {
1261
- debugLog(`[ctxce] Fan-out: ${name} across ${additionalCollections.length} additional collection(s)`);
1262
+ debugLog(`[ctxce] Fan-out: ${name} across ${additionalCollections.length} additional collection(s): ${additionalCollections.join(", ")}`);
1262
1263
  }
1263
1264
 
1264
1265
  const timeoutMs = getBridgeToolTimeoutMs();
@@ -1868,40 +1869,63 @@ function _mergeResults(primaryText, additionalTexts) {
1868
1869
  const additional = JSON.parse(addText);
1869
1870
  if (!additional || !additional.ok) continue;
1870
1871
 
1871
- if (Array.isArray(primary.results) && Array.isArray(additional.results)) {
1872
+ const pResults = Array.isArray(primary.results) ? primary.results : (Array.isArray(primary.results_json) ? primary.results_json : null);
1873
+ const aResults = Array.isArray(additional.results) ? additional.results : (Array.isArray(additional.results_json) ? additional.results_json : null);
1874
+ if (pResults && aResults) {
1875
+ if (!Array.isArray(primary.results)) {
1876
+ primary.results_json = pResults;
1877
+ }
1872
1878
  const existingPaths = new Set(
1873
- primary.results.map(r => `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`)
1879
+ pResults.map(r => `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`)
1874
1880
  );
1875
- for (const r of additional.results) {
1881
+ for (const r of aResults) {
1876
1882
  const key = `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`;
1877
1883
  if (!existingPaths.has(key)) {
1878
- primary.results.push(r);
1884
+ pResults.push(r);
1879
1885
  existingPaths.add(key);
1880
1886
  }
1881
1887
  }
1888
+ if (!Array.isArray(primary.results)) {
1889
+ primary.results_json = pResults;
1890
+ } else {
1891
+ primary.results = pResults;
1892
+ }
1882
1893
  }
1883
1894
 
1895
+ const mergedArr = Array.isArray(primary.results) ? primary.results : primary.results_json;
1884
1896
  if (typeof primary.total === "number" && typeof additional.total === "number") {
1885
- primary.total = primary.results ? primary.results.length : primary.total + additional.total;
1897
+ primary.total = Array.isArray(mergedArr) ? mergedArr.length : primary.total + additional.total;
1886
1898
  }
1887
1899
  if (typeof primary.count === "number" && typeof additional.count === "number") {
1888
- primary.count = primary.results ? primary.results.length : primary.count + additional.count;
1900
+ primary.count = Array.isArray(mergedArr) ? mergedArr.length : primary.count + additional.count;
1889
1901
  }
1890
1902
  } catch (_) {}
1891
1903
  }
1892
1904
 
1893
- if (Array.isArray(primary.results) && primary.results.length > 1) {
1894
- primary.results.sort((a, b) => (b.score || 0) - (a.score || 0));
1905
+ const resultsArr = Array.isArray(primary.results) ? primary.results : primary.results_json;
1906
+ if (Array.isArray(resultsArr) && resultsArr.length > 1) {
1907
+ resultsArr.sort((a, b) => (b.score || 0) - (a.score || 0));
1895
1908
  }
1896
1909
 
1897
1910
  const originalLimit = primary._original_limit;
1898
- if (originalLimit && Array.isArray(primary.results) && primary.results.length > originalLimit) {
1899
- primary.results = primary.results.slice(0, originalLimit);
1900
- if (typeof primary.total === "number") primary.total = primary.results.length;
1901
- if (typeof primary.count === "number") primary.count = primary.results.length;
1911
+ if (originalLimit && Array.isArray(resultsArr) && resultsArr.length > originalLimit) {
1912
+ const sliced = resultsArr.slice(0, originalLimit);
1913
+ if (Array.isArray(primary.results)) {
1914
+ primary.results = sliced;
1915
+ } else {
1916
+ primary.results_json = sliced;
1917
+ }
1918
+ if (typeof primary.total === "number") primary.total = sliced.length;
1919
+ if (typeof primary.count === "number") primary.count = sliced.length;
1902
1920
  }
1903
1921
 
1904
1922
  primary._cross_collection = true;
1923
+ primary._fanout_debug = {
1924
+ additional_texts_count: additionalTexts.length,
1925
+ additional_ok_count: additionalTexts.filter(t => { try { return JSON.parse(t).ok; } catch(_) { return false; } }).length,
1926
+ final_results_count: Array.isArray(resultsArr) ? resultsArr.length : 0,
1927
+ original_limit: originalLimit || null,
1928
+ };
1905
1929
  return JSON.stringify(primary);
1906
1930
  } catch (_) {
1907
1931
  return primaryText;