@tronsfey/ucli 0.4.0 → 0.4.1

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.
@@ -36660,10 +36660,12 @@ var require_streamableHttp = __commonJS({
36660
36660
  }
36661
36661
  });
36662
36662
 
36663
- // ../../node_modules/.pnpm/@tronsfey+mcp2cli@1.0.0_zod@4.3.6/node_modules/@tronsfey/mcp2cli/dist/client/index.js
36663
+ // ../../node_modules/.pnpm/@tronsfey+mcp2cli@1.0.1_zod@4.3.6/node_modules/@tronsfey/mcp2cli/dist/client/index.js
36664
36664
  var require_client3 = __commonJS({
36665
- "../../node_modules/.pnpm/@tronsfey+mcp2cli@1.0.0_zod@4.3.6/node_modules/@tronsfey/mcp2cli/dist/client/index.js"(exports) {
36665
+ "../../node_modules/.pnpm/@tronsfey+mcp2cli@1.0.1_zod@4.3.6/node_modules/@tronsfey/mcp2cli/dist/client/index.js"(exports) {
36666
36666
  Object.defineProperty(exports, "__esModule", { value: true });
36667
+ exports.parseCommand = parseCommand;
36668
+ exports.isTransportUnsupported = isTransportUnsupported;
36667
36669
  exports.createMcpClient = createMcpClient;
36668
36670
  var index_js_1 = require_client2();
36669
36671
  var stdio_js_1 = require_stdio2();
@@ -36691,14 +36693,26 @@ var require_client3 = __commonJS({
36691
36693
  }
36692
36694
  if (current)
36693
36695
  parts.push(current);
36696
+ if (inSingle || inDouble) {
36697
+ throw new Error(`Unclosed quote in command: ${cmdString}`);
36698
+ }
36694
36699
  const [command, ...args] = parts;
36695
36700
  return { command, args };
36696
36701
  }
36697
- async function createMcpClient(config, verbose = false) {
36698
- const client = new index_js_1.Client({
36702
+ function makeClient() {
36703
+ return new index_js_1.Client({
36699
36704
  name: "mcp2cli",
36700
36705
  version: "1.0.0"
36701
36706
  });
36707
+ }
36708
+ function isTransportUnsupported(err) {
36709
+ const msg = err instanceof Error ? err.message : String(err);
36710
+ if (/\b401\b|\bunauthorized\b|\b403\b|\bforbidden\b/i.test(msg)) {
36711
+ return false;
36712
+ }
36713
+ return true;
36714
+ }
36715
+ async function createMcpClient(config, verbose = false) {
36702
36716
  if (config.type === "stdio") {
36703
36717
  if (!config.command) {
36704
36718
  throw new Error("stdio config requires a command");
@@ -36708,41 +36722,48 @@ var require_client3 = __commonJS({
36708
36722
  ...Object.fromEntries(Object.entries(process.env).filter(([, v]) => v !== void 0)),
36709
36723
  ...config.env ?? {}
36710
36724
  };
36725
+ const client2 = makeClient();
36711
36726
  const transport = new stdio_js_1.StdioClientTransport({ command, args, env });
36712
- await client.connect(transport);
36727
+ await client2.connect(transport);
36713
36728
  if (verbose) {
36714
36729
  console.error(`[mcp2cli] Connected via stdio: ${config.command}`);
36715
36730
  }
36716
- } else {
36717
- if (!config.url) {
36718
- throw new Error("http config requires a url");
36731
+ return client2;
36732
+ }
36733
+ if (!config.url) {
36734
+ throw new Error("http config requires a url");
36735
+ }
36736
+ const serverUrl = new URL(config.url);
36737
+ const headers = config.headers ?? {};
36738
+ try {
36739
+ const client2 = makeClient();
36740
+ const transport = new streamableHttp_js_1.StreamableHTTPClientTransport(serverUrl, {
36741
+ requestInit: { headers }
36742
+ });
36743
+ await client2.connect(transport);
36744
+ if (verbose) {
36745
+ console.error(`[mcp2cli] Connected via Streamable HTTP: ${config.url}`);
36719
36746
  }
36720
- const serverUrl = new URL(config.url);
36721
- const headers = config.headers ?? {};
36722
- try {
36723
- const transport = new streamableHttp_js_1.StreamableHTTPClientTransport(serverUrl, {
36724
- requestInit: { headers }
36725
- });
36726
- await client.connect(transport);
36727
- if (verbose) {
36728
- console.error(`[mcp2cli] Connected via Streamable HTTP: ${config.url}`);
36729
- }
36730
- } catch {
36731
- if (verbose) {
36732
- console.error(`[mcp2cli] Streamable HTTP failed, falling back to SSE`);
36733
- }
36734
- const sseTransport = new sse_js_1.SSEClientTransport(serverUrl, {
36735
- requestInit: { headers }
36736
- });
36737
- await client.connect(sseTransport);
36738
- if (verbose) {
36739
- console.error(`[mcp2cli] Connected via SSE: ${config.url}`);
36740
- }
36747
+ return client2;
36748
+ } catch (err) {
36749
+ if (!isTransportUnsupported(err)) {
36750
+ throw err;
36751
+ }
36752
+ if (verbose) {
36753
+ console.error(`[mcp2cli] Streamable HTTP not supported, falling back to SSE`);
36741
36754
  }
36742
36755
  }
36756
+ const client = makeClient();
36757
+ const sseTransport = new sse_js_1.SSEClientTransport(serverUrl, {
36758
+ requestInit: { headers }
36759
+ });
36760
+ await client.connect(sseTransport);
36761
+ if (verbose) {
36762
+ console.error(`[mcp2cli] Connected via SSE: ${config.url}`);
36763
+ }
36743
36764
  return client;
36744
36765
  }
36745
36766
  }
36746
36767
  });
36747
36768
  export default require_client3();
36748
- //# sourceMappingURL=client-TA5DDDSP.js.map
36769
+ //# sourceMappingURL=client-O6QINOP2.js.map