@wrongstack/mcp 0.296.4 → 0.297.0

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/index.js CHANGED
@@ -3570,6 +3570,7 @@ function scheduleRegistryReconnect({
3570
3570
 
3571
3571
  // src/wrap-tool.ts
3572
3572
  import { ToolCapabilities } from "@wrongstack/core/security";
3573
+ import { mcpQualifiedToolName } from "@wrongstack/core/utils";
3573
3574
  var MUTATING_RE = /create|update|delete|write|send|set|put|post|patch|remove|rename|move/i;
3574
3575
  function isMutatingTool(mcpTool) {
3575
3576
  if (MUTATING_RE.test(mcpTool.name)) return true;
@@ -3585,7 +3586,7 @@ function isMutatingTool(mcpTool) {
3585
3586
  return false;
3586
3587
  }
3587
3588
  function wrapMCPTool(serverName, mcpTool, client, permission = "confirm", observer) {
3588
- const qualifiedName = `mcp__${serverName}__${mcpTool.name}`;
3589
+ const qualifiedName = mcpQualifiedToolName(serverName, mcpTool.name);
3589
3590
  return {
3590
3591
  name: qualifiedName,
3591
3592
  description: mcpTool.description ?? `${qualifiedName} (MCP tool)`,
@@ -4635,6 +4636,7 @@ function serveStdio(server, opts = {}) {
4635
4636
  let closed = false;
4636
4637
  let bufferTooLarge = false;
4637
4638
  let writeChain = Promise.resolve();
4639
+ const inFlightHandlers = /* @__PURE__ */ new Set();
4638
4640
  const writeLine = (s) => {
4639
4641
  writeChain = writeChain.then(
4640
4642
  () => new Promise((resolve) => {
@@ -4681,7 +4683,7 @@ function serveStdio(server, opts = {}) {
4681
4683
  buffer = buffer.slice(idx + 1);
4682
4684
  idx = buffer.indexOf("\n");
4683
4685
  if (!line.trim()) continue;
4684
- void server.handleMessage(line).then((res) => {
4686
+ const handler = server.handleMessage(line).then((res) => {
4685
4687
  if (res !== null) writeLine(res);
4686
4688
  }).catch((err) => {
4687
4689
  console.error(
@@ -4692,13 +4694,16 @@ function serveStdio(server, opts = {}) {
4692
4694
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
4693
4695
  })
4694
4696
  );
4697
+ }).finally(() => {
4698
+ inFlightHandlers.delete(handler);
4695
4699
  });
4700
+ inFlightHandlers.add(handler);
4696
4701
  }
4697
4702
  };
4698
4703
  let resolveDone;
4699
4704
  const done = new Promise((resolve) => {
4700
4705
  resolveDone = () => {
4701
- void writeChain.then(() => resolve());
4706
+ void Promise.allSettled([...inFlightHandlers]).then(() => writeChain).then(() => resolve());
4702
4707
  };
4703
4708
  });
4704
4709
  const onEnd = () => {