@wrongstack/mcp 1.0.17 → 1.0.19

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/dist/index.js +19 -9
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1331,7 +1331,6 @@ var SSEReader = class {
1331
1331
  // src/transport-base.ts
1332
1332
  import * as https2 from "node:https";
1333
1333
  import { ConfigError as ConfigError2 } from "@wrongstack/core/types";
1334
- import { Agent as UndiciAgent, fetch as undiciFetch } from "undici";
1335
1334
 
1336
1335
  // src/transport-security.ts
1337
1336
  import * as dns2 from "node:dns/promises";
@@ -1491,6 +1490,14 @@ function transportPinnedLookup(options) {
1491
1490
  // src/transport-base.ts
1492
1491
  var MAX_TRANSPORT_REDIRECTS = 5;
1493
1492
  var nativeGlobalFetch = globalThis.fetch;
1493
+ var undiciModule;
1494
+ var undiciLoad;
1495
+ async function ensureUndici() {
1496
+ if (undiciModule) return undiciModule;
1497
+ undiciLoad ??= import("undici");
1498
+ undiciModule = await undiciLoad;
1499
+ return undiciModule;
1500
+ }
1494
1501
  var pinnedAgents = /* @__PURE__ */ new Set();
1495
1502
  var pinnedAgentsCleanupRegistered = false;
1496
1503
  if (!pinnedAgentsCleanupRegistered) {
@@ -1608,8 +1615,8 @@ var BaseHTTPTransport = class {
1608
1615
  let hopHeaders = headers;
1609
1616
  for (let hop = 0; hop < MAX_TRANSPORT_REDIRECTS; hop++) {
1610
1617
  const fetchOpts = { ...init, headers: hopHeaders, redirect: "manual" };
1611
- this.applyPinnedDispatcher(fetchOpts);
1612
- const res = await this.dispatcherFetch()(currentUrl, fetchOpts);
1618
+ await this.applyPinnedDispatcher(fetchOpts);
1619
+ const res = await (await this.dispatcherFetch())(currentUrl, fetchOpts);
1613
1620
  if (res.status !== 301 && res.status !== 302 && res.status !== 303 && res.status !== 307 && res.status !== 308) {
1614
1621
  return res;
1615
1622
  }
@@ -1704,13 +1711,16 @@ var BaseHTTPTransport = class {
1704
1711
  }
1705
1712
  }
1706
1713
  }
1707
- dispatcherFetch() {
1708
- return globalThis.fetch === nativeGlobalFetch ? undiciFetch : globalThis.fetch;
1714
+ async dispatcherFetch() {
1715
+ if (globalThis.fetch !== nativeGlobalFetch) return globalThis.fetch;
1716
+ const undici = await ensureUndici();
1717
+ return undici.fetch;
1709
1718
  }
1710
- pinnedDispatcher() {
1719
+ async pinnedDispatcher() {
1720
+ const undici = await ensureUndici();
1711
1721
  if (!this.pinnedAgent) {
1712
1722
  const tls = this.tlsOptions;
1713
- this.pinnedAgent = new UndiciAgent({
1723
+ this.pinnedAgent = new undici.Agent({
1714
1724
  allowH2: false,
1715
1725
  connect: {
1716
1726
  ...tls ? { ca: tls.ca, rejectUnauthorized: tls.rejectUnauthorized } : {},
@@ -1724,8 +1734,8 @@ var BaseHTTPTransport = class {
1724
1734
  }
1725
1735
  return this.pinnedAgent;
1726
1736
  }
1727
- applyPinnedDispatcher(fetchOpts) {
1728
- fetchOpts.dispatcher = this.pinnedDispatcher();
1737
+ async applyPinnedDispatcher(fetchOpts) {
1738
+ fetchOpts.dispatcher = await this.pinnedDispatcher();
1729
1739
  }
1730
1740
  /**
1731
1741
  * Destroy this transport's pinned Agent and its connection pool. Idempotent.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/mcp",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "license": "MIT",
5
5
  "description": "WrongStack Model Context Protocol client and registry: stdio, SSE, and streamable HTTP transports.",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  "!dist/**/*.map"
27
27
  ],
28
28
  "dependencies": {
29
- "@wrongstack/core": "1.0.17",
29
+ "@wrongstack/core": "1.0.19",
30
30
  "undici": "^8.10.2"
31
31
  },
32
32
  "devDependencies": {