@tronsfey/ucli 0.5.2 → 0.5.4

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 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 run`
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 services list
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 run --service payments --operation createPayment --params '{...}'
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 run my-server get_weather --city Beijing
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 services list
82
+ ucli listoas
83
83
 
84
84
  # 3. Inspect a service's operations
85
- ucli services info payments
85
+ ucli oas payments listapi
86
86
 
87
87
  # 4. Run an operation
88
- ucli run --service payments --operation getPetById --params '{"petId": 42}'
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
- ### `services list`
112
+ ### `listoas`
113
113
 
114
114
  List all OpenAPI services available to your group.
115
115
 
116
116
  ```bash
117
- ucli services list [--format table|json|yaml] [--refresh]
117
+ ucli listoas [--format table|json|yaml] [--refresh]
118
118
  ```
119
119
 
120
120
  | Flag | Default | Description |
@@ -125,51 +125,72 @@ ucli services list [--format table|json|yaml] [--refresh]
125
125
  **Example output (table):**
126
126
 
127
127
  ```
128
- NAME DESCRIPTION CACHE TTL
129
- payments Payments service API 3600s
130
- inventory Inventory management 1800s
131
- crm CRM operations 7200s
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
- **Example output (json):**
135
+ ---
136
+
137
+ ### `oas <service> info`
138
+
139
+ Show detailed information about a specific service.
135
140
 
136
- ```json
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
- ### `services info <name>`
152
+ ### `oas <service> listapi`
146
153
 
147
- Show detailed information about a specific service, including its available operations.
154
+ List all available API operations for a service.
148
155
 
149
156
  ```bash
150
- ucli services info <service-name> [--format table|json|yaml]
157
+ ucli oas <service> listapi [--format json|table|yaml]
151
158
  ```
152
159
 
153
160
  | Argument/Flag | Description |
154
161
  |---------------|-------------|
155
- | `<name>` | Service name from `services list` |
156
- | `--format` | Output format (`table` default) |
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
- ### `run`
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 run --service <name> --operation <operationId> [options]
187
+ ucli oas <service> invokeapi <api> [options]
166
188
  ```
167
189
 
168
190
  | Flag | Required | Description |
169
191
  |------|----------|-------------|
170
- | `--service` | Yes | Service name (from `services list`) |
171
- | `--operation` | Yes | `operationId` from the OpenAPI spec |
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 |
175
196
  | `--machine` | No | Structured JSON envelope output (agent-friendly) |
@@ -179,39 +200,33 @@ ucli run --service <name> --operation <operationId> [options]
179
200
 
180
201
  ```bash
181
202
  # GET with path parameter
182
- ucli run --service petstore --operation getPetById \
183
- --params '{"petId": 42}'
203
+ ucli oas petstore invokeapi getPetById --params '{"petId": 42}'
184
204
 
185
205
  # POST with body
186
- ucli run --service payments --operation createPayment \
187
- --params '{"amount": 100, "currency": "USD", "recipient": "acct_123"}' \
188
- --format json
206
+ ucli oas payments invokeapi createPayment \
207
+ --data '{"amount": 100, "currency": "USD", "recipient": "acct_123"}'
189
208
 
190
209
  # GET with query parameter + JMESPath filter
191
- ucli run --service inventory --operation listProducts \
210
+ ucli oas inventory invokeapi listProducts \
192
211
  --params '{"category": "electronics", "limit": 10}' \
193
212
  --query 'items[?price < `50`].name'
194
213
 
195
- # POST with data from file
196
- ucli run --service crm --operation createContact \
197
- --params "@./contact.json"
198
-
199
214
  # Agent-friendly structured output
200
- ucli run --service payments --operation listTransactions --machine
215
+ ucli oas payments invokeapi listTransactions --machine
201
216
 
202
217
  # Preview request without executing
203
- ucli run --service payments --operation createPayment --dry-run \
218
+ ucli oas payments invokeapi createPayment --dry-run \
204
219
  --data '{"amount": 5000, "currency": "USD"}'
205
220
  ```
206
221
 
207
222
  ---
208
223
 
209
- ### `mcp list`
224
+ ### `listmcp`
210
225
 
211
226
  List all MCP servers available to your group.
212
227
 
213
228
  ```bash
214
- ucli mcp list [--format table|json|yaml]
229
+ ucli listmcp [--format table|json|yaml]
215
230
  ```
