@tronsfey/ucli 0.5.1 → 0.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tronsfey/ucli",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "ucli — proxy OpenAPI and MCP services for AI agents",
5
5
  "keywords": [
6
6
  "openapi",
@@ -37,18 +37,18 @@
37
37
  "clean": "rm -rf dist"
38
38
  },
39
39
  "dependencies": {
40
- "@tronsfey/openapi2cli": "1.0.13",
40
+ "@tronsfey/openapi2cli": "1.0.17",
41
41
  "axios": "^1.8.4",
42
42
  "commander": "^12.1.0",
43
43
  "conf": "^13.1.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@modelcontextprotocol/server-filesystem": "2026.1.14",
47
- "@tronsfey/mcp2cli": "1.0.2",
47
+ "@tronsfey/mcp2cli": "1.3.0",
48
48
  "@types/node": "^22.14.0",
49
49
  "tsup": "^8.4.0",
50
50
  "tsx": "^4.19.3",
51
- "typescript": "^5.7.3",
51
+ "typescript": "~5.8.3",
52
52
  "vitest": "^3.1.1"
53
53
  }
54
54
  }
package/skill.md CHANGED
@@ -34,9 +34,9 @@ Use `ucli` whenever you need to call any external business API or MCP server too
34
34
  ucli is designed around the **Observe → Orient → Decide → Act** (OODA) loop for AI agent workflows:
35
35
 
36
36
  1. **Observe** — Discover all available capabilities with `ucli introspect`
37
- 2. **Orient** — Understand specific operations with `ucli services info <name>` or `ucli mcp tools <server>`
37
+ 2. **Orient** — Understand specific operations with `ucli oas <service> listapi` or `ucli mcp <server> listtool`
38
38
  3. **Decide** — Choose the right operation and parameters based on the task
39
- 4. **Act** — Execute with `ucli run` or `ucli mcp run`
39
+ 4. **Act** — Execute with `ucli oas <service> invokeapi <api>` or `ucli mcp <server> invoketool <tool>`
40
40
 
41
41
  ### Recommended First Call
42
42
 
@@ -57,7 +57,7 @@ This returns a complete manifest in a single call:
57
57
  { "name": "weather", "description": "...", "transport": "http", ... }
58
58
  ],
59
59
  "commands": [
60
- { "name": "run", "description": "...", "usage": "...", "examples": [...] }
60
+ { "name": "oas invokeapi", "description": "...", "usage": "...", "examples": [...] }
61
61
  ]
62
62
  }
63
63
  }
@@ -84,7 +84,7 @@ When `--output json` is passed, every command emits exactly one JSON object to s
84
84
 
85
85
  **Error:**
86
86
  ```json
87
- { "success": false, "error": { "code": 6, "message": "Service not found: foo", "hint": "Run: ucli services list" } }
87
+ { "success": false, "error": { "code": 6, "message": "Service not found: foo", "hint": "Run: ucli listoas" } }
88
88
  ```
89
89
 
90
90
  Error codes: `0`=success, `1`=general, `2`=usage, `3`=config, `4`=auth, `5`=connectivity, `6`=not-found, `7`=server-error.
@@ -96,7 +96,7 @@ Error codes: `0`=success, `1`=general, `2`=usage, `3`=config, `4`=auth, `5`=conn
96
96
  ## Step 1 — Discover Available Services
97
97
 
98
98
  ```bash
99
- ucli services list
99
+ ucli listoas
100
100
  ```
101
101
 
102
102
  Returns a table of service names, auth type, and descriptions. Run this first to see what's available.
@@ -112,7 +112,7 @@ crm oauth2_cc Customer relationship management
112
112
 
113
113
  For machine-readable output:
114
114
  ```bash
115
- ucli services list --output json
115
+ ucli listoas --output json
116
116
  ```
117
117
 
118
118
  ---
@@ -120,14 +120,19 @@ ucli services list --output json
120
120
  ## Step 2 — Inspect a Service's Operations
121
121
 
122
122
  ```bash
123
- ucli services info <service-name>
123
+ ucli oas <service-name> listapi
124
124
  ```
125
125
 
126
126
  Shows all available operations, their parameters, and expected inputs.
127
127
 
128
128
  **Example:**
129
129
  ```bash
130
- ucli services info payments
130
+ ucli oas payments listapi
131
+ ```
132
+
133
+ For detailed information about a specific API operation:
134
+ ```bash
135
+ ucli oas payments apiinfo createCharge
131
136
  ```
132
137
 
133
138
  ---
@@ -135,7 +140,7 @@ ucli services info payments
135
140
  ## Step 3 — Execute an Operation
136
141
 
