oscar64-mcp-docs 1.0.3 → 1.0.5
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/dist/stdio.js +74 -8
- package/package.json +1 -1
package/dist/stdio.js
CHANGED
|
@@ -1443,13 +1443,42 @@ async function initState(forceRefresh = false) {
|
|
|
1443
1443
|
|
|
1444
1444
|
// src/mcp/tools/state-snapshot.ts
|
|
1445
1445
|
var inFlight = null;
|
|
1446
|
-
|
|
1446
|
+
var latestState = null;
|
|
1447
|
+
var StateUnavailableError = class extends Error {
|
|
1448
|
+
constructor(message, cause) {
|
|
1449
|
+
super(message);
|
|
1450
|
+
this.name = "StateUnavailableError";
|
|
1451
|
+
if (cause !== void 0) {
|
|
1452
|
+
this.cause = cause;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
function isStateUnavailableError(error) {
|
|
1457
|
+
return error instanceof StateUnavailableError;
|
|
1458
|
+
}
|
|
1459
|
+
function getStateSnapshotSync() {
|
|
1460
|
+
return latestState;
|
|
1461
|
+
}
|
|
1462
|
+
async function refreshStateSnapshot(forceRefresh = false) {
|
|
1447
1463
|
if (inFlight) return inFlight;
|
|
1448
|
-
inFlight =
|
|
1464
|
+
inFlight = (async () => {
|
|
1465
|
+
try {
|
|
1466
|
+
const state = await initState(forceRefresh);
|
|
1467
|
+
latestState = state;
|
|
1468
|
+
return state;
|
|
1469
|
+
} catch (error) {
|
|
1470
|
+
if (latestState) return latestState;
|
|
1471
|
+
throw new StateUnavailableError("Oscar64 source state unavailable.", error);
|
|
1472
|
+
}
|
|
1473
|
+
})().finally(() => {
|
|
1449
1474
|
inFlight = null;
|
|
1450
1475
|
});
|
|
1451
1476
|
return inFlight;
|
|
1452
1477
|
}
|
|
1478
|
+
async function getStateSnapshot() {
|
|
1479
|
+
if (latestState) return latestState;
|
|
1480
|
+
return refreshStateSnapshot(false);
|
|
1481
|
+
}
|
|
1453
1482
|
|
|
1454
1483
|
// src/mcp/tools/list-indexes.tool.ts
|
|
1455
1484
|
async function executeListIndexes(context) {
|
|
@@ -1535,7 +1564,18 @@ var listIndexesTool = createTool({
|
|
|
1535
1564
|
execute: async ({ context }) => {
|
|
1536
1565
|
try {
|
|
1537
1566
|
return await executeListIndexes(context);
|
|
1538
|
-
} catch {
|
|
1567
|
+
} catch (error) {
|
|
1568
|
+
if (isStateUnavailableError(error)) {
|
|
1569
|
+
return {
|
|
1570
|
+
ok: false,
|
|
1571
|
+
error: {
|
|
1572
|
+
code: "OFFLINE",
|
|
1573
|
+
message: "list_indexes unavailable while sources are offline.",
|
|
1574
|
+
hint: "Ensure network access to GitHub or warm cache under ~/.cache/oscar-mcp, then retry.",
|
|
1575
|
+
recoverable: true
|
|
1576
|
+
}
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1539
1579
|
return {
|
|
1540
1580
|
ok: false,
|
|
1541
1581
|
error: {
|
|
@@ -1684,7 +1724,18 @@ var readUriTool = createTool2({
|
|
|
1684
1724
|
execute: async ({ context }) => {
|
|
1685
1725
|
try {
|
|
1686
1726
|
return await executeReadUri(context);
|
|
1687
|
-
} catch {
|
|
1727
|
+
} catch (error) {
|
|
1728
|
+
if (isStateUnavailableError(error)) {
|
|
1729
|
+
return {
|
|
1730
|
+
ok: false,
|
|
1731
|
+
error: {
|
|
1732
|
+
code: "OFFLINE",
|
|
1733
|
+
message: "read_uri unavailable while sources are offline.",
|
|
1734
|
+
hint: "Ensure network access to GitHub or warm cache under ~/.cache/oscar-mcp, then retry.",
|
|
1735
|
+
recoverable: true
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1688
1739
|
return {
|
|
1689
1740
|
ok: false,
|
|
1690
1741
|
error: {
|
|
@@ -2089,7 +2140,18 @@ var searchTool = createTool3({
|
|
|
2089
2140
|
execute: async ({ context }) => {
|
|
2090
2141
|
try {
|
|
2091
2142
|
return await executeSearch(context);
|
|
2092
|
-
} catch {
|
|
2143
|
+
} catch (error) {
|
|
2144
|
+
if (isStateUnavailableError(error)) {
|
|
2145
|
+
return {
|
|
2146
|
+
ok: false,
|
|
2147
|
+
error: {
|
|
2148
|
+
code: "OFFLINE",
|
|
2149
|
+
message: "Search unavailable while sources are offline.",
|
|
2150
|
+
hint: "Ensure network access to GitHub or warm cache under ~/.cache/oscar-mcp, then retry.",
|
|
2151
|
+
recoverable: true
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
2154
|
+
}
|
|
2093
2155
|
return {
|
|
2094
2156
|
ok: false,
|
|
2095
2157
|
error: {
|
|
@@ -2123,10 +2185,14 @@ var PACKAGE_VERSION = (() => {
|
|
|
2123
2185
|
return "0.0.0";
|
|
2124
2186
|
})();
|
|
2125
2187
|
async function createOscarMcpServer(initialForceRefresh = false) {
|
|
2126
|
-
|
|
2127
|
-
const getState = () =>
|
|
2188
|
+
await refreshStateSnapshot(initialForceRefresh);
|
|
2189
|
+
const getState = () => {
|
|
2190
|
+
const state = getStateSnapshotSync();
|
|
2191
|
+
if (!state) throw new Error("Oscar64 state not initialized.");
|
|
2192
|
+
return state;
|
|
2193
|
+
};
|
|
2128
2194
|
const refreshState = async (force = false) => {
|
|
2129
|
-
|
|
2195
|
+
await refreshStateSnapshot(force);
|
|
2130
2196
|
};
|
|
2131
2197
|
let refreshInFlight = null;
|
|
2132
2198
|
const scheduleRefresh = () => {
|