216
231
 
217
232
  | Flag | Default | Description |
@@ -220,76 +235,71 @@ ucli mcp list [--format table|json|yaml]
220
235
 
221
236
  ---
222
237
 
223
- ### `mcp tools <server>`
238
+ ### `mcp <server> listtool`
224
239
 
225
240
  List tools available on a specific MCP server.
226
241
 
227
242
  ```bash
228
- ucli mcp tools <server-name> [--format table|json]
243
+ ucli mcp <server> listtool [--format table|json|yaml]
229
244
  ```
230
245
 
231
246
  | Argument/Flag | Description |
232
247
  |---------------|-------------|
233
- | `<server-name>` | MCP server name from `mcp list` |
248
+ | `<server>` | MCP server name from `listmcp` |
234
249
  | `--format` | Output format (`table` default) |
235
250
 
236
251
  ---
237
252
 
238
- ### `mcp describe <server> <tool>`
253
+ ### `mcp <server> toolinfo <tool>`
239
254
 
240
255
  Show detailed parameter schema for a tool on a MCP server.
241
256
 
242
257
  ```bash
243
- ucli mcp describe <server-name> <tool-name> [--json]
258
+ ucli mcp <server> toolinfo <tool> [--json]
244
259
  ```
245
260
 
246
261
  | Argument/Flag | Description |
247
262
  |---------------|-------------|
248
- | `<server-name>` | MCP server name from `mcp list` |
249
- | `<tool-name>` | Tool name from `mcp tools` |
263
+ | `<server>` | MCP server name from `listmcp` |
264
+ | `<tool>` | Tool name from `mcp <server> listtool` |
250
265
  | `--json` | Output full schema as JSON (for agent consumption) |
251
266
 
252
267
  **Examples:**
253
268
 
254
269
  ```bash
255
270
  # Human-readable tool description
256
- ucli mcp describe weather get_forecast
271
+ ucli mcp weather toolinfo get_forecast
257
272
 
258
273
  # JSON schema (for agent introspection)
259
- ucli mcp describe weather get_forecast --json
274
+ ucli mcp weather toolinfo get_forecast --json
260
275
  ```
261
276
 
262
277
  ---
263
278
 
264
- ### `mcp run <server> <tool> [args...]`
279
+ ### `mcp <server> invoketool <tool>`
265
280
 
266
281
  Execute a tool on an MCP server.
267
282
 
268
283
  ```bash
269
- ucli mcp run <server-name> <tool-name> [args...]
284
+ ucli mcp <server> invoketool <tool> [--data <json>] [--json]
270
285
  ```
271
286
 
272
- Args are passed as `key=value` pairs and converted to a JSON object, or use `--input-json` for direct JSON input.
273
-
274
287
  | Flag | Description |
275
288
  |------|-------------|
289
+ | `--data` | Tool arguments as a JSON object |
276
290
  | `--json` | Machine-readable JSON output |
277
- | `--input-json` | Pass tool arguments as a JSON object (preferred for agents) |
278
291
 
279
292
  **Examples:**
280
293
 
281
294
  ```bash
282
- # Call a weather tool with key=value args
283
- ucli mcp run weather get_forecast location="New York" units=metric
295
+ # Call a weather tool with JSON input
296
+ ucli mcp weather invoketool get_forecast --data '{"location": "New York", "units": "metric"}'
284
297
 
285
298
  # Call a search tool
286
- ucli mcp run search-server web_search query="ucli MCP" limit=5
287
-
288
- # Call with JSON input (preferred for agents)
289
- ucli mcp run weather get_forecast --input-json '{"location": "New York", "units": "metric"}'
299
+ ucli mcp search-server invoketool web_search --data '{"query": "ucli MCP", "limit": 5}'
290
300
 
291
301
  # Get structured JSON output
292
- ucli mcp run weather get_forecast --json location="New York"
302
+ ucli mcp weather invoketool get_forecast --json --data '{"location": "New York"}'
293
303
  ```
294
304
 
295
305
  ---
@@ -330,7 +340,7 @@ Config is managed via the `configure` command. Values are stored in the OS confi
330
340
  - OAS entries are cached locally as JSON files in the OS temp dir (`ucli/` subdirectory)