137
142
  ```bash
138
- ucli run <service> <operation> [options]
143
+ ucli oas <service> invokeapi <api> [options]
139
144
  ```
140
145
 
141
146
  ### Options
@@ -145,39 +150,66 @@ ucli run <service> <operation> [options]
145
150
  | `--format json\|table\|yaml` | Output format (default: json) | `--format table` |
146
151
  | `--query <jmespath>` | Filter response with JMESPath | `--query "items[*].id"` |
147
152
  | `--data <json\|@file>` | Request body for POST/PUT/PATCH | `--data '{"amount":100}'` |
153
+ | `--machine` | Structured JSON envelope output (agent-friendly) | `--machine` |
154
+ | `--dry-run` | Preview the HTTP request without executing (implies `--machine`) | `--dry-run` |
155
+
156
+ ### Agent-Friendly Mode (`--machine`)
157
+
158
+ Use `--machine` for structured JSON envelope output that agents can parse deterministically:
159
+
160
+ ```bash
161
+ # Structured success output
162
+ ucli oas payments invokeapi listTransactions --machine
163
+ # → { "success": true, "data": {...}, "meta": { "durationMs": 42 } }
164
+
165
+ # Structured error output
166
+ ucli oas payments invokeapi getTransaction --params '{"transactionId": "invalid"}' --machine
167
+ # → { "success": false, "error": { "type": "HttpClientError", "message": "...", "statusCode": 404 } }
168
+ ```
169
+
170
+ ### Dry-Run Mode (`--dry-run`)
171
+
172
+ Preview the HTTP request that *would* be sent, without actually executing it:
173
+
174
+ ```bash
175
+ ucli oas payments invokeapi createCharge --dry-run --data '{"amount": 5000, "currency": "USD"}'
176
+ # → { "method": "POST", "url": "https://api.example.com/charges", "headers": {...}, "body": {...} }
177
+ ```
178
+
179
+ This is useful for verifying parameters before making destructive or costly API calls.
148
180
 
149
181
  ### Examples
150
182
 
151
183
  **List resources (GET):**
152
184
  ```bash
153
- ucli run payments listTransactions --format json
185
+ ucli oas payments invokeapi listTransactions --format json
154
186
  ```
155
187
 
156
188
  **Filter response:**
157
189
  ```bash
158
- ucli run inventory listProducts --query "items[?stock > \`0\`].name"
190
+ ucli oas inventory invokeapi listProducts --query "items[?stock > \`0\`].name"
159
191
  ```
160
192
 
161
193
  **Create a resource (POST):**
162
194
  ```bash
163
- ucli run payments createCharge --data '{"amount": 5000, "currency": "USD", "customerId": "cus_123"}'
195
+ ucli oas payments invokeapi createCharge --data '{"amount": 5000, "currency": "USD", "customerId": "cus_123"}'
164
196
  ```
165
197
 
166
198
  **Update a resource (PUT/PATCH):**
167
199
  ```bash
168
- ucli run crm updateContact --data '{"email": "new@example.com"}' --contactId abc123
200
+ ucli oas crm invokeapi updateContact --data '{"email": "new@example.com"}' --params '{"contactId": "abc123"}'
169
201
  ```
170
202
 
171
203
  **Get a specific resource:**
172
204
  ```bash
173
- ucli run inventory getProduct --productId SKU-001
205
+ ucli oas inventory invokeapi getProduct --params '{"productId": "SKU-001"}'
174
206
  ```
175
207
 
176
208
  ---
177
209
 
178
210
  ## Step 4 — Process the Output
179
211
 
180
- By default, `ucli run` returns JSON. You can:
212
+ By default, `ucli oas <service> invokeapi` returns JSON. You can:
181
213
  - Parse it directly as structured data
182
214
  - Use `--query` to extract specific fields (JMESPath syntax)
183
215
  - Use `--format table` for human-readable display
@@ -205,22 +237,35 @@ By default, `ucli run` returns JSON. You can:
205
237
  # 1. Discover all capabilities (single call)
206
238
  ucli introspect --output json
207
239
 
208
- # 2. Inspect a specific service's operations
209
- ucli services info payments --output json
240
+ # 2. List available services
241
+ ucli listoas
242
+
243
+ # 3. Inspect a service's API operations
244
+ ucli oas payments listapi
210
245
 
211
- # 3. List recent transactions
212
- ucli run payments listTransactions --query "transactions[*].{id:id,amount:amount,status:status}"
246
+ # 4. Get detailed info about a specific API
247
+ ucli oas payments apiinfo createCharge
213
248
 
214
- # 4. Get a specific transaction
215
- ucli run payments getTransaction --transactionId txn_abc123
249
+ # 5. Preview a request (dry-run, no execution)
250
+ ucli oas payments invokeapi createCharge --dry-run --data '{"amount": 9900, "currency": "USD"}'
216
251
 
