@context-engine-bridge/context-engine-mcp-bridge 0.0.51 → 0.0.53
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 +22 -9
package/package.json
CHANGED
package/src/mcpServer.js
CHANGED
|
@@ -71,11 +71,6 @@ function _tryReadConnFile(connPath, now) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
function _readLspConnection(workspace) {
|
|
74
|
-
const envPort = process.env.CTXCE_LSP_PORT;
|
|
75
|
-
if (envPort && _isValidPort(envPort)) {
|
|
76
|
-
return { port: envPort, secret: process.env.CTXCE_LSP_SECRET || "" };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
74
|
const now = Date.now();
|
|
80
75
|
const cacheKey = workspace || "";
|
|
81
76
|
if (_lspConnCache.value !== undefined && (now - _lspConnCache.ts) < LSP_CONN_CACHE_TTL && _lspConnCache.key === cacheKey) {
|
|
@@ -91,6 +86,13 @@ function _readLspConnection(workspace) {
|
|
|
91
86
|
result = _tryReadConnFile(path.join(os.homedir(), ".ctxce", "lsp-connection.json"), now);
|
|
92
87
|
}
|
|
93
88
|
|
|
89
|
+
if (!result) {
|
|
90
|
+
const envPort = process.env.CTXCE_LSP_PORT;
|
|
91
|
+
if (envPort && _isValidPort(envPort)) {
|
|
92
|
+
result = { port: envPort, secret: process.env.CTXCE_LSP_SECRET || "" };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
94
96
|
_lspConnCache = { value: result, ts: now, key: cacheKey };
|
|
95
97
|
return result;
|
|
96
98
|
}
|
|
@@ -190,6 +192,13 @@ async function _enrichWithLsp(result, lspConn, workspace) {
|
|
|
190
192
|
const dest = target !== parsed ? target : parsed;
|
|
191
193
|
dest._lsp_status = await _resolveLspStatus(dest, target, lspConn, workspace);
|
|
192
194
|
textBlock.text = JSON.stringify(parsed);
|
|
195
|
+
if (result.structuredContent && typeof result.structuredContent === "object") {
|
|
196
|
+
const sc = result.structuredContent;
|
|
197
|
+
const scTarget = _lspTarget(sc);
|
|
198
|
+
const scDest = scTarget !== sc ? scTarget : sc;
|
|
199
|
+
scDest._lsp_status = dest._lsp_status;
|
|
200
|
+
if (dest._lsp) scDest._lsp = dest._lsp;
|
|
201
|
+
}
|
|
193
202
|
return result;
|
|
194
203
|
} catch (err) {
|
|
195
204
|
debugLog("[ctxce] LSP enrichment failed: " + String(err));
|
|
@@ -1310,25 +1319,29 @@ async function createBridgeServer(options) {
|
|
|
1310
1319
|
undefined,
|
|
1311
1320
|
{ timeout: timeoutMs },
|
|
1312
1321
|
);
|
|
1313
|
-
const finalResult = maybeRemapToolResult(name, result, workspace);
|
|
1314
1322
|
const lspConn = includeLsp && _readLspConnection(workspace);
|
|
1315
1323
|
if (includeLsp) {
|
|
1316
1324
|
debugLog("[ctxce] LSP gate: tool=" + name + " lsp=" + (lspConn ? "port:" + lspConn.port : "null"));
|
|
1317
1325
|
}
|
|
1318
1326
|
if (lspConn) {
|
|
1319
|
-
|
|
1327
|
+
result = await _enrichWithLsp(result, lspConn, workspace);
|
|
1320
1328
|
} else if (includeLsp) {
|
|
1321
1329
|
try {
|
|
1322
|
-
const tb = Array.isArray(
|
|
1330
|
+
const tb = Array.isArray(result?.content) && result.content.find(c => c.type === "text");
|
|
1323
1331
|
if (tb?.text) {
|
|
1324
1332
|
const p = JSON.parse(tb.text);
|
|
1325
1333
|
const d = _lspTarget(p);
|
|
1326
1334
|
(d !== p ? d : p)._lsp_status = "not_available";
|
|
1327
1335
|
tb.text = JSON.stringify(p);
|
|
1336
|
+
if (result.structuredContent && typeof result.structuredContent === "object") {
|
|
1337
|
+
const sc = result.structuredContent;
|
|
1338
|
+
const scD = _lspTarget(sc);
|
|
1339
|
+
(scD !== sc ? scD : sc)._lsp_status = "not_available";
|
|
1340
|
+
}
|
|
1328
1341
|
}
|
|
1329
1342
|
} catch (e) { debugLog("[ctxce] LSP not_available inject failed: " + String(e)); }
|
|
1330
1343
|
}
|
|
1331
|
-
return
|
|
1344
|
+
return maybeRemapToolResult(name, result, workspace);
|
|
1332
1345
|
} catch (err) {
|
|
1333
1346
|
lastError = err;
|
|
1334
1347
|
|