331
341
  - Cache TTL per entry is set by the server admin via the `cacheTtl` field (seconds)
332
342
  - Expired entries are automatically re-fetched on next access
333
- - Force a refresh: `ucli refresh` or use `--refresh` flag on `services list`
343
+ - Force a refresh: `ucli refresh` or use `--refresh` flag on `listoas`
334
344
 
335
345
  ## Auth Handling
336
346
 
@@ -355,40 +365,43 @@ The recommended workflow for AI agents using `ucli` as a skill:
355
365
 
356
366
  ```bash
357
367
  # Step 1: Discover available services
358
- ucli services list --format json
368
+ ucli listoas --format json
359
369
 
360
370
  # Step 2: Inspect a service to see available operations
361
- ucli services info <service-name> --format json
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>
362
375
 
363
- # Step 3: Preview a request (dry-run — no execution)
364
- ucli run --service <name> --operation <operationId> --dry-run \
365
- --params '{ ... }'
376
+ # Step 4: Preview a request (dry-run — no execution)
377
+ ucli oas <service-name> invokeapi <api> --dry-run \
378
+ --data '{ ... }'
366
379
 
367
- # Step 4: Execute an operation with structured output
368
- ucli run --service <name> --operation <operationId> \
369
- --params '{ ... }' --machine
380
+ # Step 5: Execute an operation with structured output
381
+ ucli oas <service-name> invokeapi <api> \
382
+ --data '{ ... }' --machine
370
383
 
371
- # Step 5: Filter results with JMESPath
372
- ucli run --service inventory --operation listProducts \
384
+ # Step 6: Filter results with JMESPath
385
+ ucli oas inventory invokeapi listProducts \
373
386
  --query 'items[?inStock == `true`] | [0:5]'
374
387
 
375
- # Step 6: Chain operations (use output from one as input to another)
376
- PRODUCT_ID=$(ucli run --service inventory --operation listProducts \
388
+ # Step 7: Chain operations (use output from one as input to another)
389
+ PRODUCT_ID=$(ucli oas inventory invokeapi listProducts \
377
390
  --query 'items[0].id' | tr -d '"')
378
- ucli run --service orders --operation createOrder \
379
- --params "{\"productId\": \"$PRODUCT_ID\", \"quantity\": 1}"
391
+ ucli oas orders invokeapi createOrder \
392
+ --data "{\"productId\": \"$PRODUCT_ID\", \"quantity\": 1}"
380
393
 
381
- # Step 7: MCP — describe a tool, then call it with JSON input
382
- ucli mcp describe weather get_forecast --json
383
- ucli mcp run weather get_forecast --input-json '{"location": "New York", "units": "metric"}'
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"}'
384
397
  ```
385
398
 
386
399
  **Tips for agents:**
387
- - Always run `services list` first to discover what's available
400
+ - Always run `ucli listoas` first to discover what's available
388
401
  - Use `--machine` for structured envelope output from API operations
389
402
  - Use `--dry-run` to preview requests before executing destructive operations
390
- - Use `mcp describe <server> <tool> --json` to discover tool parameters
391
- - Use `--input-json` for MCP tool calls (more reliable than `key=value` for complex args)
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)
392
405
  - Use `--format json` for programmatic parsing
393
406
  - Use `--query` with JMESPath to extract specific fields
394
407
  - Check pagination fields (`nextPage`, `totalCount`) for list operations
@@ -399,9 +412,9 @@ ucli mcp run weather get_forecast --input-json '{"location": "New York", "units"
399
412
  | Error | Likely Cause | Resolution |
400
413
  |-------|-------------|------------|
401
414
  | `Unauthorized (401)` | JWT expired or revoked | Get a new token from the admin |
402
- | `Service not found` | Service name misspelled or not in group | Run `services list` to see available services |
403
- | `Operation not found` | Invalid `operationId` | Run `services info <name>` to see valid operations |
404
- | `MCP server not found` | Server name misspelled or not in group | Run `ucli mcp list` to see available servers |
405
- | `Tool not found` | Invalid tool name | Run `ucli mcp tools <server>` to see available tools |
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 |
406
419
  | `Connection refused` | Server not running or wrong URL | Check server URL with `ucli configure` |
407
420
  | `Cache error` | Temp dir permissions issue | Run `ucli refresh` to reset cache |