217
- # 5. Create a new charge
218
- ucli run payments createCharge --data '{
252
+ # 6. Execute with structured output (--machine)
253
+ ucli oas payments invokeapi listTransactions --machine --query "transactions[*].{id:id,amount:amount,status:status}"
254
+
255
+ # 7. Get a specific transaction
256
+ ucli oas payments invokeapi getTransaction --params '{"transactionId": "txn_abc123"}'
257
+
258
+ # 8. Create a new charge
259
+ ucli oas payments invokeapi createCharge --data '{
219
260
  "amount": 9900,
220
261
  "currency": "USD",
221
262
  "customerId": "cus_xyz789",
222
263
  "description": "Monthly subscription"
223
264
  }'
265
+
266
+ # 9. MCP: inspect a tool's parameters, then call it
267
+ ucli mcp weather toolinfo get_forecast --json
268
+ ucli mcp weather invoketool get_forecast --data '{"location": "New York", "units": "metric"}'
224
269
  ```
225
270
 
226
271
  ---
@@ -230,8 +275,8 @@ ucli run payments createCharge --data '{
230
275
  | Error | Cause | Resolution |
231
276
  |-------|-------|------------|
232
277
  | `Authentication failed` | Token expired or invalid | Run `ucli configure --server <url> --token <jwt>` |
233
- | `Unknown service: <name>` | Service not registered | Run `ucli services list` to see valid names |
234
- | `400 Bad Request` | Invalid parameters | Check operation signature with `ucli services info <service>` |
278
+ | `Unknown service: <name>` | Service not registered | Run `ucli listoas` to see valid names |
279
+ | `400 Bad Request` | Invalid parameters | Check operation signature with `ucli oas <service> apiinfo <api>` |
235
280
  | `404 Not Found` | Resource doesn't exist | Verify the resource ID |
236
281
  | `429 Too Many Requests` | Rate limit exceeded | Wait and retry |
237
282
  | `5xx Server Error` | Upstream service error | Retry once; if persistent, report to the service owner |
@@ -252,7 +297,7 @@ ucli refresh
252
297
  ucli doctor --output json
253
298
 
254
299
  # Then retry the operation
255
- ucli run <service> <operation>
300
+ ucli oas <service> invokeapi <api>
256
301
  ```
257
302
 
258
303
  ---
