@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/README.md +137 -66
- package/README.zh.md +115 -69
- 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 +636 -446
- 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 +134 -48
- package/dist/runner-HH357SRR.js.map +0 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
- **Discover** OpenAPI services registered on a ucli server
|
|
21
21
|
- **Execute** API operations without ever handling credentials directly
|
|
22
22
|
- **Cache** specs locally to reduce round-trips
|
|
23
|
-
- **Invoke** MCP server tools via `ucli mcp
|
|
23
|
+
- **Invoke** MCP server tools via `ucli mcp <server> invoketool <tool>`
|
|
24
24
|
|
|
25
25
|
Auth credentials (bearer tokens, API keys, OAuth2 secrets, MCP headers/env) are stored encrypted on the server and injected at runtime — they are **never written to disk** or visible in process listings.
|
|
26
26
|
|
|
@@ -37,7 +37,7 @@ sequenceDiagram
|
|
|
37
37
|
Agent->>CLI: ucli configure --server URL --token JWT
|
|
38
38
|
CLI->>CLI: Save config (OS config dir)
|
|
39
39
|
|
|
40
|
-
Agent->>CLI: ucli
|
|
40
|
+
Agent->>CLI: ucli listoas
|
|
41
41
|
CLI->>Cache: Check local cache (TTL)
|
|
42
42
|
alt Cache miss
|
|
43
43
|
CLI->>Server: GET /api/v1/oas (Bearer JWT)
|
|
@@ -47,7 +47,7 @@ sequenceDiagram
|
|
|
47
47
|
Cache-->>CLI: OAS list
|
|
48
48
|
CLI-->>Agent: Table / JSON output
|
|
49
49
|
|
|
50
|
-
Agent->>CLI: ucli
|
|
50
|
+
Agent->>CLI: ucli oas payments invokeapi createPayment --data '{...}'
|
|
51
51
|
CLI->>Server: GET /api/v1/oas/payments (Bearer JWT)
|
|
52
52
|
Server-->>CLI: OAS spec + decrypted authConfig (TLS)
|
|
53
53
|
CLI->>CLI: Inject authConfig as ENV vars
|
|
@@ -55,7 +55,7 @@ sequenceDiagram
|
|
|
55
55
|
API-->>CLI: HTTP response
|
|
56
56
|
CLI-->>Agent: Formatted output (JSON / table / YAML)
|
|
57
57
|
|
|
58
|
-
Agent->>CLI: ucli mcp
|
|
58
|
+
Agent->>CLI: ucli mcp my-server invoketool get_weather --data '{"city":"Beijing"}'
|
|
59
59
|
CLI->>Server: GET /api/v1/mcp/my-server (Bearer JWT)
|
|
60
60
|
Server-->>CLI: McpEntry + decrypted authConfig (TLS)
|
|
61
61
|
CLI->>CLI: Inject auth as headers/env into mcp2cli config
|
|
@@ -79,13 +79,13 @@ pnpm add -g @tronsfey/ucli
|
|
|
79
79
|
ucli configure --server http://localhost:3000 --token <group-jwt>
|
|
80
80
|
|
|
81
81
|
# 2. List available services
|
|
82
|
-
ucli
|
|
82
|
+
ucli listoas
|
|
83
83
|
|
|
84
84
|
# 3. Inspect a service's operations
|
|
85
|
-
ucli
|
|
85
|
+
ucli oas payments listapi
|
|
86
86
|
|
|
87
87
|
# 4. Run an operation
|
|
88
|
-
ucli
|
|
88
|
+
ucli oas payments invokeapi getPetById --params '{"petId": 42}'
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
## Command Reference
|
|
@@ -109,12 +109,12 @@ Config is stored in the OS-appropriate config directory:
|
|
|
109
109
|
|
|
110
110
|
---
|
|
111
111
|
|
|
112
|
-
### `
|
|
112
|
+
### `listoas`
|
|
113
113
|
|
|
114
114
|
List all OpenAPI services available to your group.
|
|
115
115
|
|
|
116
116
|
```bash
|
|
117
|
-
ucli
|
|
117
|
+
ucli listoas [--format table|json|yaml] [--refresh]
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
| Flag | Default | Description |
|
|
@@ -125,84 +125,108 @@ ucli services list [--format table|json|yaml] [--refresh]
|
|
|
125
125
|
**Example output (table):**
|
|
126
126
|
|
|
127
127
|
```
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
SERVICE AUTH DESCRIPTION
|
|
129
|
+
---------- -------- ------------------------------------------
|
|
130
|
+
payments bearer Payments service API
|
|
131
|
+
inventory api_key Inventory management
|
|
132
|
+
crm oauth2_cc CRM operations
|
|
132
133
|
```
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### `oas <service> info`
|
|
138
|
+
|
|
139
|
+
Show detailed information about a specific service.
|
|
135
140
|
|
|
136
|
-
```
|
|
137
|
-
[
|
|
138
|
-
{ "name": "payments", "description": "Payments service API", "cacheTtl": 3600 },
|
|
139
|
-
{ "name": "inventory", "description": "Inventory management", "cacheTtl": 1800 }
|
|
140
|
-
]
|
|
141
|
+
```bash
|
|
142
|
+
ucli oas <service> info [--format json|table|yaml]
|
|
141
143
|
```
|
|
142
144
|
|
|
145
|
+
| Argument/Flag | Description |
|
|
146
|
+
|---------------|-------------|
|
|
147
|
+
| `<service>` | Service name from `listoas` |
|
|
148
|
+
| `--format` | Output format (`json` default) |
|
|
149
|
+
|
|
143
150
|
---
|
|
144
151
|
|
|
145
|
-
### `
|
|
152
|
+
### `oas <service> listapi`
|
|
146
153
|
|
|
147
|
-
|
|
154
|
+
List all available API operations for a service.
|
|
148
155
|
|
|
149
156
|
```bash
|
|
150
|
-
ucli
|
|
157
|
+
ucli oas <service> listapi [--format json|table|yaml]
|
|
151
158
|
```
|
|
152
159
|
|
|
153
160
|
| Argument/Flag | Description |
|
|
154
161
|
|---------------|-------------|
|
|
155
|
-
| `<
|
|
156
|
-
| `--format` | Output format (`
|
|
162
|
+
| `<service>` | Service name from `listoas` |
|
|
163
|
+
| `--format` | Output format (`json` default) |
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### `oas <service> apiinfo <api>`
|
|
168
|
+
|
|
169
|
+
Show detailed input/output parameters for a specific API operation.
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
ucli oas <service> apiinfo <api>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
| Argument | Description |
|
|
176
|
+
|----------|-------------|
|
|
177
|
+
| `<service>` | Service name from `listoas` |
|
|
178
|
+
| `<api>` | Operation ID from `oas <service> listapi` |
|
|
157
179
|
|
|
158
180
|
---
|
|
159
181
|
|
|
160
|
-
### `
|
|
182
|
+
### `oas <service> invokeapi <api>`
|
|
161
183
|
|
|
162
184
|
Execute a single API operation defined in an OpenAPI spec.
|
|
163
185
|
|
|
164
186
|
```bash
|
|
165
|
-
ucli
|
|
187
|
+
ucli oas <service> invokeapi <api> [options]
|
|
166
188
|
```
|
|
167
189
|
|
|
168
190
|
| Flag | Required | Description |
|
|
169
191
|
|------|----------|-------------|
|
|
170
|
-
| `--
|
|
171
|
-
| `--
|
|
172
|
-
| `--params` | No | JSON string of parameters (path, query, body merged) |
|
|
192
|
+
| `--data` | No | Request body (JSON string or @filename) |
|
|
193
|
+
| `--params` | No | JSON string of parameters (path, query merged) |
|
|
173
194
|
| `--format` | No | Output format: `json` (default), `table`, `yaml` |
|
|
174
195
|
| `--query` | No | JMESPath expression to filter the response |
|
|
196
|
+
| `--machine` | No | Structured JSON envelope output (agent-friendly) |
|
|
197
|
+
| `--dry-run` | No | Preview the HTTP request without executing (implies `--machine`) |
|
|
175
198
|
|
|
176
199
|
**Examples:**
|
|
177
200
|
|
|
178
201
|
```bash
|
|
179
202
|
# GET with path parameter
|
|
180
|
-
ucli
|
|
181
|
-
--params '{"petId": 42}'
|
|
203
|
+
ucli oas petstore invokeapi getPetById --params '{"petId": 42}'
|
|
182
204
|
|
|
183
205
|
# POST with body
|
|
184
|
-
ucli
|
|
185
|
-
--
|
|
186
|
-
--format json
|
|
206
|
+
ucli oas payments invokeapi createPayment \
|
|
207
|
+
--data '{"amount": 100, "currency": "USD", "recipient": "acct_123"}'
|
|
187
208
|
|
|
188
209
|
# GET with query parameter + JMESPath filter
|
|
189
|
-
ucli
|
|
210
|
+
ucli oas inventory invokeapi listProducts \
|
|
190
211
|
--params '{"category": "electronics", "limit": 10}' \
|
|
191
212
|
--query 'items[?price < `50`].name'
|
|
192
213
|
|
|
193
|
-
#
|
|
194
|
-
ucli
|
|
195
|
-
|
|
214
|
+
# Agent-friendly structured output
|
|
215
|
+
ucli oas payments invokeapi listTransactions --machine
|
|
216
|
+
|
|
217
|
+
# Preview request without executing
|
|
218
|
+
ucli oas payments invokeapi createPayment --dry-run \
|
|
219
|
+
--data '{"amount": 5000, "currency": "USD"}'
|
|
196
220
|
```
|
|
197
221
|
|
|
198
222
|
---
|
|
199
223
|
|
|
200
|
-
### `
|
|
224
|
+
### `listmcp`
|
|
201
225
|
|
|
202
226
|
List all MCP servers available to your group.
|
|
203
227
|
|
|
204
228
|
```bash
|
|
205
|
-
ucli
|
|
229
|
+
ucli listmcp [--format table|json|yaml]
|
|
206
230
|
```
|
|
207
231
|
|
|
208
232
|
| Flag | Default | Description |
|
|
@@ -211,39 +235,71 @@ ucli mcp list [--format table|json|yaml]
|
|
|
211
235
|
|
|
212
236
|
---
|
|
213
237
|
|
|
214
|
-
### `mcp
|
|
238
|
+
### `mcp <server> listtool`
|
|
215
239
|
|
|
216
240
|
List tools available on a specific MCP server.
|
|
217
241
|
|
|
218
242
|
```bash
|
|
219
|
-
ucli mcp
|
|
243
|
+
ucli mcp <server> listtool [--format table|json|yaml]
|
|
220
244
|
```
|
|
221
245
|
|
|
222
246
|
| Argument/Flag | Description |
|
|
223
247
|
|---------------|-------------|
|
|
224
|
-
| `<server
|
|
248
|
+
| `<server>` | MCP server name from `listmcp` |
|
|
225
249
|
| `--format` | Output format (`table` default) |
|
|
226
250
|
|
|
227
251
|
---
|
|
228
252
|
|
|
229
|
-
### `mcp
|
|
253
|
+
### `mcp <server> toolinfo <tool>`
|
|
254
|
+
|
|
255
|
+
Show detailed parameter schema for a tool on a MCP server.
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
ucli mcp <server> toolinfo <tool> [--json]
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
| Argument/Flag | Description |
|
|
262
|
+
|---------------|-------------|
|
|
263
|
+
| `<server>` | MCP server name from `listmcp` |
|
|
264
|
+
| `<tool>` | Tool name from `mcp <server> listtool` |
|
|
265
|
+
| `--json` | Output full schema as JSON (for agent consumption) |
|
|
266
|
+
|
|
267
|
+
**Examples:**
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
# Human-readable tool description
|
|
271
|
+
ucli mcp weather toolinfo get_forecast
|
|
272
|
+
|
|
273
|
+
# JSON schema (for agent introspection)
|
|
274
|
+
ucli mcp weather toolinfo get_forecast --json
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
### `mcp <server> invoketool <tool>`
|
|
230
280
|
|
|
231
281
|
Execute a tool on an MCP server.
|
|
232
282
|
|
|
233
283
|
```bash
|
|
234
|
-
ucli mcp
|
|
284
|
+
ucli mcp <server> invoketool <tool> [--data <json>] [--json]
|
|
235
285
|
```
|
|
236
286
|
|
|
237
|
-
|
|
287
|
+
| Flag | Description |
|
|
288
|
+
|------|-------------|
|
|
289
|
+
| `--data` | Tool arguments as a JSON object |
|
|
290
|
+
| `--json` | Machine-readable JSON output |
|
|
238
291
|
|
|
239
292
|
**Examples:**
|
|
240
293
|
|
|
241
294
|
```bash
|
|
242
|
-
# Call a weather tool
|
|
243
|
-
ucli mcp
|
|
295
|
+
# Call a weather tool with JSON input
|
|
296
|
+
ucli mcp weather invoketool get_forecast --data '{"location": "New York", "units": "metric"}'
|
|
244
297
|
|
|
245
298
|
# Call a search tool
|
|
246
|
-
ucli mcp
|
|
299
|
+
ucli mcp search-server invoketool web_search --data '{"query": "ucli MCP", "limit": 5}'
|
|
300
|
+
|
|
301
|
+
# Get structured JSON output
|
|
302
|
+
ucli mcp weather invoketool get_forecast --json --data '{"location": "New York"}'
|
|
247
303
|
```
|
|
248
304
|
|
|
249
305
|
---
|
|
@@ -284,7 +340,7 @@ Config is managed via the `configure` command. Values are stored in the OS confi
|
|
|
284
340
|
- OAS entries are cached locally as JSON files in the OS temp dir (`ucli/` subdirectory)
|
|
285
341
|
- Cache TTL per entry is set by the server admin via the `cacheTtl` field (seconds)
|
|
286
342
|
- Expired entries are automatically re-fetched on next access
|
|
287
|
-
- Force a refresh: `ucli refresh` or use `--refresh` flag on `
|
|
343
|
+
- Force a refresh: `ucli refresh` or use `--refresh` flag on `listoas`
|
|
288
344
|
|
|
289
345
|
## Auth Handling
|
|
290
346
|
|
|
@@ -309,28 +365,43 @@ The recommended workflow for AI agents using `ucli` as a skill:
|
|
|
309
365
|
|
|
310
366
|
```bash
|
|
311
367
|
# Step 1: Discover available services
|
|
312
|
-
ucli
|
|
368
|
+
ucli listoas --format json
|
|
313
369
|
|
|
314
370
|
# Step 2: Inspect a service to see available operations
|
|
315
|
-
ucli
|
|
371
|
+
ucli oas <service-name> listapi --format json
|
|
372
|
+
|
|
373
|
+
# Step 3: Get detailed info about a specific API
|
|
374
|
+
ucli oas <service-name> apiinfo <api>
|
|
316
375
|
|
|
317
|
-
# Step
|
|
318
|
-
ucli
|
|
319
|
-
--
|
|
376
|
+
# Step 4: Preview a request (dry-run — no execution)
|
|
377
|
+
ucli oas <service-name> invokeapi <api> --dry-run \
|
|
378
|
+
--data '{ ... }'
|
|
320
379
|
|
|
321
|
-
# Step
|
|
322
|
-
ucli
|
|
380
|
+
# Step 5: Execute an operation with structured output
|
|
381
|
+
ucli oas <service-name> invokeapi <api> \
|
|
382
|
+
--data '{ ... }' --machine
|
|
383
|
+
|
|
384
|
+
# Step 6: Filter results with JMESPath
|
|
385
|
+
ucli oas inventory invokeapi listProducts \
|
|
323
386
|
--query 'items[?inStock == `true`] | [0:5]'
|
|
324
387
|
|
|
325
|
-
# Step
|
|
326
|
-
PRODUCT_ID=$(ucli
|
|
388
|
+
# Step 7: Chain operations (use output from one as input to another)
|
|
389
|
+
PRODUCT_ID=$(ucli oas inventory invokeapi listProducts \
|
|
327
390
|
--query 'items[0].id' | tr -d '"')
|
|
328
|
-
ucli
|
|
329
|
-
--
|
|
391
|
+
ucli oas orders invokeapi createOrder \
|
|
392
|
+
--data "{\"productId\": \"$PRODUCT_ID\", \"quantity\": 1}"
|
|
393
|
+
|
|
394
|
+
# Step 8: MCP — inspect a tool, then call it with JSON input
|
|
395
|
+
ucli mcp weather toolinfo get_forecast --json
|
|
396
|
+
ucli mcp weather invoketool get_forecast --data '{"location": "New York", "units": "metric"}'
|
|
330
397
|
```
|
|
331
398
|
|
|
332
399
|
**Tips for agents:**
|
|
333
|
-
- Always run `
|
|
400
|
+
- Always run `ucli listoas` first to discover what's available
|
|
401
|
+
- Use `--machine` for structured envelope output from API operations
|
|
402
|
+
- Use `--dry-run` to preview requests before executing destructive operations
|
|
403
|
+
- Use `ucli mcp <server> toolinfo <tool> --json` to discover tool parameters
|
|
404
|
+
- Use `--data` for both MCP tool calls and OAS API calls (JSON input)
|
|
334
405
|
- Use `--format json` for programmatic parsing
|
|
335
406
|
- Use `--query` with JMESPath to extract specific fields
|
|
336
407
|
- Check pagination fields (`nextPage`, `totalCount`) for list operations
|
|
@@ -341,9 +412,9 @@ ucli run --service orders --operation createOrder \
|
|
|
341
412
|
| Error | Likely Cause | Resolution |
|
|
342
413
|
|-------|-------------|------------|
|
|
343
414
|
| `Unauthorized (401)` | JWT expired or revoked | Get a new token from the admin |
|
|
344
|
-
| `Service not found` | Service name misspelled or not in group | Run `
|
|
345
|
-
| `Operation not found` | Invalid `operationId` | Run `
|
|
346
|
-
| `MCP server not found` | Server name misspelled or not in group | Run `ucli
|
|
347
|
-
| `Tool not found` | Invalid tool name | Run `ucli mcp
|
|
415
|
+
| `Service not found` | Service name misspelled or not in group | Run `ucli listoas` to see available services |
|
|
416
|
+
| `Operation not found` | Invalid `operationId` | Run `ucli oas <service> listapi` to see valid operations |
|
|
417
|
+
| `MCP server not found` | Server name misspelled or not in group | Run `ucli listmcp` to see available servers |
|
|
418
|
+
| `Tool not found` | Invalid tool name | Run `ucli mcp <server> listtool` to see available tools |
|
|
348
419
|
| `Connection refused` | Server not running or wrong URL | Check server URL with `ucli configure` |
|
|
349
420
|
| `Cache error` | Temp dir permissions issue | Run `ucli refresh` to reset cache |
|