@hvgllc/hvgerp-mcp 3.0.2 → 3.0.3
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/hvgerp-mcp.mjs +47 -11
- package/package.json +1 -1
package/hvgerp-mcp.mjs
CHANGED
|
@@ -49632,8 +49632,14 @@ function loadMrtrConfig() {
|
|
|
49632
49632
|
}
|
|
49633
49633
|
|
|
49634
49634
|
// src/claude-code-stdio-compat.ts
|
|
49635
|
-
var
|
|
49636
|
-
|
|
49635
|
+
var CACHE_HINT_METHODS = /* @__PURE__ */ new Set([
|
|
49636
|
+
"tools/list",
|
|
49637
|
+
"resources/list",
|
|
49638
|
+
"resources/templates/list",
|
|
49639
|
+
"resources/read",
|
|
49640
|
+
"prompts/list"
|
|
49641
|
+
]);
|
|
49642
|
+
function stampSpecFields(line, method, cacheHints) {
|
|
49637
49643
|
const hasTrailingNewline = line.endsWith("\n");
|
|
49638
49644
|
const trimmed = hasTrailingNewline ? line.slice(0, -1) : line;
|
|
49639
49645
|
let message2;
|
|
@@ -49650,22 +49656,52 @@ function stampMissingResultType(line) {
|
|
|
49650
49656
|
return line;
|
|
49651
49657
|
}
|
|
49652
49658
|
const record2 = result;
|
|
49653
|
-
const isListResult = LIST_RESULT_ARRAY_KEYS.some(
|
|
49654
|
-
(key) => Array.isArray(record2[key])
|
|
49655
|
-
);
|
|
49656
|
-
if (!isListResult) return line;
|
|
49657
49659
|
record2.resultType = "complete";
|
|
49660
|
+
if (method && CACHE_HINT_METHODS.has(method)) {
|
|
49661
|
+
record2.ttlMs = cacheHints.ttlMs;
|
|
49662
|
+
record2.cacheScope = cacheHints.cacheScope;
|
|
49663
|
+
}
|
|
49658
49664
|
return JSON.stringify(message2) + (hasTrailingNewline ? "\n" : "");
|
|
49659
49665
|
}
|
|
49660
|
-
function installClaudeCodeStdioCompat() {
|
|
49666
|
+
function installClaudeCodeStdioCompat(cacheHints) {
|
|
49661
49667
|
const stdout = process.stdout;
|
|
49662
49668
|
if (stdout.__claudeCodeStdioCompatInstalled) return;
|
|
49669
|
+
stdout.__claudeCodeStdioCompatInstalled = true;
|
|
49670
|
+
const pendingMethods = /* @__PURE__ */ new Map();
|
|
49671
|
+
let stdinBuffer = "";
|
|
49672
|
+
process.stdin.on("data", (chunk) => {
|
|
49673
|
+
stdinBuffer += String(chunk);
|
|
49674
|
+
let newlineIndex;
|
|
49675
|
+
while ((newlineIndex = stdinBuffer.indexOf("\n")) >= 0) {
|
|
49676
|
+
const requestLine = stdinBuffer.slice(0, newlineIndex);
|
|
49677
|
+
stdinBuffer = stdinBuffer.slice(newlineIndex + 1);
|
|
49678
|
+
if (!requestLine.trim()) continue;
|
|
49679
|
+
try {
|
|
49680
|
+
const request = JSON.parse(requestLine);
|
|
49681
|
+
if (request && typeof request === "object" && "id" in request && typeof request.method === "string") {
|
|
49682
|
+
pendingMethods.set(
|
|
49683
|
+
request.id,
|
|
49684
|
+
request.method
|
|
49685
|
+
);
|
|
49686
|
+
}
|
|
49687
|
+
} catch {
|
|
49688
|
+
}
|
|
49689
|
+
}
|
|
49690
|
+
});
|
|
49663
49691
|
const originalWrite = stdout.write.bind(stdout);
|
|
49664
49692
|
stdout.write = (chunk, ...rest) => {
|
|
49665
|
-
|
|
49666
|
-
|
|
49693
|
+
if (typeof chunk === "string") {
|
|
49694
|
+
let id;
|
|
49695
|
+
try {
|
|
49696
|
+
id = JSON.parse(chunk.endsWith("\n") ? chunk.slice(0, -1) : chunk)?.id;
|
|
49697
|
+
} catch {
|
|
49698
|
+
}
|
|
49699
|
+
const method = id === void 0 ? void 0 : pendingMethods.get(id);
|
|
49700
|
+
if (id !== void 0) pendingMethods.delete(id);
|
|
49701
|
+
chunk = stampSpecFields(chunk, method, cacheHints);
|
|
49702
|
+
}
|
|
49703
|
+
return originalWrite(chunk, ...rest);
|
|
49667
49704
|
};
|
|
49668
|
-
stdout.__claudeCodeStdioCompatInstalled = true;
|
|
49669
49705
|
}
|
|
49670
49706
|
|
|
49671
49707
|
// server.ts
|
|
@@ -49792,7 +49828,7 @@ async function main() {
|
|
|
49792
49828
|
}
|
|
49793
49829
|
});
|
|
49794
49830
|
} else {
|
|
49795
|
-
installClaudeCodeStdioCompat();
|
|
49831
|
+
installClaudeCodeStdioCompat({ ttlMs: 36e5, cacheScope: "public" });
|
|
49796
49832
|
await server.start();
|
|
49797
49833
|
console.error("[hvgerp-mcp] stdio mode ready");
|
|
49798
49834
|
}
|