@@ -265,37 +310,72 @@ In addition to OpenAPI services, ucli can interact with MCP (Model Context Proto
265
310
 
266
311
  ```bash
267
312
  # Step 1: Discover available MCP servers
268
- ucli mcp list
313
+ ucli listmcp
269
314
 
270
315
  # Step 2: Inspect a server's available tools
271
- ucli mcp tools <server-name>
316
+ ucli mcp <server-name> listtool
272
317
 
273
- # Step 3: Run a tool (args as key=value pairs)
274
- ucli mcp run <server-name> <tool-name> [key=value ...]
318
+ # Step 3: Describe a specific tool's schema (parameters, types)
319
+ ucli mcp <server-name> toolinfo <tool-name>
320
+
321
+ # Step 4: Run a tool (pass arguments as JSON with --data)
322
+ ucli mcp <server-name> invoketool <tool-name> --data <json>
275
323
  ```
276
324
 
277
325
  ### Commands
278
326
 
279
327
  | Command | Description |
280
328
  |---------|-------------|
281
- | `ucli mcp list` | List all MCP servers available to your group |
282
- | `ucli mcp tools <server>` | List tools available on the server |
283
- | `ucli mcp run <server> <tool> [args...]` | Execute a tool on the server |
329
+ | `ucli listmcp` | List all MCP servers available to your group |
330
+ | `ucli mcp <server> listtool` | List tools available on the server |
331
+ | `ucli mcp <server> toolinfo <tool>` | Show detailed parameter schema for a tool |
332
+ | `ucli mcp <server> invoketool <tool> --data <json>` | Execute a tool on the server |
333
+
334
+ ### Tool Introspection (`mcp toolinfo`)
335
+
336
+ Before calling a tool, use `mcp toolinfo` to discover its parameters:
337
+
338
+ ```bash
339
+ # Human-readable description
340
+ ucli mcp weather toolinfo get_forecast
341
+
342
+ # JSON schema (for agent consumption)
343
+ ucli mcp weather toolinfo get_forecast --json
344
+ ```
345
+
346
+ ### JSON Input Mode (`--data`)
347
+
348
+ Pass tool arguments as a JSON object with `--data`:
349
+
350
+ ```bash
351
+ ucli mcp weather invoketool get_forecast --data '{"location": "New York", "units": "metric"}'
352
+ ```
353
+
354
+ ### JSON Output Mode (`--json`)
355
+
356
+ Use `--json` on `mcp invoketool` to get structured JSON envelope output:
357
+
358
+ ```bash
359
+ ucli mcp weather invoketool get_forecast --json --data '{"location": "New York"}'
360
+ ```
284
361
 
285
362
  ### Examples
286
363
 
287
364
  ```bash
288
365
  # List available MCP servers
289
- ucli mcp list
366
+ ucli listmcp
290
367
 
291
368
  # See what tools are available on "weather" server
292
- ucli mcp tools weather
369
+ ucli mcp weather listtool
370
+
371
+ # Describe the get_forecast tool's parameters
372
+ ucli mcp weather toolinfo get_forecast
293
373
 
294
- # Call the get_forecast tool with arguments
295
- ucli mcp run weather get_forecast location="New York" units=metric
374
+ # Call the get_forecast tool with JSON input
375
+ ucli mcp weather invoketool get_forecast --data '{"location": "New York", "units": "metric"}'
296
376
 
297
- # Call a search tool
298
- ucli mcp run search-server web_search query="ucli documentation" limit=5
377
+ # Call a search tool with structured JSON output
378
+ ucli mcp search-server invoketool web_search --json --data '{"query": "ucli documentation", "limit": 5}'
299
379
  ```
300
380
 
301
381
  ---
@@ -306,19 +386,25 @@ ucli mcp run search-server web_search query="ucli documentation" limit=5
306
386
 
307
387
  2. **Always use `--output json`.** This wraps every result in `{ success: true, data }` or `{ success: false, error }`. Never parse human-readable text output.
308
388
 
309
- 3. **Use `--query` to extract.** Instead of parsing the entire response, use JMESPath to extract exactly what you need.
389
+ 3. **Use `--machine` for operation execution.** When running API operations, use `--machine` to get structured envelope output with metadata (timing, method, path). This is more reliable than parsing raw API responses.
310
390
 
311
- 4. **Chain operations.** Use the output of one operation as input to the next:
391
+ 4. **Preview before mutating with `--dry-run`.** Before making POST/PUT/DELETE calls, use `--dry-run` to verify the request URL, headers, and body without actually executing. This prevents accidental mutations.
392
+
393
+ 5. **Use `--query` to extract.** Instead of parsing the entire response, use JMESPath to extract exactly what you need.
394
+
395
+ 6. **Use `mcp toolinfo` before `mcp invoketool`.** Use `ucli mcp <server> toolinfo <tool> --json` to discover a tool's full parameter schema before calling it. This avoids parameter errors.
396
+
397
+ 7. **Use `--data` for tool/API calls.** When calling MCP tools or OAS APIs programmatically, prefer `--data '{"key": "value"}'` to pass arguments as JSON. JSON input is more reliable for complex or nested arguments.
398
+
399
+ 8. **Chain operations.** Use the output of one operation as input to the next:
312
400
  ```bash
313
401
  # Get customer ID, then create a charge
314
- CUSTOMER_ID=$(ucli run crm findCustomer --email user@example.com --query "id" | tr -d '"')
315
- ucli run payments createCharge --data "{\"customerId\": \"$CUSTOMER_ID\", \"amount\": 1000}"
402
+ CUSTOMER_ID=$(ucli oas crm invokeapi findCustomer --params '{"email":"user@example.com"}' --query "id" | tr -d '"')
403
+ ucli oas payments invokeapi createCharge --data "{\"customerId\": \"$CUSTOMER_ID\", \"amount\": 1000}"
316
404
  ```
317
405
 
318
- 5. **Check pagination.** Large result sets may be paginated. Look for `nextPage`, `cursor`, or `Link` headers in the response.
319
-
320
- 6. **Validate before mutating.** For destructive operations (DELETE, large updates), confirm the resource exists and is correct before proceeding.
406
+ 9. **Check pagination.** Large result sets may be paginated. Look for `nextPage`, `cursor`, or `Link` headers in the response.
321
407
 
322
- 7. **Use exit codes for control flow.** Exit code `0` = success, non-zero = failure. Use `--output json` for richer error context.
408
+ 10. **Use exit codes for control flow.** Exit code `0` = success, non-zero = failure. Use `--output json` for richer error context.
323
409
 
324
- 8. **Re-introspect on capability changes.** If you encounter a `not found` error for a service that should exist, run `ucli refresh` then `ucli introspect` to refresh your model of available capabilities.
410
+ 11. **Re-introspect on capability changes.** If you encounter a `not found` error for a service that should exist, run `ucli refresh` then `ucli introspect` to refresh your model of available capabilities.