@tronsfey/ucli 0.5.2 → 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/README.md +102 -89
- package/README.zh.md +80 -92
- package/dist/index.js +629 -502
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/skill.md +73 -65
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
|
|
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
|
|
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": "
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
143
|
+
ucli oas <service> invokeapi <api> [options]
|
|
139
144
|
```
|
|
140
145
|
|
|
141
146
|
### Options
|
|
@@ -154,11 +159,11 @@ Use `--machine` for structured JSON envelope output that agents can parse determ
|
|
|
154
159
|
|
|
155
160
|
```bash
|
|
156
161
|
# Structured success output
|
|
157
|
-
ucli
|
|
162
|
+
ucli oas payments invokeapi listTransactions --machine
|
|
158
163
|
# → { "success": true, "data": {...}, "meta": { "durationMs": 42 } }
|
|
159
164
|
|
|
160
165
|
# Structured error output
|
|
161
|
-
ucli
|
|
166
|
+
ucli oas payments invokeapi getTransaction --params '{"transactionId": "invalid"}' --machine
|
|
162
167
|
# → { "success": false, "error": { "type": "HttpClientError", "message": "...", "statusCode": 404 } }
|
|
163
168
|
```
|
|
164
169
|
|
|
@@ -167,7 +172,7 @@ ucli run payments getTransaction --transactionId invalid --machine
|
|
|
167
172
|
Preview the HTTP request that *would* be sent, without actually executing it:
|
|
168
173
|
|
|
169
174
|
```bash
|
|
170
|
-
ucli
|
|
175
|
+
ucli oas payments invokeapi createCharge --dry-run --data '{"amount": 5000, "currency": "USD"}'
|
|
171
176
|
# → { "method": "POST", "url": "https://api.example.com/charges", "headers": {...}, "body": {...} }
|
|
172
177
|
```
|
|
173
178
|
|
|
@@ -177,34 +182,34 @@ This is useful for verifying parameters before making destructive or costly API
|
|
|
177
182
|
|
|
178
183
|
**List resources (GET):**
|
|
179
184
|
```bash
|
|
180
|
-
ucli
|
|
185
|
+
ucli oas payments invokeapi listTransactions --format json
|
|
181
186
|
```
|
|
182
187
|
|
|
183
188
|
**Filter response:**
|
|
184
189
|
```bash
|
|
185
|
-
ucli
|
|
190
|
+
ucli oas inventory invokeapi listProducts --query "items[?stock > \`0\`].name"
|
|
186
191
|
```
|
|
187
192
|
|
|
188
193
|
**Create a resource (POST):**
|
|
189
194
|
```bash
|
|
190
|
-
ucli
|
|
195
|
+
ucli oas payments invokeapi createCharge --data '{"amount": 5000, "currency": "USD", "customerId": "cus_123"}'
|
|
191
196
|
```
|
|
192
197
|
|
|
193
198
|
**Update a resource (PUT/PATCH):**
|
|
194
199
|
```bash
|
|
195
|
-
ucli
|
|
200
|
+
ucli oas crm invokeapi updateContact --data '{"email": "new@example.com"}' --params '{"contactId": "abc123"}'
|
|
196
201
|
```
|
|
197
202
|
|
|
198
203
|
**Get a specific resource:**
|
|
199
204
|
```bash
|
|
200
|
-
ucli
|
|
205
|
+
ucli oas inventory invokeapi getProduct --params '{"productId": "SKU-001"}'
|
|
201
206
|
```
|
|
202
207
|
|
|
203
208
|
---
|
|
204
209
|
|
|
205
210
|
## Step 4 — Process the Output
|
|
206
211
|
|
|
207
|
-
By default, `ucli
|
|
212
|
+
By default, `ucli oas <service> invokeapi` returns JSON. You can:
|
|
208
213
|
- Parse it directly as structured data
|
|
209
214
|
- Use `--query` to extract specific fields (JMESPath syntax)
|
|
210
215
|
- Use `--format table` for human-readable display
|
|
@@ -232,29 +237,35 @@ By default, `ucli run` returns JSON. You can:
|
|
|
232
237
|
# 1. Discover all capabilities (single call)
|
|
233
238
|
ucli introspect --output json
|
|
234
239
|
|
|
235
|
-
# 2.
|
|
236
|
-
ucli
|
|
240
|
+
# 2. List available services
|
|
241
|
+
ucli listoas
|
|
237
242
|
|
|
238
|
-
# 3.
|
|
239
|
-
ucli
|
|
243
|
+
# 3. Inspect a service's API operations
|
|
244
|
+
ucli oas payments listapi
|
|
240
245
|
|
|
241
|
-
# 4.
|
|
242
|
-
ucli
|
|
246
|
+
# 4. Get detailed info about a specific API
|
|
247
|
+
ucli oas payments apiinfo createCharge
|
|
243
248
|
|
|
244
|
-
# 5.
|
|
245
|
-
ucli
|
|
249
|
+
# 5. Preview a request (dry-run, no execution)
|
|
250
|
+
ucli oas payments invokeapi createCharge --dry-run --data '{"amount": 9900, "currency": "USD"}'
|
|
246
251
|
|
|
247
|
-
# 6.
|
|
248
|
-
ucli
|
|
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 '{
|
|
249
260
|
"amount": 9900,
|
|
250
261
|
"currency": "USD",
|
|
251
262
|
"customerId": "cus_xyz789",
|
|
252
263
|
"description": "Monthly subscription"
|
|
253
264
|
}'
|
|
254
265
|
|
|
255
|
-
#
|
|
256
|
-
ucli mcp
|
|
257
|
-
ucli mcp
|
|
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"}'
|
|
258
269
|
```
|
|
259
270
|
|
|
260
271
|
---
|
|
@@ -264,8 +275,8 @@ ucli mcp run weather get_forecast --input-json '{"location": "New York", "units"
|
|
|
264
275
|
| Error | Cause | Resolution |
|
|
265
276
|
|-------|-------|------------|
|
|
266
277
|
| `Authentication failed` | Token expired or invalid | Run `ucli configure --server <url> --token <jwt>` |
|
|
267
|
-
| `Unknown service: <name>` | Service not registered | Run `ucli
|
|
268
|
-
| `400 Bad Request` | Invalid parameters | Check operation signature with `ucli
|
|
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>` |
|
|
269
280
|
| `404 Not Found` | Resource doesn't exist | Verify the resource ID |
|
|
270
281
|
| `429 Too Many Requests` | Rate limit exceeded | Wait and retry |
|
|
271
282
|
| `5xx Server Error` | Upstream service error | Retry once; if persistent, report to the service owner |
|
|
@@ -286,7 +297,7 @@ ucli refresh
|
|
|
286
297
|
ucli doctor --output json
|
|
287
298
|
|
|
288
299
|
# Then retry the operation
|
|
289
|
-
ucli
|
|
300
|
+
ucli oas <service> invokeapi <api>
|
|
290
301
|
```
|
|
291
302
|
|
|
292
303
|
---
|
|
@@ -299,75 +310,72 @@ In addition to OpenAPI services, ucli can interact with MCP (Model Context Proto
|
|
|
299
310
|
|
|
300
311
|
```bash
|
|
301
312
|
# Step 1: Discover available MCP servers
|
|
302
|
-
ucli
|
|
313
|
+
ucli listmcp
|
|
303
314
|
|
|
304
315
|
# Step 2: Inspect a server's available tools
|
|
305
|
-
ucli mcp
|
|
316
|
+
ucli mcp <server-name> listtool
|
|
306
317
|
|
|
307
318
|
# Step 3: Describe a specific tool's schema (parameters, types)
|
|
308
|
-
ucli mcp
|
|
319
|
+
ucli mcp <server-name> toolinfo <tool-name>
|
|
309
320
|
|
|
310
|
-
# Step 4: Run a tool (
|
|
311
|
-
ucli mcp
|
|
321
|
+
# Step 4: Run a tool (pass arguments as JSON with --data)
|
|
322
|
+
ucli mcp <server-name> invoketool <tool-name> --data <json>
|
|
312
323
|
```
|
|
313
324
|
|
|
314
325
|
### Commands
|
|
315
326
|
|
|
316
327
|
| Command | Description |
|
|
317
328
|
|---------|-------------|
|
|
318
|
-
| `ucli
|
|
319
|
-
| `ucli mcp
|
|
320
|
-
| `ucli mcp
|
|
321
|
-
| `ucli mcp
|
|
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 |
|
|
322
333
|
|
|
323
|
-
### Tool Introspection (`mcp
|
|
334
|
+
### Tool Introspection (`mcp toolinfo`)
|
|
324
335
|
|
|
325
|
-
Before calling a tool, use `mcp
|
|
336
|
+
Before calling a tool, use `mcp toolinfo` to discover its parameters:
|
|
326
337
|
|
|
327
338
|
```bash
|
|
328
339
|
# Human-readable description
|
|
329
|
-
ucli mcp
|
|
340
|
+
ucli mcp weather toolinfo get_forecast
|
|
330
341
|
|
|
331
342
|
# JSON schema (for agent consumption)
|
|
332
|
-
ucli mcp
|
|
343
|
+
ucli mcp weather toolinfo get_forecast --json
|
|
333
344
|
```
|
|
334
345
|
|
|
335
|
-
### JSON Input Mode (`--
|
|
346
|
+
### JSON Input Mode (`--data`)
|
|
336
347
|
|
|
337
|
-
|
|
348
|
+
Pass tool arguments as a JSON object with `--data`:
|
|
338
349
|
|
|
339
350
|
```bash
|
|
340
|
-
ucli mcp
|
|
351
|
+
ucli mcp weather invoketool get_forecast --data '{"location": "New York", "units": "metric"}'
|
|
341
352
|
```
|
|
342
353
|
|
|
343
354
|
### JSON Output Mode (`--json`)
|
|
344
355
|
|
|
345
|
-
Use `--json` on `mcp
|
|
356
|
+
Use `--json` on `mcp invoketool` to get structured JSON envelope output:
|
|
346
357
|
|
|
347
358
|
```bash
|
|
348
|
-
ucli mcp
|
|
359
|
+
ucli mcp weather invoketool get_forecast --json --data '{"location": "New York"}'
|
|
349
360
|
```
|
|
350
361
|
|
|
351
362
|
### Examples
|
|
352
363
|
|
|
353
364
|
```bash
|
|
354
365
|
# List available MCP servers
|
|
355
|
-
ucli
|
|
366
|
+
ucli listmcp
|
|
356
367
|
|
|
357
368
|
# See what tools are available on "weather" server
|
|
358
|
-
ucli mcp
|
|
369
|
+
ucli mcp weather listtool
|
|
359
370
|
|
|
360
371
|
# Describe the get_forecast tool's parameters
|
|
361
|
-
ucli mcp
|
|
362
|
-
|
|
363
|
-
# Call the get_forecast tool with key=value arguments
|
|
364
|
-
ucli mcp run weather get_forecast location="New York" units=metric
|
|
372
|
+
ucli mcp weather toolinfo get_forecast
|
|
365
373
|
|
|
366
|
-
# Call with JSON input
|
|
367
|
-
ucli mcp
|
|
374
|
+
# Call the get_forecast tool with JSON input
|
|
375
|
+
ucli mcp weather invoketool get_forecast --data '{"location": "New York", "units": "metric"}'
|
|
368
376
|
|
|
369
377
|
# Call a search tool with structured JSON output
|
|
370
|
-
ucli mcp
|
|
378
|
+
ucli mcp search-server invoketool web_search --json --data '{"query": "ucli documentation", "limit": 5}'
|
|
371
379
|
```
|
|
372
380
|
|
|
373
381
|
---
|
|
@@ -384,15 +392,15 @@ ucli mcp run search-server web_search --json query="ucli documentation" limit=5
|
|
|
384
392
|
|
|
385
393
|
5. **Use `--query` to extract.** Instead of parsing the entire response, use JMESPath to extract exactly what you need.
|
|
386
394
|
|
|
387
|
-
6. **Use `mcp
|
|
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.
|
|
388
396
|
|
|
389
|
-
7. **Use `--
|
|
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.
|
|
390
398
|
|
|
391
399
|
8. **Chain operations.** Use the output of one operation as input to the next:
|
|
392
400
|
```bash
|
|
393
401
|
# Get customer ID, then create a charge
|
|
394
|
-
CUSTOMER_ID=$(ucli
|
|
395
|
-
ucli
|
|
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}"
|
|
396
404
|
```
|
|
397
405
|
|
|
398
406
|
9. **Check pagination.** Large result sets may be paginated. Look for `nextPage`, `cursor`, or `Link` headers in the response.
|