@tronsfey/ucli 0.4.0 → 0.4.2

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
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import "./chunk-NNFC34A5.js";
2
+ import { createRequire as __createRequire } from "module";
3
+ const require = __createRequire(import.meta.url);
4
+ import "./chunk-FJU3QOHW.js";
3
5
 
4
6
  // src/index.ts
5
7
  import { Command } from "commander";
@@ -103,11 +105,17 @@ function registerConfigure(program2) {
103
105
  }
104
106
 
105
107
  // src/lib/cache.ts
106
- import { readFile, writeFile, mkdir } from "fs/promises";
108
+ import { readFile, writeFile, mkdir, unlink, chmod } from "fs/promises";
107
109
  import { join as join2 } from "path";
108
110
  var LIST_CACHE_FILE = join2(cacheDir, "oas-list.json");
109
111
  async function ensureCacheDir() {
110
- await mkdir(cacheDir, { recursive: true });
112
+ await mkdir(cacheDir, { recursive: true, mode: 448 });
113
+ }
114
+ function redactEntries(entries) {
115
+ return entries.map((e) => ({
116
+ ...e,
117
+ authConfig: { type: e.authConfig["type"] ?? e.authType }
118
+ }));
111
119
  }
112
120
  async function readOASListCache() {
113
121
  try {
@@ -122,15 +130,35 @@ async function readOASListCache() {
122
130
  }
123
131
  async function writeOASListCache(entries, ttlSec) {
124
132
  await ensureCacheDir();
125
- const cached = { entries, fetchedAt: Date.now(), ttlSec };
126
- await writeFile(LIST_CACHE_FILE, JSON.stringify(cached, null, 2), "utf8");
133
+ const cached = { entries: redactEntries(entries), fetchedAt: Date.now(), ttlSec };
134
+ await writeFile(LIST_CACHE_FILE, JSON.stringify(cached, null, 2), { encoding: "utf8", mode: 384 });
135
+ await chmod(LIST_CACHE_FILE, 384);
127
136
  }
128
137
  async function clearOASListCache() {
129
138
  try {
130
- await writeFile(LIST_CACHE_FILE, "{}", "utf8");
139
+ await unlink(LIST_CACHE_FILE);
131
140
  } catch {
132
141
  }
133
142
  }
143
+ async function clearOASCache(name) {
144
+ try {
145
+ const raw = await readFile(LIST_CACHE_FILE, "utf8");
146
+ const cached = JSON.parse(raw);
147
+ const entries = Array.isArray(cached.entries) ? cached.entries.filter((e) => e.name !== name) : [];
148
+ if (entries.length === 0) {
149
+ await clearOASListCache();
150
+ return;
151
+ }
152
+ const next = {
153
+ entries,
154
+ fetchedAt: cached.fetchedAt ?? Date.now(),
155
+ ttlSec: cached.ttlSec ?? 0
156
+ };
157
+ await writeFile(LIST_CACHE_FILE, JSON.stringify(next, null, 2), { encoding: "utf8", mode: 384 });
158
+ } catch {
159
+ await clearOASListCache();
160
+ }
161
+ }
134
162
 
135
163
  // src/lib/oas-runner.ts
136
164
  import { spawn } from "child_process";
@@ -170,6 +198,58 @@ function buildAuthEnv(entry) {
170
198
  return {};
171
199
  }
172
200
  }
201
+ var SAFE_ENV_KEYS = [
202
+ // System essentials
203
+ "PATH",
204
+ "HOME",
205
+ "USER",
206
+ "LOGNAME",
207
+ "SHELL",
208
+ "TMPDIR",
209
+ "TMP",
210
+ "TEMP",
211
+ // Terminal / display
212
+ "TERM",
213
+ "COLORTERM",
214
+ "NO_COLOR",
215
+ "FORCE_COLOR",
216
+ "LANG",
217
+ "LC_ALL",
218
+ "LC_CTYPE",
219
+ "LC_MESSAGES",
220
+ "LC_COLLATE",
221
+ // Node.js
222
+ "NODE_ENV",
223
+ "NODE_PATH",
224
+ "NODE_OPTIONS",
225
+ "NODE_EXTRA_CA_CERTS",
226
+ // Network proxy (required for tools behind corporate proxies)
227
+ "HTTP_PROXY",
228
+ "HTTPS_PROXY",
229
+ "NO_PROXY",
230
+ "http_proxy",
231
+ "https_proxy",
232
+ "no_proxy",
233
+ // OS-specific
234
+ "SYSTEMROOT",
235
+ "COMSPEC",
236
+ "APPDATA",
237
+ "LOCALAPPDATA",
238
+ "PROGRAMFILES",
239
+ "XDG_RUNTIME_DIR",
240
+ "XDG_CONFIG_HOME",
241
+ "XDG_CACHE_HOME",
242
+ "XDG_DATA_HOME"
243
+ ];
244
+ function buildSafeEnv(authEnv) {
245
+ const safe = {};
246
+ for (const key of SAFE_ENV_KEYS) {
247
+ if (process.env[key] !== void 0) {
248
+ safe[key] = process.env[key];
249
+ }
250
+ }
251
+ return { ...safe, ...authEnv };
252
+ }
173
253
  async function runOperation(opts) {
174
254
  const bin = resolveOpenapi2CliBin();
175
255
  const { entry, operationArgs, format, query } = opts;
@@ -185,17 +265,13 @@ async function runOperation(opts) {
185
265
  ...operationArgs
186
266
  ];
187
267
  const authEnv = buildAuthEnv(entry);
188
- await new Promise((resolve, reject) => {
268
+ await new Promise((resolve2, reject) => {
189
269
  const child = spawn(process.execPath, [bin, ...args], {
190
270
  stdio: "inherit",
191
- env: {
192
- ...process.env,
193
- ...authEnv
194
- // inject auth — not visible to parent shell
195
- }
271
+ env: buildSafeEnv(authEnv)
196
272
  });
197
273
  child.on("close", (code) => {
198
- if (code === 0) resolve();
274
+ if (code === 0) resolve2();
199
275
  else reject(new Error(`openapi2cli exited with code ${code}`));
200
276
  });
201
277
  child.on("error", reject);
@@ -211,7 +287,7 @@ async function getServiceHelp(entry) {
211
287
  String(entry.cacheTtl),
212
288
  "--help"
213
289
  ];
214
- return new Promise((resolve, reject) => {
290
+ return new Promise((resolve2, reject) => {
215
291
  let output = "";
216
292
  const child = spawn(process.execPath, [bin, ...args], {
217
293
  stdio: ["ignore", "pipe", "pipe"]
@@ -222,7 +298,7 @@ async function getServiceHelp(entry) {
222
298
  child.stderr?.on("data", (d) => {
223
299
  output += d.toString();
224
300
  });
225
- child.on("close", () => resolve(output));
301
+ child.on("close", () => resolve2(output));
226
302
  child.on("error", reject);
227
303
  });
228
304
  }
@@ -230,10 +306,14 @@ async function getServiceHelp(entry) {
230
306
  // src/commands/services.ts
231
307
  function registerServices(program2) {
232
308
  const services = program2.command("services").description("Manage and inspect available OAS services");
233
- services.command("list").description("List all OAS services available in the current group").option("--no-cache", "Bypass local cache and fetch fresh from server").action(async (opts) => {
309
+ services.command("list").description("List all OAS services available in the current group").option("--refresh", "Bypass local cache and fetch fresh from server").option("--format <fmt>", "Output format: table | json | yaml", "table").option("--no-cache", "Bypass local cache and fetch fresh from server").action(async (opts) => {
234
310
  const cfg = getConfig();
235
311
  const client = new ServerClient(cfg);
236
- let entries = opts.cache ? await readOASListCache() : null;
312
+ if (!opts.cache) {
313
+ process.emitWarning("The --no-cache flag is deprecated. Please use --refresh instead.");
314
+ }
315
+ const useCache = opts.cache && !opts.refresh;
316
+ let entries = useCache ? await readOASListCache() : null;
237
317
  if (!entries) {
238
318
  entries = await client.listOAS();
239
319
  if (entries.length > 0) {
@@ -241,10 +321,19 @@ function registerServices(program2) {
241
321
  await writeOASListCache(entries, maxTtl);
242
322
  }
243
323
  }
324
+ const format = (opts.format ?? "table").toLowerCase();
244
325
  if (entries.length === 0) {
245
326
  console.log("No services registered in this group.");
246
327
  return;
247
328
  }
329
+ if (format === "json") {
330
+ const safe = entries.map(({ authConfig, ...rest }) => ({
331
+ ...rest,
332
+ authConfig: { type: authConfig["type"] ?? rest.authType }
333
+ }));
334
+ console.log(JSON.stringify(safe, null, 2));
335
+ return;
336
+ }
248
337
  const nameWidth = Math.max(10, ...entries.map((e) => e.name.length));
249
338
  console.log(`
250
339
  ${"SERVICE".padEnd(nameWidth)} AUTH DESCRIPTION`);
@@ -256,7 +345,7 @@ ${"SERVICE".padEnd(nameWidth)} AUTH DESCRIPTION`);
256
345
  }
257
346
  console.log();
258
347
  });
259
- services.command("info <name>").description("Show detailed information and available operations for a service").action(async (name) => {
348
+ services.command("info <name>").description("Show detailed information and available operations for a service").option("--format <fmt>", "Output format: table | json | yaml", "table").action(async (name, opts) => {
260
349
  const cfg = getConfig();
261
350
  const client = new ServerClient(cfg);
262
351
  let entry;
@@ -267,6 +356,18 @@ ${"SERVICE".padEnd(nameWidth)} AUTH DESCRIPTION`);
267
356
  console.error("Run `ucli services list` to see available services.");
268
357
  process.exit(1);
269
358
  }
359
+ const help = await getServiceHelp(entry);
360
+ const format = (opts.format ?? "table").toLowerCase();
361
+ if (format === "json") {
362
+ const { authConfig, ...rest } = entry;
363
+ const safe = {
364
+ ...rest,
365
+ authConfig: { type: authConfig["type"] ?? rest.authType },
366
+ operationsHelp: help
367
+ };
368
+ console.log(JSON.stringify(safe, null, 2));
369
+ return;
370
+ }
270
371
  console.log(`
271
372
  Service: ${entry.name}`);
272
373
  console.log(`Description: ${entry.description || "(none)"}`);
@@ -276,14 +377,22 @@ Service: ${entry.name}`);
276
377
  console.log(`Cache TTL: ${entry.cacheTtl}s`);
277
378
  console.log("\nAvailable operations:");
278
379
  console.log("\u2500".repeat(60));
279
- const help = await getServiceHelp(entry);
280
380
  console.log(help);
281
381
  });
282
382
  }
283
383
 
284
384
  // src/commands/run.ts
285
385
  function registerRun(program2) {
286
- program2.command("run <service> [args...]").description("Execute an operation on a service").option("--format <fmt>", "Output format: json | table | yaml", "json").option("--query <jmespath>", "Filter response with JMESPath expression").option("--data <json>", "Request body (JSON string or @filename)").allowUnknownOption(true).action(async (service, args, opts) => {
386
+ program2.command("run [service] [args...]").description("Execute an operation on a service").option("--service <name>", "Service name (from `services list`)").option("--operation <id>", "OperationId to execute").option("--params <json>", "JSON string of operation parameters").option("--format <fmt>", "Output format: json | table | yaml", "json").option("--query <jmespath>", "Filter response with JMESPath expression").option("--data <json>", "Request body (JSON string or @filename)").allowUnknownOption(true).action(async (serviceArg, args, opts) => {
387
+ if (serviceArg && opts.service && serviceArg !== opts.service) {
388
+ console.error(`Conflicting service values: positional "${serviceArg}" and --service "${opts.service}". Use either the positional argument or --service flag, not both.`);
389
+ process.exit(1);
390
+ }
391
+ const service = opts.service ?? serviceArg;
392
+ if (!service) {
393
+ console.error("Missing service name. Use positional <service> or --service <name>.");
394
+ process.exit(1);
395
+ }
287
396
  const cfg = getConfig();
288
397
  const client = new ServerClient(cfg);
289
398
  let entry;
@@ -295,11 +404,29 @@ function registerRun(program2) {
295
404
  process.exit(1);
296
405
  }
297
406
  const extraArgs = opts.args ?? [];
298
- const operationArgs = [
299
- ...args,
300
- ...extraArgs,
301
- ...opts.data ? ["--data", opts.data] : []
302
- ];
407
+ const operationArgs = [...args, ...extraArgs];
408
+ if (opts.operation) {
409
+ operationArgs.unshift(opts.operation);
410
+ }
411
+ if (opts.params) {
412
+ let parsed;
413
+ try {
414
+ parsed = JSON.parse(opts.params);
415
+ } catch {
416
+ console.error(`Invalid --params JSON. Example: --params '{"petId": 1}'`);
417
+ process.exit(1);
418
+ }
419
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
420
+ for (const [k, v] of Object.entries(parsed)) {
421
+ if (v === void 0 || v === null) continue;
422
+ const strVal = typeof v === "object" ? JSON.stringify(v) : String(v);
423
+ operationArgs.push(`--${k}`, strVal);
424
+ }
425
+ }
426
+ }
427
+ if (opts.data) {
428
+ operationArgs.push("--data", opts.data);
429
+ }
303
430
  const format = opts.format;
304
431
  const query = opts.query;
305
432
  try {
@@ -318,11 +445,15 @@ function registerRun(program2) {
318
445
 
319
446
  // src/commands/refresh.ts
320
447
  function registerRefresh(program2) {
321
- program2.command("refresh").description("Force-refresh the local OAS cache from the server").action(async () => {
448
+ program2.command("refresh").description("Force-refresh the local OAS cache from the server").option("--service <name>", "Refresh only a specific service").action(async (opts) => {
322
449
  const cfg = getConfig();
323
450
  const client = new ServerClient(cfg);
324
451
  console.log("Refreshing OAS list from server...");
325
- await clearOASListCache();
452
+ if (opts.service) {
453
+ await clearOASCache(opts.service);
454
+ } else {
455
+ await clearOASListCache();
456
+ }
326
457
  const entries = await client.listOAS();
327
458
  if (entries.length > 0) {
328
459
  const maxTtl = Math.min(...entries.map((e) => e.cacheTtl));
@@ -427,10 +558,24 @@ ERRORS
427
558
  }
428
559
 
429
560
  // src/lib/mcp-runner.ts
561
+ function resolve(mod, name) {
562
+ if (typeof mod[name] === "function") return mod[name];
563
+ if (mod.default && typeof mod.default[name] === "function") return mod.default[name];
564
+ throw new Error(`Cannot resolve export "${name}" from module`);
565
+ }
430
566
  async function getMcp2cli() {
431
- const clientMod = await import("./client-TA5DDDSP.js");
432
- const runnerMod = await import("./runner-IBHNUS24.js");
433
- return { createMcpClient: clientMod.createMcpClient, getTools: runnerMod.getTools, runTool: runnerMod.runTool };
567
+ const clientMod = await import("./client-3I7XBDJU.js");
568
+ const runnerMod = await import("./runner-GVYIJNHN.js");
569
+ return {
570
+ createMcpClient: resolve(clientMod, "createMcpClient"),
571
+ getTools: resolve(runnerMod, "getTools"),
572
+ runTool: resolve(runnerMod, "runTool")
573
+ };
574
+ }
575
+ async function closeClient(client) {
576
+ if (typeof client.close === "function") {
577
+ await client.close();
578
+ }
434
579
  }
435
580
  function buildMcpConfig(entry) {
436
581
  const base = { type: entry.transport };
@@ -451,23 +596,42 @@ async function listMcpTools(entry) {
451
596
  const { createMcpClient, getTools } = await getMcp2cli();
452
597
  const config = buildMcpConfig(entry);
453
598
  const client = await createMcpClient(config);
454
- const tools = await getTools(client, config, { noCache: true });
455
- return tools;
599
+ try {
600
+ const tools = await getTools(client, config, { noCache: true });
601
+ return tools;
602
+ } finally {
603
+ await closeClient(client);
604
+ }
456
605
  }
457
606
  async function runMcpTool(entry, toolName, rawArgs) {
458
607
  const { createMcpClient, getTools, runTool } = await getMcp2cli();
459
608
  const config = buildMcpConfig(entry);
460
609
  const client = await createMcpClient(config);
461
- const tools = await getTools(client, config, { noCache: false, cacheTtl: 3600 });
462
- const tool = tools.find((t) => t.name === toolName);
463
- if (!tool) throw new Error(`Tool "${toolName}" not found on MCP server "${entry.name}"`);
464
- await runTool(client, tool, rawArgs, {});
610
+ try {
611
+ const tools = await getTools(client, config, { noCache: false, cacheTtl: 3600 });
612
+ const tool = tools.find((t) => t.name === toolName);
613
+ if (!tool) throw new Error(`Tool "${toolName}" not found on MCP server "${entry.name}"`);
614
+ const normalizedArgs = [];
615
+ for (const arg of rawArgs) {
616
+ if (arg.includes("=") && !arg.startsWith("--")) {
617
+ const idx = arg.indexOf("=");
618
+ const key = arg.slice(0, idx);
619
+ const value = arg.slice(idx + 1);
620
+ normalizedArgs.push(`--${key}`, value);
621
+ } else {
622
+ normalizedArgs.push(arg);
623
+ }
624
+ }
625
+ await runTool(client, tool, normalizedArgs, {});
626
+ } finally {
627
+ await closeClient(client);
628
+ }
465
629
  }
466
630
 
467
631
  // src/commands/mcp.ts
468
632
  function registerMcp(program2) {
469
633
  const mcp = program2.command("mcp").description("Interact with MCP servers registered in your group");
470
- mcp.command("list").description("List all MCP servers available in the current group").action(async () => {
634
+ mcp.command("list").description("List all MCP servers available in the current group").option("--format <fmt>", "Output format: table | json | yaml", "table").action(async (opts) => {
471
635
  const cfg = getConfig();
472
636
  const client = new ServerClient(cfg);
473
637
  const entries = await client.listMCP();
@@ -475,6 +639,15 @@ function registerMcp(program2) {
475
639
  console.log("No MCP servers registered in this group.");
476
640
  return;
477
641
  }
642
+ const format = (opts.format ?? "table").toLowerCase();
643
+ if (format === "json") {
644
+ const safe = entries.map(({ authConfig, ...rest }) => ({
645
+ ...rest,
646
+ authConfig: { type: authConfig.type }
647
+ }));
648
+ console.log(JSON.stringify(safe, null, 2));
649
+ return;
650
+ }
478
651
  const nameWidth = Math.max(10, ...entries.map((e) => e.name.length));
479
652
  console.log(`
480
653
  ${"SERVER".padEnd(nameWidth)} TRANSPORT DESCRIPTION`);
@@ -485,7 +658,7 @@ ${"SERVER".padEnd(nameWidth)} TRANSPORT DESCRIPTION`);
485
658
  }
486
659
  console.log();
487
660
  });
488
- mcp.command("tools <server>").description("List tools available on a MCP server").action(async (serverName) => {
661
+ mcp.command("tools <server>").description("List tools available on a MCP server").option("--format <fmt>", "Output format: table | json", "table").action(async (serverName, opts) => {
489
662
  const cfg = getConfig();
490
663
  const client = new ServerClient(cfg);
491
664
  let entry;
@@ -507,6 +680,11 @@ ${"SERVER".padEnd(nameWidth)} TRANSPORT DESCRIPTION`);
507
680
  console.log(`No tools found on MCP server "${serverName}".`);
508
681
  return;
509
682
  }
683
+ const format = (opts.format ?? "table").toLowerCase();
684
+ if (format === "json") {
685
+ console.log(JSON.stringify(tools, null, 2));
686
+ return;
687
+ }
510
688
  console.log(`
511
689
  Tools on "${serverName}":`);
512
690
  console.log("\u2500".repeat(60));
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/lib/server-client.ts","../src/commands/configure.ts","../src/lib/cache.ts","../src/lib/oas-runner.ts","../src/commands/services.ts","../src/commands/run.ts","../src/commands/refresh.ts","../src/commands/help-cmd.ts","../src/lib/mcp-runner.ts","../src/commands/mcp.ts"],"sourcesContent":["import { Command } from 'commander'\nimport { createRequire } from 'node:module'\nimport { registerConfigure } from './commands/configure.js'\nimport { registerServices } from './commands/services.js'\nimport { registerRun } from './commands/run.js'\nimport { registerRefresh } from './commands/refresh.js'\nimport { registerHelp } from './commands/help-cmd.js'\nimport { registerMcp } from './commands/mcp.js'\n\nconst require = createRequire(import.meta.url)\nconst pkg = require('../package.json') as { version: string; description: string }\n\nconst program = new Command()\n\nprogram\n .name('ucli')\n .description(pkg.description)\n .version(pkg.version, '-v, --version')\n .addHelpCommand(false) // we provide our own help command\n\nregisterConfigure(program)\nregisterServices(program)\nregisterRun(program)\nregisterRefresh(program)\nregisterMcp(program)\nregisterHelp(program)\n\nprogram.parse(process.argv)\n","import Conf from 'conf'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\n\nexport interface CLIConfig {\n serverUrl: string\n token: string\n}\n\nconst conf = new Conf<CLIConfig>({\n projectName: 'ucli',\n schema: {\n serverUrl: { type: 'string' },\n token: { type: 'string' },\n },\n})\n\nexport const cacheDir = join(homedir(), '.cache', 'ucli')\n\nexport function getConfig(): CLIConfig {\n const serverUrl = conf.get('serverUrl')\n const token = conf.get('token')\n\n if (!serverUrl || !token) {\n console.error('ucli is not configured. Run: ucli configure --server <url> --token <jwt>')\n process.exit(1)\n }\n\n return { serverUrl, token }\n}\n\nexport function saveConfig(cfg: CLIConfig): void {\n conf.set('serverUrl', cfg.serverUrl)\n conf.set('token', cfg.token)\n}\n\nexport function isConfigured(): boolean {\n return Boolean(conf.get('serverUrl') && conf.get('token'))\n}\n","/**\n * HTTP client for the ucli-server API.\n * Attaches group JWT and handles common error cases.\n */\nimport axios, { type AxiosInstance } from 'axios'\nimport type { CLIConfig } from '../config.js'\n\nexport interface OASEntryPublic {\n id: string\n name: string\n description: string\n remoteUrl: string\n baseEndpoint: string | null\n authType: 'bearer' | 'api_key' | 'basic' | 'oauth2_cc' | 'none'\n authConfig: Record<string, unknown>\n cacheTtl: number\n}\n\nexport type McpAuthConfig =\n | { type: 'none' }\n | { type: 'http_headers'; headers: Record<string, string> }\n | { type: 'env'; env: Record<string, string> }\n\nexport interface McpEntryPublic {\n id: string\n groupId: string\n name: string\n description: string\n transport: 'http' | 'stdio'\n serverUrl: string | null\n command: string | null\n authConfig: McpAuthConfig\n enabled: boolean\n}\n\nexport class ServerClient {\n private http: AxiosInstance\n\n constructor(cfg: CLIConfig) {\n this.http = axios.create({\n baseURL: cfg.serverUrl.replace(/\\/$/, ''),\n headers: {\n Authorization: `Bearer ${cfg.token}`,\n 'Content-Type': 'application/json',\n },\n timeout: 15_000,\n })\n\n this.http.interceptors.response.use(\n (r) => r,\n (err: unknown) => {\n if (axios.isAxiosError(err)) {\n const status = err.response?.status\n const message = (err.response?.data as { message?: string })?.message ?? err.message\n\n if (status === 401) {\n console.error('Authentication failed. Run: ucli configure --server <url> --token <jwt>')\n process.exit(1)\n }\n\n throw new Error(`Server error ${status ?? 'unknown'}: ${message}`)\n }\n throw err\n },\n )\n }\n\n async listOAS(): Promise<OASEntryPublic[]> {\n const { data } = await this.http.get<OASEntryPublic[]>('/api/v1/oas')\n return data\n }\n\n async getOAS(name: string): Promise<OASEntryPublic> {\n const { data } = await this.http.get<OASEntryPublic>(`/api/v1/oas/${encodeURIComponent(name)}`)\n return data\n }\n\n async listMCP(): Promise<McpEntryPublic[]> {\n const { data } = await this.http.get<McpEntryPublic[]>('/api/v1/mcp')\n return data\n }\n\n async getMCP(name: string): Promise<McpEntryPublic> {\n const { data } = await this.http.get<McpEntryPublic>(`/api/v1/mcp/${encodeURIComponent(name)}`)\n return data\n }\n}\n","import type { Command } from 'commander'\nimport { saveConfig, isConfigured } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\n\nexport function registerConfigure(program: Command): void {\n program\n .command('configure')\n .description('Configure the OAS Gateway server URL and authentication token')\n .requiredOption('--server <url>', 'OAS Gateway server URL (e.g. https://oas.example.com)')\n .requiredOption('--token <jwt>', 'Group JWT token issued by the server admin')\n .action(async (opts: { server: string; token: string }) => {\n const serverUrl = opts.server.replace(/\\/$/, '')\n const token = opts.token\n\n // Validate connectivity before saving\n console.log(`Connecting to ${serverUrl}...`)\n const client = new ServerClient({ serverUrl, token })\n\n try {\n await client.listOAS()\n saveConfig({ serverUrl, token })\n console.log('✓ Configuration saved successfully.')\n console.log(` Server: ${serverUrl}`)\n console.log(` Token: ${token.slice(0, 20)}...`)\n } catch (err) {\n console.error('Connection failed:', (err as Error).message)\n console.error('Please check the server URL and token.')\n process.exit(1)\n }\n })\n}\n","/**\n * Local file cache for OAS entries.\n * Stored at ~/.cache/oas-cli/<name>.json with TTL metadata.\n */\nimport { readFile, writeFile, mkdir } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { cacheDir } from '../config.js'\nimport type { OASEntryPublic } from './server-client.js'\n\ninterface CacheFile {\n entries: OASEntryPublic[]\n fetchedAt: number // ms timestamp\n ttlSec: number // cache duration\n}\n\nconst LIST_CACHE_FILE = join(cacheDir, 'oas-list.json')\n\nasync function ensureCacheDir(): Promise<void> {\n await mkdir(cacheDir, { recursive: true })\n}\n\nexport async function readOASListCache(): Promise<OASEntryPublic[] | null> {\n try {\n const raw = await readFile(LIST_CACHE_FILE, 'utf8')\n const cached: CacheFile = JSON.parse(raw)\n const age = (Date.now() - cached.fetchedAt) / 1000\n if (cached.ttlSec === 0 || age > cached.ttlSec) return null // expired\n return cached.entries\n } catch {\n return null // not found or parse error\n }\n}\n\nexport async function writeOASListCache(entries: OASEntryPublic[], ttlSec: number): Promise<void> {\n await ensureCacheDir()\n const cached: CacheFile = { entries, fetchedAt: Date.now(), ttlSec }\n await writeFile(LIST_CACHE_FILE, JSON.stringify(cached, null, 2), 'utf8')\n}\n\nexport async function clearOASListCache(): Promise<void> {\n try {\n await writeFile(LIST_CACHE_FILE, '{}', 'utf8')\n } catch {\n // ignore if not found\n }\n}\n","/**\n * Bridge between oas-cli and @tronsfey/openapi2cli run mode.\n *\n * Spawns openapi2cli as a child process, injecting auth config\n * as environment variables (never exposed to the agent's shell).\n */\nimport { spawn } from 'node:child_process'\nimport { createRequire } from 'node:module'\nimport { fileURLToPath } from 'node:url'\nimport { join, dirname } from 'node:path'\nimport type { OASEntryPublic } from './server-client.js'\n\nconst require = createRequire(import.meta.url)\n\nfunction resolveOpenapi2CliBin(): string {\n try {\n const pkgPath = require.resolve('@tronsfey/openapi2cli/package.json')\n const pkgDir = dirname(pkgPath)\n // @tronsfey/openapi2cli exposes its binary; find it\n const pkg = require('@tronsfey/openapi2cli/package.json') as { bin?: Record<string, string> }\n const binEntry = pkg.bin?.['openapi2cli'] ?? 'bin/openapi2cli.js'\n return join(pkgDir, binEntry)\n } catch {\n throw new Error(\n '@tronsfey/openapi2cli is not installed. Run: pnpm add @tronsfey/openapi2cli in packages/cli',\n )\n }\n}\n\nexport interface RunOptions {\n entry: OASEntryPublic\n /** Operation command args (e.g. ['listPets', '--limit', '10']) */\n operationArgs: string[]\n format?: 'json' | 'table' | 'yaml'\n query?: string\n}\n\n/**\n * Build auth environment variables for injection into child process.\n * The calling shell (and thus the AI agent) never sees these values.\n */\nfunction buildAuthEnv(entry: OASEntryPublic): Record<string, string> {\n const cfg = entry.authConfig\n const prefix = entry.name.toUpperCase().replace(/[^A-Z0-9]/g, '_')\n\n switch (cfg['type']) {\n case 'bearer':\n return { [`${prefix}_TOKEN`]: cfg['token'] as string }\n\n case 'api_key':\n return { [`${prefix}_API_KEY`]: cfg['key'] as string }\n\n case 'basic':\n return { [`${prefix}_CREDENTIALS`]: `${cfg['username']}:${cfg['password']}` }\n\n case 'oauth2_cc':\n return {\n [`${prefix}_CLIENT_ID`]: cfg['clientId'] as string,\n [`${prefix}_CLIENT_SECRET`]: cfg['clientSecret'] as string,\n [`${prefix}_SCOPES`]: (cfg['scopes'] as string[]).join(' '),\n }\n\n default:\n return {}\n }\n}\n\nexport async function runOperation(opts: RunOptions): Promise<void> {\n const bin = resolveOpenapi2CliBin()\n const { entry, operationArgs, format, query } = opts\n\n const args = [\n 'run',\n '--oas', entry.remoteUrl,\n '--cache-ttl', String(entry.cacheTtl),\n ...(entry.baseEndpoint ? ['--endpoint', entry.baseEndpoint] : []),\n ...(format ? ['--format', format] : []),\n ...(query ? ['--query', query] : []),\n ...operationArgs,\n ]\n\n const authEnv = buildAuthEnv(entry)\n\n await new Promise<void>((resolve, reject) => {\n const child = spawn(process.execPath, [bin, ...args], {\n stdio: 'inherit',\n env: {\n ...process.env,\n ...authEnv, // inject auth — not visible to parent shell\n },\n })\n\n child.on('close', (code) => {\n if (code === 0) resolve()\n else reject(new Error(`openapi2cli exited with code ${code}`))\n })\n child.on('error', reject)\n })\n}\n\n/**\n * Get list of available operations for a service by running `--help`.\n * Returns the raw help text from openapi2cli.\n */\nexport async function getServiceHelp(entry: OASEntryPublic): Promise<string> {\n const bin = resolveOpenapi2CliBin()\n const args = [\n 'run',\n '--oas', entry.remoteUrl,\n '--cache-ttl', String(entry.cacheTtl),\n '--help',\n ]\n\n return new Promise<string>((resolve, reject) => {\n let output = ''\n const child = spawn(process.execPath, [bin, ...args], {\n stdio: ['ignore', 'pipe', 'pipe'],\n })\n\n child.stdout?.on('data', (d: Buffer) => { output += d.toString() })\n child.stderr?.on('data', (d: Buffer) => { output += d.toString() })\n child.on('close', () => resolve(output))\n child.on('error', reject)\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { readOASListCache, writeOASListCache } from '../lib/cache.js'\nimport { getServiceHelp } from '../lib/oas-runner.js'\n\nexport function registerServices(program: Command): void {\n const services = program\n .command('services')\n .description('Manage and inspect available OAS services')\n\n // services list\n services\n .command('list')\n .description('List all OAS services available in the current group')\n .option('--no-cache', 'Bypass local cache and fetch fresh from server')\n .action(async (opts: { cache: boolean }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entries = opts.cache ? await readOASListCache() : null\n\n if (!entries) {\n entries = await client.listOAS()\n if (entries.length > 0) {\n const maxTtl = Math.min(...entries.map((e) => e.cacheTtl))\n await writeOASListCache(entries, maxTtl)\n }\n }\n\n if (entries.length === 0) {\n console.log('No services registered in this group.')\n return\n }\n\n const nameWidth = Math.max(10, ...entries.map((e) => e.name.length))\n console.log(`\\n${'SERVICE'.padEnd(nameWidth)} AUTH DESCRIPTION`)\n console.log(`${'-'.repeat(nameWidth)} -------- ${'-'.repeat(40)}`)\n for (const e of entries) {\n const auth = e.authType.padEnd(8)\n const desc = e.description.length > 60 ? e.description.slice(0, 57) + '...' : e.description\n console.log(`${e.name.padEnd(nameWidth)} ${auth} ${desc}`)\n }\n console.log()\n })\n\n // services info <name>\n services\n .command('info <name>')\n .description('Show detailed information and available operations for a service')\n .action(async (name: string) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getOAS(name)\n } catch (err) {\n console.error(`Service not found: ${name}`)\n console.error('Run `ucli services list` to see available services.')\n process.exit(1)\n }\n\n console.log(`\\nService: ${entry.name}`)\n console.log(`Description: ${entry.description || '(none)'}`)\n console.log(`OAS URL: ${entry.remoteUrl}`)\n if (entry.baseEndpoint) console.log(`Base endpoint: ${entry.baseEndpoint}`)\n console.log(`Auth type: ${entry.authType}`)\n console.log(`Cache TTL: ${entry.cacheTtl}s`)\n\n console.log('\\nAvailable operations:')\n console.log('─'.repeat(60))\n\n const help = await getServiceHelp(entry)\n console.log(help)\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { runOperation } from '../lib/oas-runner.js'\n\nexport function registerRun(program: Command): void {\n program\n .command('run <service> [args...]')\n .description('Execute an operation on a service')\n .option('--format <fmt>', 'Output format: json | table | yaml', 'json')\n .option('--query <jmespath>', 'Filter response with JMESPath expression')\n .option('--data <json>', 'Request body (JSON string or @filename)')\n .allowUnknownOption(true)\n .action(async (\n service: string,\n args: string[],\n opts: { format?: string; query?: string; data?: string; args?: string[] },\n ) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getOAS(service)\n } catch {\n console.error(`Unknown service: ${service}`)\n console.error('Run `ucli services list` to see available services.')\n process.exit(1)\n }\n\n // Collect extra args (pass-through to openapi2cli)\n const extraArgs = opts.args ?? []\n const operationArgs = [\n ...args,\n ...extraArgs,\n ...(opts.data ? ['--data', opts.data] : []),\n ]\n\n const format = opts.format as 'json' | 'table' | 'yaml' | undefined\n const query = opts.query as string | undefined\n\n try {\n await runOperation({\n entry,\n operationArgs,\n ...(format !== undefined ? { format } : {}),\n ...(query !== undefined ? { query } : {}),\n })\n } catch (err) {\n console.error('Operation failed:', (err as Error).message)\n process.exit(1)\n }\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { writeOASListCache, clearOASListCache } from '../lib/cache.js'\n\nexport function registerRefresh(program: Command): void {\n program\n .command('refresh')\n .description('Force-refresh the local OAS cache from the server')\n .action(async () => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n console.log('Refreshing OAS list from server...')\n await clearOASListCache()\n\n const entries = await client.listOAS()\n if (entries.length > 0) {\n const maxTtl = Math.min(...entries.map((e) => e.cacheTtl))\n await writeOASListCache(entries, maxTtl)\n }\n\n console.log(`✓ Refreshed ${entries.length} service(s).`)\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig, isConfigured } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { readOASListCache, writeOASListCache } from '../lib/cache.js'\nimport { getServiceHelp } from '../lib/oas-runner.js'\n\nexport function registerHelp(program: Command): void {\n program\n .command('help [service]')\n .description('Show usage guide. Pass a service name for service-specific operations.')\n .action(async (service?: string) => {\n if (!service) {\n printGeneralHelp()\n if (isConfigured()) {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n let entries = await readOASListCache()\n if (!entries) {\n entries = await client.listOAS()\n if (entries.length > 0) {\n const maxTtl = Math.min(...entries.map((e) => e.cacheTtl))\n await writeOASListCache(entries, maxTtl)\n }\n }\n if (entries.length > 0) {\n console.log('\\nAvailable services:')\n for (const e of entries) {\n console.log(` ${e.name.padEnd(20)} ${e.description}`)\n }\n console.log('\\nTip: Run `ucli help <service>` for service-specific operations.')\n }\n } else {\n console.log('\\nRun `ucli configure --server <url> --token <jwt>` to get started.')\n }\n return\n }\n\n // Service-specific help\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getOAS(service)\n } catch {\n console.error(`Unknown service: ${service}`)\n console.error('Run `ucli services list` to see available services.')\n process.exit(1)\n }\n\n console.log(`\\n=== ${entry.name} ===`)\n console.log(`${entry.description}`)\n console.log(`\\nOAS spec: ${entry.remoteUrl}`)\n console.log('\\nOperations:')\n console.log('─'.repeat(60))\n\n const help = await getServiceHelp(entry)\n console.log(help)\n\n console.log('\\nExamples:')\n console.log(` ucli run ${entry.name} <operation>`)\n console.log(` ucli run ${entry.name} <operation> --format table`)\n console.log(` ucli run ${entry.name} <operation> --query \"results[*].id\"`)\n console.log(` ucli run ${entry.name} <operation> --data '{\"key\":\"value\"}'`)\n })\n}\n\nfunction printGeneralHelp(): void {\n console.log(`\nucli — OpenAPI & MCP Gateway for AI Agents\n════════════════════════════════════════\n\nSETUP\n ucli configure --server <url> --token <jwt>\n Configure server connection and authentication.\n\nDISCOVERY\n ucli services list\n List all OAS services available in your group.\n\n ucli services info <service>\n Show detailed service info and all available operations.\n\n ucli help [service]\n Show this guide, or service-specific operations.\n\nEXECUTION\n ucli run <service> <operation> [options]\n Execute a service operation.\n\n Options:\n --format json|table|yaml Output format (default: json)\n --query <jmespath> Filter response with JMESPath\n --data <json|@file> Request body for POST/PUT/PATCH\n\nMAINTENANCE\n ucli refresh\n Force-refresh the local OAS cache from the server.\n\nERRORS\n 401 Unauthorized → Run: ucli configure --server <url> --token <jwt>\n 404 Not Found → Check service name: ucli services list\n 4xx Client Error → Check operation args: ucli services info <service>\n 5xx Server Error → Retry or run: ucli refresh\n`)\n}\n","/**\n * MCP tool runner using @tronsfey/mcp2cli programmatic API.\n *\n * Auth credentials are injected via McpServerConfig (headers or env) —\n * never passed as CLI arguments (which would be visible in `ps`).\n */\nimport type { McpEntryPublic } from './server-client.js'\n\n// Dynamic imports to avoid top-level await in ESM\nasync function getMcp2cli() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const clientMod = await import('@tronsfey/mcp2cli/dist/client/index.js') as any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const runnerMod = await import('@tronsfey/mcp2cli/dist/runner/index.js') as any\n return { createMcpClient: clientMod.createMcpClient, getTools: runnerMod.getTools, runTool: runnerMod.runTool }\n}\n\nfunction buildMcpConfig(entry: McpEntryPublic): Record<string, unknown> {\n const base: Record<string, unknown> = { type: entry.transport }\n if (entry.transport === 'http') {\n base.url = entry.serverUrl\n } else {\n base.command = entry.command\n }\n const auth = entry.authConfig\n if (auth.type === 'http_headers') {\n base.headers = auth.headers\n } else if (auth.type === 'env') {\n base.env = auth.env\n }\n return base\n}\n\nexport async function listMcpTools(entry: McpEntryPublic): Promise<{ name: string; description?: string }[]> {\n const { createMcpClient, getTools } = await getMcp2cli()\n const config = buildMcpConfig(entry)\n const client = await createMcpClient(config)\n const tools = await getTools(client, config, { noCache: true })\n return tools\n}\n\nexport async function runMcpTool(entry: McpEntryPublic, toolName: string, rawArgs: string[]): Promise<void> {\n const { createMcpClient, getTools, runTool } = await getMcp2cli()\n const config = buildMcpConfig(entry)\n const client = await createMcpClient(config)\n const tools = await getTools(client, config, { noCache: false, cacheTtl: 3600 })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const tool = tools.find((t: any) => t.name === toolName)\n if (!tool) throw new Error(`Tool \"${toolName}\" not found on MCP server \"${entry.name}\"`)\n await runTool(client, tool, rawArgs, {})\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { listMcpTools, runMcpTool } from '../lib/mcp-runner.js'\n\nexport function registerMcp(program: Command): void {\n const mcp = program\n .command('mcp')\n .description('Interact with MCP servers registered in your group')\n\n // mcp list\n mcp\n .command('list')\n .description('List all MCP servers available in the current group')\n .action(async () => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n const entries = await client.listMCP()\n\n if (entries.length === 0) {\n console.log('No MCP servers registered in this group.')\n return\n }\n\n const nameWidth = Math.max(10, ...entries.map(e => e.name.length))\n console.log(`\\n${'SERVER'.padEnd(nameWidth)} TRANSPORT DESCRIPTION`)\n console.log(`${'-'.repeat(nameWidth)} --------- ${'-'.repeat(40)}`)\n for (const e of entries) {\n const desc = e.description.length > 60 ? e.description.slice(0, 57) + '...' : e.description\n console.log(`${e.name.padEnd(nameWidth)} ${e.transport.padEnd(9)} ${desc}`)\n }\n console.log()\n })\n\n // mcp tools <server>\n mcp\n .command('tools <server>')\n .description('List tools available on a MCP server')\n .action(async (serverName: string) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getMCP(serverName)\n } catch {\n console.error(`Unknown MCP server: ${serverName}`)\n console.error('Run `ucli mcp list` to see available servers.')\n process.exit(1)\n }\n\n let tools\n try {\n tools = await listMcpTools(entry)\n } catch (err) {\n console.error('Failed to fetch tools:', (err as Error).message)\n process.exit(1)\n }\n\n if (tools.length === 0) {\n console.log(`No tools found on MCP server \"${serverName}\".`)\n return\n }\n\n console.log(`\\nTools on \"${serverName}\":`)\n console.log('─'.repeat(60))\n for (const t of tools) {\n console.log(` ${t.name}`)\n if (t.description) console.log(` ${t.description}`)\n }\n console.log()\n })\n\n // mcp run <server> <tool> [args...]\n mcp\n .command('run <server> <tool> [args...]')\n .description('Call a tool on a MCP server')\n .action(async (serverName: string, toolName: string, args: string[]) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getMCP(serverName)\n } catch {\n console.error(`Unknown MCP server: ${serverName}`)\n console.error('Run `ucli mcp list` to see available servers.')\n process.exit(1)\n }\n\n try {\n await runMcpTool(entry, toolName, args)\n } catch (err) {\n console.error('Tool execution failed:', (err as Error).message)\n process.exit(1)\n }\n })\n}\n"],"mappings":";;;;AAAA,SAAS,eAAe;AACxB,SAAS,iBAAAA,sBAAqB;;;ACD9B,OAAO,UAAU;AACjB,SAAS,eAAe;AACxB,SAAS,YAAY;AAOrB,IAAM,OAAO,IAAI,KAAgB;AAAA,EAC/B,aAAa;AAAA,EACb,QAAQ;AAAA,IACN,WAAW,EAAE,MAAM,SAAS;AAAA,IAC5B,OAAO,EAAE,MAAM,SAAS;AAAA,EAC1B;AACF,CAAC;AAEM,IAAM,WAAW,KAAK,QAAQ,GAAG,UAAU,MAAM;AAEjD,SAAS,YAAuB;AACrC,QAAM,YAAY,KAAK,IAAI,WAAW;AACtC,QAAM,QAAQ,KAAK,IAAI,OAAO;AAE9B,MAAI,CAAC,aAAa,CAAC,OAAO;AACxB,YAAQ,MAAM,0EAA0E;AACxF,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,SAAO,EAAE,WAAW,MAAM;AAC5B;AAEO,SAAS,WAAW,KAAsB;AAC/C,OAAK,IAAI,aAAa,IAAI,SAAS;AACnC,OAAK,IAAI,SAAS,IAAI,KAAK;AAC7B;AAEO,SAAS,eAAwB;AACtC,SAAO,QAAQ,KAAK,IAAI,WAAW,KAAK,KAAK,IAAI,OAAO,CAAC;AAC3D;;;AClCA,OAAO,WAAmC;AA+BnC,IAAM,eAAN,MAAmB;AAAA,EA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AE;AACjD,cAAQ,MAAM,+CAA+C;AAC7D,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,QAAI;AACF,YAAM,WAAW,OAAO,UAAU,IAAI;AAAA,IACxC,SAAS,KAAK;AACZ,cAAQ,MAAM,0BAA2B,IAAc,OAAO;AAC9D,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;;;AXxFA,IAAMC,WAAUC,eAAc,YAAY,GAAG;AAC7C,IAAM,MAAMD,SAAQ,iBAAiB;AAErC,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,MAAM,EACX,YAAY,IAAI,WAAW,EAC3B,QAAQ,IAAI,SAAS,eAAe,EACpC,eAAe,KAAK;AAEvB,kBAAkB,OAAO;AACzB,iBAAiB,OAAO;AACxB,YAAY,OAAO;AACnB,gBAAgB,OAAO;AACvB,YAAY,OAAO;AACnB,aAAa,OAAO;AAEpB,QAAQ,MAAM,QAAQ,IAAI;","names":["createRequire","program","join","join","join","require","pkg","program","program","program","program","cfg","client","program","require","createRequire"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/lib/server-client.ts","../src/commands/configure.ts","../src/lib/cache.ts","../src/lib/oas-runner.ts","../src/commands/services.ts","../src/commands/run.ts","../src/commands/refresh.ts","../src/commands/help-cmd.ts","../src/lib/mcp-runner.ts","../src/commands/mcp.ts"],"sourcesContent":["import { Command } from 'commander'\nimport { createRequire } from 'node:module'\nimport { registerConfigure } from './commands/configure.js'\nimport { registerServices } from './commands/services.js'\nimport { registerRun } from './commands/run.js'\nimport { registerRefresh } from './commands/refresh.js'\nimport { registerHelp } from './commands/help-cmd.js'\nimport { registerMcp } from './commands/mcp.js'\n\nconst require = createRequire(import.meta.url)\nconst pkg = require('../package.json') as { version: string; description: string }\n\nconst program = new Command()\n\nprogram\n .name('ucli')\n .description(pkg.description)\n .version(pkg.version, '-v, --version')\n .addHelpCommand(false) // we provide our own help command\n\nregisterConfigure(program)\nregisterServices(program)\nregisterRun(program)\nregisterRefresh(program)\nregisterMcp(program)\nregisterHelp(program)\n\nprogram.parse(process.argv)\n","import Conf from 'conf'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\n\nexport interface CLIConfig {\n serverUrl: string\n token: string\n}\n\nconst conf = new Conf<CLIConfig>({\n projectName: 'ucli',\n schema: {\n serverUrl: { type: 'string' },\n token: { type: 'string' },\n },\n})\n\nexport const cacheDir = join(homedir(), '.cache', 'ucli')\n\nexport function getConfig(): CLIConfig {\n const serverUrl = conf.get('serverUrl')\n const token = conf.get('token')\n\n if (!serverUrl || !token) {\n console.error('ucli is not configured. Run: ucli configure --server <url> --token <jwt>')\n process.exit(1)\n }\n\n return { serverUrl, token }\n}\n\nexport function saveConfig(cfg: CLIConfig): void {\n conf.set('serverUrl', cfg.serverUrl)\n conf.set('token', cfg.token)\n}\n\nexport function isConfigured(): boolean {\n return Boolean(conf.get('serverUrl') && conf.get('token'))\n}\n","/**\n * HTTP client for the ucli-server API.\n * Attaches group JWT and handles common error cases.\n */\nimport axios, { type AxiosInstance } from 'axios'\nimport type { CLIConfig } from '../config.js'\n\nexport interface OASEntryPublic {\n id: string\n name: string\n description: string\n remoteUrl: string\n baseEndpoint: string | null\n authType: 'bearer' | 'api_key' | 'basic' | 'oauth2_cc' | 'none'\n authConfig: Record<string, unknown>\n cacheTtl: number\n}\n\nexport type McpAuthConfig =\n | { type: 'none' }\n | { type: 'http_headers'; headers: Record<string, string> }\n | { type: 'env'; env: Record<string, string> }\n\nexport interface McpEntryPublic {\n id: string\n groupId: string\n name: string\n description: string\n transport: 'http' | 'stdio'\n serverUrl: string | null\n command: string | null\n authConfig: McpAuthConfig\n enabled: boolean\n}\n\nexport class ServerClient {\n private http: AxiosInstance\n\n constructor(cfg: CLIConfig) {\n this.http = axios.create({\n baseURL: cfg.serverUrl.replace(/\\/$/, ''),\n headers: {\n Authorization: `Bearer ${cfg.token}`,\n 'Content-Type': 'application/json',\n },\n timeout: 15_000,\n })\n\n this.http.interceptors.response.use(\n (r) => r,\n (err: unknown) => {\n if (axios.isAxiosError(err)) {\n const status = err.response?.status\n const message = (err.response?.data as { message?: string })?.message ?? err.message\n\n if (status === 401) {\n console.error('Authentication failed. Run: ucli configure --server <url> --token <jwt>')\n process.exit(1)\n }\n\n throw new Error(`Server error ${status ?? 'unknown'}: ${message}`)\n }\n throw err\n },\n )\n }\n\n async listOAS(): Promise<OASEntryPublic[]> {\n const { data } = await this.http.get<OASEntryPublic[]>('/api/v1/oas')\n return data\n }\n\n async getOAS(name: string): Promise<OASEntryPublic> {\n const { data } = await this.http.get<OASEntryPublic>(`/api/v1/oas/${encodeURIComponent(name)}`)\n return data\n }\n\n async listMCP(): Promise<McpEntryPublic[]> {\n const { data } = await this.http.get<McpEntryPublic[]>('/api/v1/mcp')\n return data\n }\n\n async getMCP(name: string): Promise<McpEntryPublic> {\n const { data } = await this.http.get<McpEntryPublic>(`/api/v1/mcp/${encodeURIComponent(name)}`)\n return data\n }\n}\n","import type { Command } from 'commander'\nimport { saveConfig, isConfigured } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\n\nexport function registerConfigure(program: Command): void {\n program\n .command('configure')\n .description('Configure the OAS Gateway server URL and authentication token')\n .requiredOption('--server <url>', 'OAS Gateway server URL (e.g. https://oas.example.com)')\n .requiredOption('--token <jwt>', 'Group JWT token issued by the server admin')\n .action(async (opts: { server: string; token: string }) => {\n const serverUrl = opts.server.replace(/\\/$/, '')\n const token = opts.token\n\n // Validate connectivity before saving\n console.log(`Connecting to ${serverUrl}...`)\n const client = new ServerClient({ serverUrl, token })\n\n try {\n await client.listOAS()\n saveConfig({ serverUrl, token })\n console.log('✓ Configuration saved successfully.')\n console.log(` Server: ${serverUrl}`)\n console.log(` Token: ${token.slice(0, 20)}...`)\n } catch (err) {\n console.error('Connection failed:', (err as Error).message)\n console.error('Please check the server URL and token.')\n process.exit(1)\n }\n })\n}\n","/**\n * Local file cache for OAS entries.\n * Stored at ~/.cache/oas-cli/<name>.json with TTL metadata.\n *\n * Security: authConfig credential values are stripped before writing.\n * Only { type } is persisted — full secrets are never written to disk.\n */\nimport { readFile, writeFile, mkdir, unlink, chmod } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { cacheDir } from '../config.js'\nimport type { OASEntryPublic } from './server-client.js'\n\ninterface CacheFile {\n entries: OASEntryPublic[]\n fetchedAt: number // ms timestamp\n ttlSec: number // cache duration\n}\n\nconst LIST_CACHE_FILE = join(cacheDir, 'oas-list.json')\n\nasync function ensureCacheDir(): Promise<void> {\n await mkdir(cacheDir, { recursive: true, mode: 0o700 })\n}\n\n/** Strip credential secrets from authConfig — only persist { type }. */\nfunction redactEntries(entries: OASEntryPublic[]): OASEntryPublic[] {\n return entries.map((e) => ({\n ...e,\n authConfig: { type: (e.authConfig as Record<string, unknown>)['type'] ?? e.authType },\n }))\n}\n\nexport async function readOASListCache(): Promise<OASEntryPublic[] | null> {\n try {\n const raw = await readFile(LIST_CACHE_FILE, 'utf8')\n const cached: CacheFile = JSON.parse(raw)\n const age = (Date.now() - cached.fetchedAt) / 1000\n if (cached.ttlSec === 0 || age > cached.ttlSec) return null // expired\n return cached.entries\n } catch {\n return null // not found or parse error\n }\n}\n\nexport async function writeOASListCache(entries: OASEntryPublic[], ttlSec: number): Promise<void> {\n await ensureCacheDir()\n const cached: CacheFile = { entries: redactEntries(entries), fetchedAt: Date.now(), ttlSec }\n await writeFile(LIST_CACHE_FILE, JSON.stringify(cached, null, 2), { encoding: 'utf8', mode: 0o600 })\n await chmod(LIST_CACHE_FILE, 0o600)\n}\n\nexport async function clearOASListCache(): Promise<void> {\n try {\n await unlink(LIST_CACHE_FILE)\n } catch {\n // ignore if not found\n }\n}\n\nexport async function clearOASCache(name: string): Promise<void> {\n try {\n const raw = await readFile(LIST_CACHE_FILE, 'utf8')\n const cached: CacheFile = JSON.parse(raw)\n const entries = Array.isArray(cached.entries) ? cached.entries.filter((e) => e.name !== name) : []\n if (entries.length === 0) {\n await clearOASListCache()\n return\n }\n const next: CacheFile = {\n entries,\n fetchedAt: cached.fetchedAt ?? Date.now(),\n ttlSec: cached.ttlSec ?? 0,\n }\n await writeFile(LIST_CACHE_FILE, JSON.stringify(next, null, 2), { encoding: 'utf8', mode: 0o600 })\n } catch {\n await clearOASListCache()\n }\n}\n","/**\n * Bridge between oas-cli and @tronsfey/openapi2cli run mode.\n *\n * Spawns openapi2cli as a child process, injecting auth config\n * as environment variables (never exposed to the agent's shell).\n */\nimport { spawn } from 'node:child_process'\nimport { createRequire } from 'node:module'\nimport { join, dirname } from 'node:path'\nimport type { OASEntryPublic } from './server-client.js'\n\nconst require = createRequire(import.meta.url)\n\nfunction resolveOpenapi2CliBin(): string {\n try {\n const pkgPath = require.resolve('@tronsfey/openapi2cli/package.json')\n const pkgDir = dirname(pkgPath)\n // @tronsfey/openapi2cli exposes its binary; find it\n const pkg = require('@tronsfey/openapi2cli/package.json') as { bin?: Record<string, string> }\n const binEntry = pkg.bin?.['openapi2cli'] ?? 'bin/openapi2cli.js'\n return join(pkgDir, binEntry)\n } catch {\n throw new Error(\n '@tronsfey/openapi2cli is not installed. Run: pnpm add @tronsfey/openapi2cli in packages/cli',\n )\n }\n}\n\nexport interface RunOptions {\n entry: OASEntryPublic\n /** Operation command args (e.g. ['listPets', '--limit', '10']) */\n operationArgs: string[]\n format?: 'json' | 'table' | 'yaml'\n query?: string\n}\n\n/**\n * Build auth environment variables for injection into child process.\n * The calling shell (and thus the AI agent) never sees these values.\n */\nfunction buildAuthEnv(entry: OASEntryPublic): Record<string, string> {\n const cfg = entry.authConfig\n const prefix = entry.name.toUpperCase().replace(/[^A-Z0-9]/g, '_')\n\n switch (cfg['type']) {\n case 'bearer':\n return { [`${prefix}_TOKEN`]: cfg['token'] as string }\n\n case 'api_key':\n return { [`${prefix}_API_KEY`]: cfg['key'] as string }\n\n case 'basic':\n return { [`${prefix}_CREDENTIALS`]: `${cfg['username']}:${cfg['password']}` }\n\n case 'oauth2_cc':\n return {\n [`${prefix}_CLIENT_ID`]: cfg['clientId'] as string,\n [`${prefix}_CLIENT_SECRET`]: cfg['clientSecret'] as string,\n [`${prefix}_SCOPES`]: (cfg['scopes'] as string[]).join(' '),\n }\n\n default:\n return {}\n }\n}\n\n/**\n * Environment variable allowlist for subprocess execution.\n * Only these variables (when present in the parent) are forwarded to the\n * child process. This prevents leakage of secrets such as cloud credentials,\n * encryption keys, or database passwords that may be in the parent env.\n */\nconst SAFE_ENV_KEYS: readonly string[] = [\n // System essentials\n 'PATH', 'HOME', 'USER', 'LOGNAME', 'SHELL', 'TMPDIR', 'TMP', 'TEMP',\n // Terminal / display\n 'TERM', 'COLORTERM', 'NO_COLOR', 'FORCE_COLOR', 'LANG', 'LC_ALL',\n 'LC_CTYPE', 'LC_MESSAGES', 'LC_COLLATE',\n // Node.js\n 'NODE_ENV', 'NODE_PATH', 'NODE_OPTIONS', 'NODE_EXTRA_CA_CERTS',\n // Network proxy (required for tools behind corporate proxies)\n 'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY',\n 'http_proxy', 'https_proxy', 'no_proxy',\n // OS-specific\n 'SYSTEMROOT', 'COMSPEC', 'APPDATA', 'LOCALAPPDATA', 'PROGRAMFILES',\n 'XDG_RUNTIME_DIR', 'XDG_CONFIG_HOME', 'XDG_CACHE_HOME', 'XDG_DATA_HOME',\n]\n\nfunction buildSafeEnv(authEnv: Record<string, string>): Record<string, string> {\n const safe: Record<string, string> = {}\n for (const key of SAFE_ENV_KEYS) {\n if (process.env[key] !== undefined) {\n safe[key] = process.env[key]!\n }\n }\n return { ...safe, ...authEnv }\n}\n\nexport async function runOperation(opts: RunOptions): Promise<void> {\n const bin = resolveOpenapi2CliBin()\n const { entry, operationArgs, format, query } = opts\n\n const args = [\n 'run',\n '--oas', entry.remoteUrl,\n '--cache-ttl', String(entry.cacheTtl),\n ...(entry.baseEndpoint ? ['--endpoint', entry.baseEndpoint] : []),\n ...(format ? ['--format', format] : []),\n ...(query ? ['--query', query] : []),\n ...operationArgs,\n ]\n\n const authEnv = buildAuthEnv(entry)\n\n await new Promise<void>((resolve, reject) => {\n const child = spawn(process.execPath, [bin, ...args], {\n stdio: 'inherit',\n env: buildSafeEnv(authEnv),\n })\n\n child.on('close', (code) => {\n if (code === 0) resolve()\n else reject(new Error(`openapi2cli exited with code ${code}`))\n })\n child.on('error', reject)\n })\n}\n\n/**\n * Get list of available operations for a service by running `--help`.\n * Returns the raw help text from openapi2cli.\n */\nexport async function getServiceHelp(entry: OASEntryPublic): Promise<string> {\n const bin = resolveOpenapi2CliBin()\n const args = [\n 'run',\n '--oas', entry.remoteUrl,\n '--cache-ttl', String(entry.cacheTtl),\n '--help',\n ]\n\n return new Promise<string>((resolve, reject) => {\n let output = ''\n const child = spawn(process.execPath, [bin, ...args], {\n stdio: ['ignore', 'pipe', 'pipe'],\n })\n\n child.stdout?.on('data', (d: Buffer) => { output += d.toString() })\n child.stderr?.on('data', (d: Buffer) => { output += d.toString() })\n child.on('close', () => resolve(output))\n child.on('error', reject)\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { readOASListCache, writeOASListCache } from '../lib/cache.js'\nimport { getServiceHelp } from '../lib/oas-runner.js'\n\nexport function registerServices(program: Command): void {\n const services = program\n .command('services')\n .description('Manage and inspect available OAS services')\n\n // services list\n services\n .command('list')\n .description('List all OAS services available in the current group')\n .option('--refresh', 'Bypass local cache and fetch fresh from server')\n .option('--format <fmt>', 'Output format: table | json | yaml', 'table')\n .option('--no-cache', 'Bypass local cache and fetch fresh from server')\n .action(async (opts: { cache: boolean; refresh?: boolean; format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n if (!opts.cache) {\n process.emitWarning('The --no-cache flag is deprecated. Please use --refresh instead.')\n }\n\n const useCache = opts.cache && !opts.refresh\n let entries = useCache ? await readOASListCache() : null\n\n if (!entries) {\n entries = await client.listOAS()\n if (entries.length > 0) {\n const maxTtl = Math.min(...entries.map((e) => e.cacheTtl))\n await writeOASListCache(entries, maxTtl)\n }\n }\n\n const format = (opts.format ?? 'table').toLowerCase()\n\n if (entries.length === 0) {\n console.log('No services registered in this group.')\n return\n }\n\n if (format === 'json') {\n // Strip authConfig secrets from JSON output — only expose { type }\n const safe = entries.map(({ authConfig, ...rest }) => ({\n ...rest,\n authConfig: { type: (authConfig as Record<string, unknown>)['type'] ?? rest.authType },\n }))\n console.log(JSON.stringify(safe, null, 2))\n return\n }\n\n const nameWidth = Math.max(10, ...entries.map((e) => e.name.length))\n console.log(`\\n${'SERVICE'.padEnd(nameWidth)} AUTH DESCRIPTION`)\n console.log(`${'-'.repeat(nameWidth)} -------- ${'-'.repeat(40)}`)\n for (const e of entries) {\n const auth = e.authType.padEnd(8)\n const desc = e.description.length > 60 ? e.description.slice(0, 57) + '...' : e.description\n console.log(`${e.name.padEnd(nameWidth)} ${auth} ${desc}`)\n }\n console.log()\n })\n\n // services info <name>\n services\n .command('info <name>')\n .description('Show detailed information and available operations for a service')\n .option('--format <fmt>', 'Output format: table | json | yaml', 'table')\n .action(async (name: string, opts: { format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getOAS(name)\n } catch (err) {\n console.error(`Service not found: ${name}`)\n console.error('Run `ucli services list` to see available services.')\n process.exit(1)\n }\n\n const help = await getServiceHelp(entry)\n const format = (opts.format ?? 'table').toLowerCase()\n if (format === 'json') {\n // Strip authConfig secrets from JSON output\n const { authConfig, ...rest } = entry\n const safe = {\n ...rest,\n authConfig: { type: (authConfig as Record<string, unknown>)['type'] ?? rest.authType },\n operationsHelp: help,\n }\n console.log(JSON.stringify(safe, null, 2))\n return\n }\n\n console.log(`\\nService: ${entry.name}`)\n console.log(`Description: ${entry.description || '(none)'}`)\n console.log(`OAS URL: ${entry.remoteUrl}`)\n if (entry.baseEndpoint) console.log(`Base endpoint: ${entry.baseEndpoint}`)\n console.log(`Auth type: ${entry.authType}`)\n console.log(`Cache TTL: ${entry.cacheTtl}s`)\n console.log('\\nAvailable operations:')\n console.log('─'.repeat(60))\n console.log(help)\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { runOperation } from '../lib/oas-runner.js'\n\nexport function registerRun(program: Command): void {\n program\n .command('run [service] [args...]')\n .description('Execute an operation on a service')\n .option('--service <name>', 'Service name (from `services list`)')\n .option('--operation <id>', 'OperationId to execute')\n .option('--params <json>', 'JSON string of operation parameters')\n .option('--format <fmt>', 'Output format: json | table | yaml', 'json')\n .option('--query <jmespath>', 'Filter response with JMESPath expression')\n .option('--data <json>', 'Request body (JSON string or @filename)')\n .allowUnknownOption(true)\n .action(async (\n serviceArg: string | undefined,\n args: string[],\n opts: { service?: string; operation?: string; params?: string; format?: string; query?: string; data?: string; args?: string[] },\n ) => {\n if (serviceArg && opts.service && serviceArg !== opts.service) {\n console.error(`Conflicting service values: positional \"${serviceArg}\" and --service \"${opts.service}\". Use either the positional argument or --service flag, not both.`)\n process.exit(1)\n }\n\n const service = opts.service ?? serviceArg\n if (!service) {\n console.error('Missing service name. Use positional <service> or --service <name>.')\n process.exit(1)\n }\n\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getOAS(service)\n } catch {\n console.error(`Unknown service: ${service}`)\n console.error('Run `ucli services list` to see available services.')\n process.exit(1)\n }\n\n // Collect extra args (pass-through to openapi2cli)\n const extraArgs = opts.args ?? []\n const operationArgs = [...args, ...extraArgs]\n\n if (opts.operation) {\n operationArgs.unshift(opts.operation)\n }\n\n if (opts.params) {\n let parsed: unknown\n try {\n parsed = JSON.parse(opts.params)\n } catch {\n console.error('Invalid --params JSON. Example: --params \\'{\"petId\": 1}\\'')\n process.exit(1)\n }\n if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {\n for (const [k, v] of Object.entries(parsed as Record<string, unknown>)) {\n if (v === undefined || v === null) continue\n const strVal = typeof v === 'object' ? JSON.stringify(v) : String(v)\n operationArgs.push(`--${k}`, strVal)\n }\n }\n }\n\n if (opts.data) {\n operationArgs.push('--data', opts.data)\n }\n\n const format = opts.format as 'json' | 'table' | 'yaml' | undefined\n const query = opts.query as string | undefined\n\n try {\n await runOperation({\n entry,\n operationArgs,\n ...(format !== undefined ? { format } : {}),\n ...(query !== undefined ? { query } : {}),\n })\n } catch (err) {\n console.error('Operation failed:', (err as Error).message)\n process.exit(1)\n }\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { writeOASListCache, clearOASListCache, clearOASCache } from '../lib/cache.js'\n\nexport function registerRefresh(program: Command): void {\n program\n .command('refresh')\n .description('Force-refresh the local OAS cache from the server')\n .option('--service <name>', 'Refresh only a specific service')\n .action(async (opts: { service?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n console.log('Refreshing OAS list from server...')\n if (opts.service) {\n await clearOASCache(opts.service)\n } else {\n await clearOASListCache()\n }\n\n const entries = await client.listOAS()\n if (entries.length > 0) {\n const maxTtl = Math.min(...entries.map((e) => e.cacheTtl))\n await writeOASListCache(entries, maxTtl)\n }\n\n console.log(`✓ Refreshed ${entries.length} service(s).`)\n })\n}\n","import type { Command } from 'commander'\nimport { getConfig, isConfigured } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { readOASListCache, writeOASListCache } from '../lib/cache.js'\nimport { getServiceHelp } from '../lib/oas-runner.js'\n\nexport function registerHelp(program: Command): void {\n program\n .command('help [service]')\n .description('Show usage guide. Pass a service name for service-specific operations.')\n .action(async (service?: string) => {\n if (!service) {\n printGeneralHelp()\n if (isConfigured()) {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n let entries = await readOASListCache()\n if (!entries) {\n entries = await client.listOAS()\n if (entries.length > 0) {\n const maxTtl = Math.min(...entries.map((e) => e.cacheTtl))\n await writeOASListCache(entries, maxTtl)\n }\n }\n if (entries.length > 0) {\n console.log('\\nAvailable services:')\n for (const e of entries) {\n console.log(` ${e.name.padEnd(20)} ${e.description}`)\n }\n console.log('\\nTip: Run `ucli help <service>` for service-specific operations.')\n }\n } else {\n console.log('\\nRun `ucli configure --server <url> --token <jwt>` to get started.')\n }\n return\n }\n\n // Service-specific help\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getOAS(service)\n } catch {\n console.error(`Unknown service: ${service}`)\n console.error('Run `ucli services list` to see available services.')\n process.exit(1)\n }\n\n console.log(`\\n=== ${entry.name} ===`)\n console.log(`${entry.description}`)\n console.log(`\\nOAS spec: ${entry.remoteUrl}`)\n console.log('\\nOperations:')\n console.log('─'.repeat(60))\n\n const help = await getServiceHelp(entry)\n console.log(help)\n\n console.log('\\nExamples:')\n console.log(` ucli run ${entry.name} <operation>`)\n console.log(` ucli run ${entry.name} <operation> --format table`)\n console.log(` ucli run ${entry.name} <operation> --query \"results[*].id\"`)\n console.log(` ucli run ${entry.name} <operation> --data '{\"key\":\"value\"}'`)\n })\n}\n\nfunction printGeneralHelp(): void {\n console.log(`\nucli — OpenAPI & MCP Gateway for AI Agents\n════════════════════════════════════════\n\nSETUP\n ucli configure --server <url> --token <jwt>\n Configure server connection and authentication.\n\nDISCOVERY\n ucli services list\n List all OAS services available in your group.\n\n ucli services info <service>\n Show detailed service info and all available operations.\n\n ucli help [service]\n Show this guide, or service-specific operations.\n\nEXECUTION\n ucli run <service> <operation> [options]\n Execute a service operation.\n\n Options:\n --format json|table|yaml Output format (default: json)\n --query <jmespath> Filter response with JMESPath\n --data <json|@file> Request body for POST/PUT/PATCH\n\nMAINTENANCE\n ucli refresh\n Force-refresh the local OAS cache from the server.\n\nERRORS\n 401 Unauthorized → Run: ucli configure --server <url> --token <jwt>\n 404 Not Found → Check service name: ucli services list\n 4xx Client Error → Check operation args: ucli services info <service>\n 5xx Server Error → Retry or run: ucli refresh\n`)\n}\n","/**\n * MCP tool runner using @tronsfey/mcp2cli programmatic API.\n *\n * Auth credentials are injected via McpServerConfig (headers or env) —\n * never passed as CLI arguments (which would be visible in `ps`).\n */\nimport type { McpEntryPublic } from './server-client.js'\n\n/**\n * Resolve a named export from a module that may be CJS-wrapped (exports live\n * under `module.default`) or a plain ESM module (named exports at top level).\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction resolve(mod: any, name: string): unknown {\n if (typeof mod[name] === 'function') return mod[name]\n if (mod.default && typeof mod.default[name] === 'function') return mod.default[name]\n throw new Error(`Cannot resolve export \"${name}\" from module`)\n}\n\nasync function getMcp2cli() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const clientMod = await import('@tronsfey/mcp2cli/dist/client/index.js') as any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const runnerMod = await import('@tronsfey/mcp2cli/dist/runner/index.js') as any\n return {\n createMcpClient: resolve(clientMod, 'createMcpClient') as (...args: unknown[]) => Promise<unknown>,\n getTools: resolve(runnerMod, 'getTools') as (...args: unknown[]) => Promise<{ name: string; description?: string }[]>,\n runTool: resolve(runnerMod, 'runTool') as (...args: unknown[]) => Promise<void>,\n }\n}\n\nasync function closeClient(client: unknown): Promise<void> {\n if (typeof (client as { close?: unknown }).close === 'function') {\n await (client as { close: () => Promise<void> }).close()\n }\n}\n\nfunction buildMcpConfig(entry: McpEntryPublic): Record<string, unknown> {\n const base: Record<string, unknown> = { type: entry.transport }\n if (entry.transport === 'http') {\n base.url = entry.serverUrl\n } else {\n base.command = entry.command\n }\n const auth = entry.authConfig\n if (auth.type === 'http_headers') {\n base.headers = auth.headers\n } else if (auth.type === 'env') {\n base.env = auth.env\n }\n return base\n}\n\nexport async function listMcpTools(entry: McpEntryPublic): Promise<{ name: string; description?: string }[]> {\n const { createMcpClient, getTools } = await getMcp2cli()\n const config = buildMcpConfig(entry)\n const client = await createMcpClient(config)\n try {\n const tools = await getTools(client, config, { noCache: true })\n return tools\n } finally {\n await closeClient(client)\n }\n}\n\nexport async function runMcpTool(entry: McpEntryPublic, toolName: string, rawArgs: string[]): Promise<void> {\n const { createMcpClient, getTools, runTool } = await getMcp2cli()\n const config = buildMcpConfig(entry)\n const client = await createMcpClient(config)\n try {\n const tools = await getTools(client, config, { noCache: false, cacheTtl: 3600 })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const tool = tools.find((t: any) => t.name === toolName)\n if (!tool) throw new Error(`Tool \"${toolName}\" not found on MCP server \"${entry.name}\"`)\n const normalizedArgs: string[] = []\n for (const arg of rawArgs) {\n if (arg.includes('=') && !arg.startsWith('--')) {\n const idx = arg.indexOf('=')\n const key = arg.slice(0, idx)\n const value = arg.slice(idx + 1)\n normalizedArgs.push(`--${key}`, value)\n } else {\n normalizedArgs.push(arg)\n }\n }\n await runTool(client, tool, normalizedArgs, {})\n } finally {\n await closeClient(client)\n }\n}\n","import type { Command } from 'commander'\nimport { getConfig } from '../config.js'\nimport { ServerClient } from '../lib/server-client.js'\nimport { listMcpTools, runMcpTool } from '../lib/mcp-runner.js'\n\nexport function registerMcp(program: Command): void {\n const mcp = program\n .command('mcp')\n .description('Interact with MCP servers registered in your group')\n\n // mcp list\n mcp\n .command('list')\n .description('List all MCP servers available in the current group')\n .option('--format <fmt>', 'Output format: table | json | yaml', 'table')\n .action(async (opts: { format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n const entries = await client.listMCP()\n\n if (entries.length === 0) {\n console.log('No MCP servers registered in this group.')\n return\n }\n\n const format = (opts.format ?? 'table').toLowerCase()\n if (format === 'json') {\n // Strip authConfig secrets from JSON output — only expose { type }\n const safe = entries.map(({ authConfig, ...rest }) => ({\n ...rest,\n authConfig: { type: authConfig.type },\n }))\n console.log(JSON.stringify(safe, null, 2))\n return\n }\n\n const nameWidth = Math.max(10, ...entries.map(e => e.name.length))\n console.log(`\\n${'SERVER'.padEnd(nameWidth)} TRANSPORT DESCRIPTION`)\n console.log(`${'-'.repeat(nameWidth)} --------- ${'-'.repeat(40)}`)\n for (const e of entries) {\n const desc = e.description.length > 60 ? e.description.slice(0, 57) + '...' : e.description\n console.log(`${e.name.padEnd(nameWidth)} ${e.transport.padEnd(9)} ${desc}`)\n }\n console.log()\n })\n\n // mcp tools <server>\n mcp\n .command('tools <server>')\n .description('List tools available on a MCP server')\n .option('--format <fmt>', 'Output format: table | json', 'table')\n .action(async (serverName: string, opts: { format?: string }) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getMCP(serverName)\n } catch {\n console.error(`Unknown MCP server: ${serverName}`)\n console.error('Run `ucli mcp list` to see available servers.')\n process.exit(1)\n }\n\n let tools\n try {\n tools = await listMcpTools(entry)\n } catch (err) {\n console.error('Failed to fetch tools:', (err as Error).message)\n process.exit(1)\n }\n\n if (tools.length === 0) {\n console.log(`No tools found on MCP server \"${serverName}\".`)\n return\n }\n\n const format = (opts.format ?? 'table').toLowerCase()\n if (format === 'json') {\n console.log(JSON.stringify(tools, null, 2))\n return\n }\n\n console.log(`\\nTools on \"${serverName}\":`)\n console.log('─'.repeat(60))\n for (const t of tools) {\n console.log(` ${t.name}`)\n if (t.description) console.log(` ${t.description}`)\n }\n console.log()\n })\n\n // mcp run <server> <tool> [args...]\n mcp\n .command('run <server> <tool> [args...]')\n .description('Call a tool on a MCP server')\n .action(async (serverName: string, toolName: string, args: string[]) => {\n const cfg = getConfig()\n const client = new ServerClient(cfg)\n\n let entry\n try {\n entry = await client.getMCP(serverName)\n } catch {\n console.error(`Unknown MCP server: ${serverName}`)\n console.error('Run `ucli mcp list` to see available servers.')\n process.exit(1)\n }\n\n try {\n await runMcpTool(entry, toolName, args)\n } catch (err) {\n console.error('Tool execution failed:', (err as Error).message)\n process.exit(1)\n }\n })\n}\n"],"mappings":";;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,iBAAAA,sBAAqB;;;ACD9B,OAAO,UAAU;AACjB,SAAS,eAAe;AACxB,SAAS,YAAY;AAOrB,IAAM,OAAO,IAAI,KAAgB;AAAA,EAC/B,aAAa;AAAA,EACb,QAAQ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AAI;AACzC,YAAQ,IAAI,SAAI,OAAO,EAAE,CAAC;AAC1B,eAAW,KAAK,OAAO;AACrB,cAAQ,IAAI,KAAK,EAAE,IAAI,EAAE;AACzB,UAAI,EAAE,YAAa,SAAQ,IAAI,OAAO,EAAE,WAAW,EAAE;AAAA,IACvD;AACA,YAAQ,IAAI;AAAA,EACd,CAAC;AAGH,MACG,QAAQ,+BAA+B,EACvC,YAAY,6BAA6B,EACzC,OAAO,OAAO,YAAoB,UAAkB,SAAmB;AACtE,UAAM,MAAM,UAAU;AACtB,UAAM,SAAS,IAAI,aAAa,GAAG;AAEnC,QAAI;AACJ,QAAI;AACF,cAAQ,MAAM,OAAO,OAAO,UAAU;AAAA,IACxC,QAAQ;AACN,cAAQ,MAAM,uBAAuB,UAAU,EAAE;AACjD,cAAQ,MAAM,+CAA+C;AAC7D,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,QAAI;AACF,YAAM,WAAW,OAAO,UAAU,IAAI;AAAA,IACxC,SAAS,KAAK;AACZ,cAAQ,MAAM,0BAA2B,IAAc,OAAO;AAC9D,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;;;AX3GA,IAAMC,WAAUC,eAAc,YAAY,GAAG;AAC7C,IAAM,MAAMD,SAAQ,iBAAiB;AAErC,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,MAAM,EACX,YAAY,IAAI,WAAW,EAC3B,QAAQ,IAAI,SAAS,eAAe,EACpC,eAAe,KAAK;AAEvB,kBAAkB,OAAO;AACzB,iBAAiB,OAAO;AACxB,YAAY,OAAO;AACnB,gBAAgB,OAAO;AACvB,YAAY,OAAO;AACnB,aAAa,OAAO;AAEpB,QAAQ,MAAM,QAAQ,IAAI;","names":["createRequire","program","join","join","join","require","pkg","resolve","program","program","program","program","cfg","client","program","require","createRequire"]}