@context-engine-bridge/context-engine-mcp-bridge 0.0.35 → 0.0.37
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 +16 -9
package/package.json
CHANGED
package/src/mcpServer.js
CHANGED
|
@@ -171,6 +171,11 @@ function _callLspHandler(port, secret, operation, params) {
|
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
function _lspTarget(parsed) {
|
|
175
|
+
const r = parsed.result;
|
|
176
|
+
return r && typeof r === "object" && !Array.isArray(r) ? r : parsed;
|
|
177
|
+
}
|
|
178
|
+
|
|
174
179
|
async function _enrichWithLsp(result, lspConn, workspace) {
|
|
175
180
|
try {
|
|
176
181
|
debugLog("[ctxce] LSP enrich: workspace=" + workspace + " port=" + lspConn?.port);
|
|
@@ -183,7 +188,8 @@ async function _enrichWithLsp(result, lspConn, workspace) {
|
|
|
183
188
|
return result;
|
|
184
189
|
}
|
|
185
190
|
if (!parsed.ok) return result;
|
|
186
|
-
|
|
191
|
+
const target = _lspTarget(parsed);
|
|
192
|
+
target._lsp_status = await _resolveLspStatus(target, lspConn, workspace);
|
|
187
193
|
textBlock.text = JSON.stringify(parsed);
|
|
188
194
|
return result;
|
|
189
195
|
} catch (err) {
|
|
@@ -193,10 +199,10 @@ async function _enrichWithLsp(result, lspConn, workspace) {
|
|
|
193
199
|
}
|
|
194
200
|
}
|
|
195
201
|
|
|
196
|
-
async function _resolveLspStatus(
|
|
202
|
+
async function _resolveLspStatus(target, lspConn, workspace) {
|
|
197
203
|
if (_lspCircuitOpen()) return "circuit_open";
|
|
198
204
|
const paths = new Set();
|
|
199
|
-
_extractPaths(
|
|
205
|
+
_extractPaths(target, paths, workspace);
|
|
200
206
|
if (paths.size === 0) return "no_paths";
|
|
201
207
|
const diag = await _callLspHandler(lspConn.port, lspConn.secret, "diagnostics_recent", { paths: [...paths] });
|
|
202
208
|
if (!diag) {
|
|
@@ -205,7 +211,7 @@ async function _resolveLspStatus(parsed, lspConn, workspace) {
|
|
|
205
211
|
}
|
|
206
212
|
_lspCircuitRecordSuccess();
|
|
207
213
|
if (!diag.ok || !diag.files || diag.total === 0) return "no_diagnostics";
|
|
208
|
-
|
|
214
|
+
target._lsp = { diagnostics: diag.files, total: diag.total };
|
|
209
215
|
return "ok";
|
|
210
216
|
}
|
|
211
217
|
|
|
@@ -1286,23 +1292,24 @@ async function createBridgeServer(options) {
|
|
|
1286
1292
|
undefined,
|
|
1287
1293
|
{ timeout: timeoutMs },
|
|
1288
1294
|
);
|
|
1289
|
-
let finalResult = maybeRemapToolResult(name, result, workspace);
|
|
1290
1295
|
const lspConn = includeLsp && _readLspConnection(workspace);
|
|
1291
1296
|
if (includeLsp) {
|
|
1292
1297
|
debugLog("[ctxce] LSP gate: tool=" + name + " lsp=" + (lspConn ? "port:" + lspConn.port : "null"));
|
|
1293
1298
|
}
|
|
1294
1299
|
if (lspConn) {
|
|
1295
|
-
|
|
1300
|
+
result = await _enrichWithLsp(result, lspConn, workspace);
|
|
1296
1301
|
} else if (includeLsp) {
|
|
1297
1302
|
try {
|
|
1298
|
-
const tb = Array.isArray(
|
|
1303
|
+
const tb = Array.isArray(result?.content) && result.content.find(c => c.type === "text");
|
|
1299
1304
|
if (tb?.text) {
|
|
1300
1305
|
const p = JSON.parse(tb.text);
|
|
1301
|
-
|
|
1306
|
+
const t = _lspTarget(p);
|
|
1307
|
+
t._lsp_status = "not_available";
|
|
1302
1308
|
tb.text = JSON.stringify(p);
|
|
1303
1309
|
}
|
|
1304
|
-
} catch (
|
|
1310
|
+
} catch (e) { debugLog("[ctxce] LSP not_available inject failed: " + String(e)); }
|
|
1305
1311
|
}
|
|
1312
|
+
const finalResult = maybeRemapToolResult(name, result, workspace);
|
|
1306
1313
|
return finalResult;
|
|
1307
1314
|
} catch (err) {
|
|
1308
1315
|
lastError = err;
|