@tronsfey/ucli 0.5.1 → 0.5.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/README.md +64 -6
- package/README.zh.md +63 -5
- package/dist/{client-LCWUZRZX.js → client-Y6NONDCI.js} +25 -11
- package/dist/{client-LCWUZRZX.js.map → client-Y6NONDCI.js.map} +1 -1
- package/dist/index.js +77 -14
- package/dist/index.js.map +1 -1
- package/dist/{runner-HH357SRR.js → runner-ROLDMGH3.js} +250 -60
- package/dist/runner-ROLDMGH3.js.map +1 -0
- package/package.json +4 -4
- package/skill.md +93 -15
- package/dist/runner-HH357SRR.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -371,7 +371,7 @@ function buildSafeEnv(authEnv) {
|
|
|
371
371
|
}
|
|
372
372
|
async function runOperation(opts) {
|
|
373
373
|
const bin = resolveOpenapi2CliBin();
|
|
374
|
-
const { entry, operationArgs, format, query } = opts;
|
|
374
|
+
const { entry, operationArgs, format, query, machine, dryRun } = opts;
|
|
375
375
|
const args = [
|
|
376
376
|
"run",
|
|
377
377
|
"--oas",
|
|
@@ -379,6 +379,8 @@ async function runOperation(opts) {
|
|
|
379
379
|
"--cache-ttl",
|
|
380
380
|
String(entry.cacheTtl),
|
|
381
381
|
...entry.baseEndpoint ? ["--endpoint", entry.baseEndpoint] : [],
|
|
382
|
+
...machine ? ["--machine"] : [],
|
|
383
|
+
...dryRun ? ["--dry-run"] : [],
|
|
382
384
|
...format ? ["--format", format] : [],
|
|
383
385
|
...query ? ["--query", query] : [],
|
|
384
386
|
...operationArgs
|
|
@@ -582,7 +584,7 @@ Service: ${entry.name}`);
|
|
|
582
584
|
|
|
583
585
|
// src/commands/run.ts
|
|
584
586
|
function registerRun(program2) {
|
|
585
|
-
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) => {
|
|
587
|
+
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)").option("--machine", "Agent-friendly mode: structured JSON envelope output").option("--dry-run", "Preview the HTTP request without executing (implies --machine)").allowUnknownOption(true).action(async (serviceArg, args, opts) => {
|
|
586
588
|
if (serviceArg && opts.service && serviceArg !== opts.service) {
|
|
587
589
|
outputError(
|
|
588
590
|
ExitCode.USAGE_ERROR,
|
|
@@ -638,12 +640,16 @@ function registerRun(program2) {
|
|
|
638
640
|
}
|
|
639
641
|
const format = opts.format;
|
|
640
642
|
const query = opts.query;
|
|
643
|
+
const machine = opts.machine ?? false;
|
|
644
|
+
const dryRun = opts.dryRun ?? false;
|
|
641
645
|
try {
|
|
642
646
|
await runOperation({
|
|
643
647
|
entry,
|
|
644
648
|
operationArgs,
|
|
645
649
|
...format !== void 0 ? { format } : {},
|
|
646
|
-
...query !== void 0 ? { query } : {}
|
|
650
|
+
...query !== void 0 ? { query } : {},
|
|
651
|
+
...machine ? { machine } : {},
|
|
652
|
+
...dryRun ? { dryRun } : {}
|
|
647
653
|
});
|
|
648
654
|
} catch (err) {
|
|
649
655
|
outputError(
|
|
@@ -814,12 +820,14 @@ function resolve(mod, name) {
|
|
|
814
820
|
throw new Error(`Cannot resolve export "${name}" from module`);
|
|
815
821
|
}
|
|
816
822
|
async function getMcp2cli() {
|
|
817
|
-
const clientMod = await import("./client-
|
|
818
|
-
const runnerMod = await import("./runner-
|
|
823
|
+
const clientMod = await import("./client-Y6NONDCI.js");
|
|
824
|
+
const runnerMod = await import("./runner-ROLDMGH3.js");
|
|
819
825
|
return {
|
|
820
826
|
createMcpClient: resolve(clientMod, "createMcpClient"),
|
|
821
827
|
getTools: resolve(runnerMod, "getTools"),
|
|
822
|
-
runTool: resolve(runnerMod, "runTool")
|
|
828
|
+
runTool: resolve(runnerMod, "runTool"),
|
|
829
|
+
describeTool: resolve(runnerMod, "describeTool"),
|
|
830
|
+
describeToolJson: resolve(runnerMod, "describeToolJson")
|
|
823
831
|
};
|
|
824
832
|
}
|
|
825
833
|
async function closeClient(client) {
|
|
@@ -853,7 +861,24 @@ async function listMcpTools(entry) {
|
|
|
853
861
|
await closeClient(client);
|
|
854
862
|
}
|
|
855
863
|
}
|
|
856
|
-
async function
|
|
864
|
+
async function describeMcpTool(entry, toolName, opts) {
|
|
865
|
+
const { createMcpClient, getTools, describeTool, describeToolJson } = await getMcp2cli();
|
|
866
|
+
const config = buildMcpConfig(entry);
|
|
867
|
+
const client = await createMcpClient(config);
|
|
868
|
+
try {
|
|
869
|
+
const tools = await getTools(client, config, { noCache: false, cacheTtl: 3600 });
|
|
870
|
+
const tool = tools.find((t) => t.name === toolName);
|
|
871
|
+
if (!tool) throw new Error(`Tool "${toolName}" not found on MCP server "${entry.name}"`);
|
|
872
|
+
if (opts?.json) {
|
|
873
|
+
describeToolJson(tool);
|
|
874
|
+
} else {
|
|
875
|
+
describeTool(tool);
|
|
876
|
+
}
|
|
877
|
+
} finally {
|
|
878
|
+
await closeClient(client);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
async function runMcpTool(entry, toolName, rawArgs, opts) {
|
|
857
882
|
const { createMcpClient, getTools, runTool } = await getMcp2cli();
|
|
858
883
|
const config = buildMcpConfig(entry);
|
|
859
884
|
const client = await createMcpClient(config);
|
|
@@ -872,7 +897,10 @@ async function runMcpTool(entry, toolName, rawArgs) {
|
|
|
872
897
|
normalizedArgs.push(arg);
|
|
873
898
|
}
|
|
874
899
|
}
|
|
875
|
-
await runTool(client, tool, normalizedArgs, {
|
|
900
|
+
await runTool(client, tool, normalizedArgs, {
|
|
901
|
+
...opts?.json ? { json: true } : {},
|
|
902
|
+
...opts?.inputJson ? { inputJson: opts.inputJson } : {}
|
|
903
|
+
});
|
|
876
904
|
} finally {
|
|
877
905
|
await closeClient(client);
|
|
878
906
|
}
|
|
@@ -961,7 +989,26 @@ Tools on "${serverName}":`);
|
|
|
961
989
|
}
|
|
962
990
|
console.log();
|
|
963
991
|
});
|
|
964
|
-
mcp.command("
|
|
992
|
+
mcp.command("describe <server> <tool>").description("Show detailed schema for a tool on a MCP server").option("--json", "Output full schema as JSON (for agent consumption)").action(async (serverName, toolName, opts) => {
|
|
993
|
+
const cfg = getConfig();
|
|
994
|
+
const client = new ServerClient(cfg);
|
|
995
|
+
let entry;
|
|
996
|
+
try {
|
|
997
|
+
entry = await client.getMCP(serverName);
|
|
998
|
+
} catch {
|
|
999
|
+
outputError(
|
|
1000
|
+
ExitCode.NOT_FOUND,
|
|
1001
|
+
`Unknown MCP server: ${serverName}`,
|
|
1002
|
+
"Run: ucli mcp list to see available servers"
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1005
|
+
try {
|
|
1006
|
+
await describeMcpTool(entry, toolName, { json: opts.json });
|
|
1007
|
+
} catch (err) {
|
|
1008
|
+
outputError(ExitCode.GENERAL_ERROR, `Failed to describe tool: ${err.message}`);
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
mcp.command("run <server> <tool> [args...]").description("Call a tool on a MCP server").option("--json", "Machine-readable JSON output").option("--input-json <json>", "Pass tool arguments as a JSON object").action(async (serverName, toolName, args, opts) => {
|
|
965
1012
|
const cfg = getConfig();
|
|
966
1013
|
const client = new ServerClient(cfg);
|
|
967
1014
|
let entry;
|
|
@@ -975,7 +1022,10 @@ Tools on "${serverName}":`);
|
|
|
975
1022
|
);
|
|
976
1023
|
}
|
|
977
1024
|
try {
|
|
978
|
-
await runMcpTool(entry, toolName, args
|
|
1025
|
+
await runMcpTool(entry, toolName, args, {
|
|
1026
|
+
json: opts.json,
|
|
1027
|
+
inputJson: opts.inputJson
|
|
1028
|
+
});
|
|
979
1029
|
} catch (err) {
|
|
980
1030
|
outputError(ExitCode.GENERAL_ERROR, `Tool execution failed: ${err.message}`);
|
|
981
1031
|
}
|
|
@@ -1307,12 +1357,14 @@ function getCommandReference() {
|
|
|
1307
1357
|
{
|
|
1308
1358
|
name: "run",
|
|
1309
1359
|
description: "Execute an operation on an OAS service",
|
|
1310
|
-
usage: "ucli run <service> <operation> [--format json|table|yaml] [--query <jmespath>] [--data <json|@file>] [--params <json>]",
|
|
1360
|
+
usage: "ucli run <service> <operation> [--format json|table|yaml] [--query <jmespath>] [--data <json|@file>] [--params <json>] [--machine] [--dry-run]",
|
|
1311
1361
|
examples: [
|
|
1312
1362
|
"ucli run payments listTransactions",
|
|
1313
1363
|
"ucli run payments getTransaction --transactionId txn_123",
|
|
1314
1364
|
`ucli run payments createCharge --data '{"amount": 5000, "currency": "USD"}'`,
|
|
1315
|
-
'ucli run inventory listProducts --query "items[?stock > `0`].name"'
|
|
1365
|
+
'ucli run inventory listProducts --query "items[?stock > `0`].name"',
|
|
1366
|
+
"ucli run payments listTransactions --machine",
|
|
1367
|
+
`ucli run payments createCharge --dry-run --data '{"amount": 5000}'`
|
|
1316
1368
|
]
|
|
1317
1369
|
},
|
|
1318
1370
|
{
|
|
@@ -1333,13 +1385,24 @@ function getCommandReference() {
|
|
|
1333
1385
|
"ucli mcp tools weather --format json"
|
|
1334
1386
|
]
|
|
1335
1387
|
},
|
|
1388
|
+
{
|
|
1389
|
+
name: "mcp describe",
|
|
1390
|
+
description: "Show detailed schema for a tool on a MCP server",
|
|
1391
|
+
usage: "ucli mcp describe <server> <tool> [--json]",
|
|
1392
|
+
examples: [
|
|
1393
|
+
"ucli mcp describe weather get_forecast",
|
|
1394
|
+
"ucli mcp describe weather get_forecast --json"
|
|
1395
|
+
]
|
|
1396
|
+
},
|
|
1336
1397
|
{
|
|
1337
1398
|
name: "mcp run",
|
|
1338
1399
|
description: "Call a tool on a MCP server",
|
|
1339
|
-
usage: "ucli mcp run <server> <tool> [key=value ...]",
|
|
1400
|
+
usage: "ucli mcp run <server> <tool> [key=value ...] [--json] [--input-json <json>]",
|
|
1340
1401
|
examples: [
|
|
1341
1402
|
'ucli mcp run weather get_forecast location="New York"',
|
|
1342
|
-
'ucli mcp run search web_search query="ucli docs" limit=5'
|
|
1403
|
+
'ucli mcp run search web_search query="ucli docs" limit=5',
|
|
1404
|
+
`ucli mcp run weather get_forecast --input-json '{"location": "New York"}'`,
|
|
1405
|
+
'ucli mcp run weather get_forecast --json location="New York"'
|
|
1343
1406
|
]
|
|
1344
1407
|
},
|
|
1345
1408
|
{
|