@hvgllc/hvgerp-mcp 3.0.1 → 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.
Files changed (2) hide show
  1. package/hvgerp-mcp.mjs +74 -0
  2. package/package.json +1 -1
package/hvgerp-mcp.mjs CHANGED
@@ -49631,6 +49631,79 @@ function loadMrtrConfig() {
49631
49631
  return { signingKey };
49632
49632
  }
49633
49633
 
49634
+ // src/claude-code-stdio-compat.ts
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) {
49643
+ const hasTrailingNewline = line.endsWith("\n");
49644
+ const trimmed = hasTrailingNewline ? line.slice(0, -1) : line;
49645
+ let message2;
49646
+ try {
49647
+ message2 = JSON.parse(trimmed);
49648
+ } catch {
49649
+ return line;
49650
+ }
49651
+ if (!message2 || typeof message2 !== "object" || !("result" in message2)) {
49652
+ return line;
49653
+ }
49654
+ const result = message2.result;
49655
+ if (!result || typeof result !== "object" || Array.isArray(result) || "resultType" in result) {
49656
+ return line;
49657
+ }
49658
+ const record2 = result;
49659
+ record2.resultType = "complete";
49660
+ if (method && CACHE_HINT_METHODS.has(method)) {
49661
+ record2.ttlMs = cacheHints.ttlMs;
49662
+ record2.cacheScope = cacheHints.cacheScope;
49663
+ }
49664
+ return JSON.stringify(message2) + (hasTrailingNewline ? "\n" : "");
49665
+ }
49666
+ function installClaudeCodeStdioCompat(cacheHints) {
49667
+ const stdout = process.stdout;
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
+ });
49691
+ const originalWrite = stdout.write.bind(stdout);
49692
+ stdout.write = (chunk, ...rest) => {
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);
49704
+ };
49705
+ }
49706
+
49634
49707
  // server.ts
49635
49708
  var DEFAULT_HTTP_PORT = 3012;
49636
49709
  async function main() {
@@ -49755,6 +49828,7 @@ async function main() {
49755
49828
  }
49756
49829
  });
49757
49830
  } else {
49831
+ installClaudeCodeStdioCompat({ ttlMs: 36e5, cacheScope: "public" });
49758
49832
  await server.start();
49759
49833
  console.error("[hvgerp-mcp] stdio mode ready");
49760
49834
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hvgllc/hvgerp-mcp",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "MCP server for ERPNext with interactive UI viewers",
5
5
  "type": "module",
6
6
  "bin": {