uxc 0.1.1

Universal X-Protocol Call - Schema-driven multi-protocol RPC execution runtime
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# UXC

**Universal X-Protocol Call**

[![CI](https://github.com/holon-run/uxc/workflows/CI/badge.svg)](https://github.com/holon-run/uxc/actions)
[![Coverage](https://github.com/holon-run/uxc/workflows/Coverage/badge.svg)](https://github.com/holon-run/uxc/actions/workflows/coverage.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Rust](https://img.shields.io/badge/rust-1.83%2B-orange.svg)](https://www.rust-lang.org)

UXC is a schema-driven, multi-protocol RPC execution runtime.

It turns remote, schema-exposed services into executable command-line capabilities — without SDKs, code generation, or preconfigured server aliases.

If a service exposes a machine-readable interface, UXC can discover it, understand it, and execute it.

---

## Vision

Modern systems increasingly expose machine-readable schemas:

* OpenAPI (`/openapi.json`)
* gRPC reflection
* MCP (Model Context Protocol)
* GraphQL introspection
* JSON-RPC (OpenRPC discovery)
* WSDL (SOAP)

Yet interacting with them still requires:

* Static client generation
* SDK installation
* Custom configuration files
* Or embedding tool definitions into AI prompts

UXC removes that friction.

It provides a **universal execution layer** that dynamically transforms remote schema definitions into immediately usable commands.

Schema becomes execution.

---

## Core Principles

### 1. URL-First, Not Config-First

UXC does not require registering server aliases.

```bash
uxc https://api.example.com list
uxc https://api.example.com get:/users/42
```

Any compliant endpoint can be called directly.

This makes UXC safe to use inside:

* Automation scripts
* CI pipelines
* AI skills and agents
* Sandboxed execution environments

---

### 2. Schema-Driven Execution

UXC automatically:

* Detects protocol type
* Retrieves remote schema
* Generates contextual help
* Validates arguments
* Executes calls
* Returns structured JSON by default

No manual client definitions required.

---

### 3. Multi-Protocol by Design

UXC supports multiple schema-exposing protocols through adapters:

* OpenAPI / Swagger
* gRPC (with reflection)
* MCP
* GraphQL
* JSON-RPC (with OpenRPC)
* Extensible adapter system

The CLI interface remains consistent across protocols.

---

### 4. Deterministic Machine Output

`uxc ...` outputs a stable JSON envelope by default:

```json
{
  "ok": true,
  "kind": "call_result",
  "protocol": "openapi",
  "endpoint": "https://api.example.com",
  "operation": "get:/users/{id}",
  "data": { ... },
  "meta": {
    "version": "v1",
    "duration_ms": 128
  }
}
```

Command failures are structured and predictable:

```json
{
  "ok": false,
  "error": {
    "code": "INVALID_ARGUMENT",
    "message": "Field 'id' must be an integer"
  },
  "meta": {
    "version": "v1"
  }
}
```

Use `--text` (or `--format text`) for human-readable output.

Global discovery commands are also JSON-first:

```bash
uxc
uxc help
```

Use `--text` when you want CLI-style help text:

```bash
uxc --text help
```

If an operation ID conflicts with a CLI keyword (for example `help`/`list`), use explicit `call`:

```bash
uxc <host> call <operation_id> [--json '{...}']
```

This makes UXC ideal for:

* Shell pipelines
* Agent runtimes
* Skill systems
* Infrastructure automation

---

## Cache Management

```bash
# View cache statistics
uxc cache stats

# Clear cache for specific endpoint
uxc cache clear https://api.example.com

# Clear all cache
uxc cache clear --all

# Disable cache for this operation
uxc https://api.example.com list --no-cache

# Use custom TTL (in seconds)
uxc https://api.example.com list --cache-ttl 3600
```

## Debugging and Logging

UXC uses structured logging with the `tracing` crate. By default, only warnings and errors are displayed.

```bash
# Default: warnings and errors only
uxc https://api.example.com list

# Enable info logs (HTTP requests, responses, etc.)
RUST_LOG=info uxc https://api.example.com list

# Enable debug logs (detailed debugging information)
RUST_LOG=debug uxc https://api.example.com list

# Enable trace logs (maximum verbosity)
RUST_LOG=trace uxc https://api.example.com list

# Enable logs for specific modules only
RUST_LOG=uxc::adapters::openapi=debug uxc https://api.example.com list
```

**Log Levels:**
- `error` - Critical failures that prevent operation completion
- `warn` - **[Default]** Non-critical issues and warnings
- `info` - Informational messages (HTTP requests, protocol detection, etc.)
- `debug` - Detailed debugging information
- `trace` - Extremely verbose tracing information

Logs are written to stderr to avoid interfering with JSON output on stdout.

## Installation

### Homebrew (macOS/Linux)

```bash
brew tap holon-run/homebrew-tap
brew install uxc
```

### Install Script (macOS/Linux)

```bash
curl -fsSL https://raw.githubusercontent.com/holon-run/uxc/main/scripts/install.sh | bash
```

If you prefer to review before execution:

```bash
curl -fsSL https://raw.githubusercontent.com/holon-run/uxc/main/scripts/install.sh -o install-uxc.sh
less install-uxc.sh
bash install-uxc.sh
```

Install a specific version:

```bash
curl -fsSL https://raw.githubusercontent.com/holon-run/uxc/main/scripts/install.sh | bash -s -- -v v0.1.1
```

### Cargo

```bash
cargo install uxc
```

### From Source

```bash
git clone https://github.com/holon-run/uxc.git
cd uxc
cargo install --path .
```

## Example Usage

### Operation ID Conventions

UXC uses protocol-native, machine-friendly `operation_id` values:

- OpenAPI: `method:/path` (e.g. `get:/users/{id}`, `post:/pet`)
- gRPC: `Service/Method`
- GraphQL: `query/viewer`, `mutation/addStar`, `subscription/onEvent`
- MCP: tool name (e.g. `ask_question`)
- JSON-RPC: method name (e.g. `eth_getBalance`, `net_version`)

### OpenAPI / REST APIs

```bash
# List available operations
uxc https://api.example.com list
uxc petstore3.swagger.io/api/v3 list  # scheme can be omitted for common HTTP targets

# Schema-separated service: runtime endpoint and schema URL are different
uxc https://api.github.com list \
  --schema-url https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json

# Get operation help
uxc https://api.example.com describe get:/users/{id}
uxc https://api.example.com get:/users/{id} help

# Execute with parameters
uxc https://api.example.com get:/users/{id} --json '{"id":42}'

# Execute with JSON input
uxc https://api.example.com call post:/users --json '{"name":"Alice","email":"alice@example.com"}'
```

### gRPC Services

```bash
# List all services via reflection
uxc grpc.example.com:9000 list

# Call a unary RPC
uxc grpc.example.com:9000 addsvc.Add/Sum --json '{"a":1,"b":2}'
```

Note: gRPC unary invocation uses the `grpcurl` binary at runtime.

### GraphQL APIs

```bash
# List available queries/mutations/subscriptions
uxc https://graphql.example.com list

# Execute a query
uxc https://graphql.example.com query/viewer

# Execute with parameters
uxc https://graphql.example.com query/user --json '{"id":"42"}'

# Execute a mutation
uxc https://graphql.example.com mutation/addStar --json '{"starredId":"123"}'
```

### MCP (Model Context Protocol)

```bash
# HTTP transport (recommended for production)
uxc https://mcp-server.example.com list
uxc https://mcp-server.example.com tool_name --json '{"param1":"value1"}'

# If a tool name conflicts with CLI subcommands, use explicit call
uxc https://mcp-server.example.com call help --json '{}'

# stdio transport (for local development)
uxc "npx -y @modelcontextprotocol/server-filesystem /tmp" list
uxc "npx -y @modelcontextprotocol/server-filesystem /tmp" list_directory --json '{"path":"/tmp"}'
```

### JSON-RPC (OpenRPC)

```bash
# Discover methods (requires rpc.discover or openrpc.json)
uxc https://rpc.example.com list

# Describe one method
uxc https://rpc.example.com describe eth_getBalance

# Execute a method
uxc https://rpc.example.com eth_getBalance --json '{"address":"0xabc...","block":"latest"}'
```

Note: JSON-RPC support is OpenRPC-driven for predictable `list/describe` discovery.

## Public Test Endpoints (No API Key)

These endpoints are useful for protocol availability checks without API keys.
Verified on 2026-02-23.

### OpenAPI

- Endpoint: `https://petstore3.swagger.io/api/v3`
- Verify schema:

```bash
curl -sS https://petstore3.swagger.io/api/v3/openapi.json | jq -r '.openapi, .info.title'
```

### GraphQL

- Endpoint: `https://countries.trevorblades.com/`
- Verify introspection:

```bash
curl -sS https://countries.trevorblades.com/ \
  -H 'content-type: application/json' \
  --data '{"query":"{ __schema { queryType { name } } }"}' \
  | jq -r '.data.__schema.queryType.name'
```

### gRPC (Server Reflection)

- Endpoint (plaintext): `grpcb.in:9000`
- Endpoint (TLS): `grpcb.in:9001`
- Verify reflection:

```bash
grpcurl -plaintext grpcb.in:9000 list
grpcurl grpcb.in:9001 list
```

### MCP (HTTP)

- Endpoint: `https://mcp.deepwiki.com/mcp`
- Verify `initialize` (DeepWiki uses streamable HTTP/SSE response):

```bash
curl -sS https://mcp.deepwiki.com/mcp \
  -H 'content-type: application/json' \
  -H 'accept: application/json, text/event-stream' \
  --data '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"uxc-check","version":"0.1"}}}'
```

Note: this endpoint is publicly reachable without an API key for basic calls. Some MCP clients that only expect JSON (not SSE) may need transport updates.

### MCP (stdio, local)

- Command: `npx -y @modelcontextprotocol/server-filesystem /tmp`
- This is useful as a local no-key MCP baseline.

---

## Automatic Protocol Detection

UXC determines the protocol via lightweight probing:

1. Attempt MCP stdio/HTTP discovery
2. Attempt GraphQL introspection
3. Check OpenAPI schema sources:
   - `--schema-url` override
   - user/builtin schema mappings
   - default well-known OpenAPI endpoints (`/openapi.json`, `/swagger.json`, etc.)
4. Attempt JSON-RPC OpenRPC discovery
5. Attempt gRPC reflection
6. Fallback or fail gracefully

Each protocol is handled by a dedicated adapter.

### OpenAPI Schema Mapping

For services where the OpenAPI document is hosted separately from the runtime endpoint
(for example `api.github.com`), UXC supports:

1. Explicit override via `--schema-url`
2. Builtin mappings for known services
3. User mappings in `~/.uxc/schema_mappings.json`

Example user mapping file:

```json
{
  "version": 1,
  "openapi": [
    {
      "host": "api.github.com",
      "path_prefix": "/",
      "schema_url": "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json",
      "priority": 100
    }
  ]
}
```

For tests or custom environments, the mapping file path can be overridden via:
`UXC_SCHEMA_MAPPINGS_FILE=/path/to/schema_mappings.json`.

---

## Architecture Overview

```
User / Skill / Agent
          UXC CLI
    Protocol Detector
       Adapter Layer
   ├── OpenAPI Adapter
   ├── gRPC Adapter
   ├── MCP Adapter
   ├── GraphQL Adapter
   ├── JSON-RPC Adapter
     Remote Endpoint
```

Optional:

```
UXCd (local daemon)
  - Connection pooling
  - Schema caching
  - Authentication management
  - Rate limiting
```

The CLI works independently, but can transparently use the daemon for performance and stability.

---

## Target Use Cases

### AI Agents & Skills

* Dynamically call remote capabilities
* Avoid injecting large tool schemas into context
* Maintain deterministic execution boundaries

### Infrastructure & DevOps

* Replace SDK generation with runtime discovery
* Interact with heterogeneous services via a unified interface
* Simplify testing across protocols

### Execution Sandboxes

* Provide a controlled, auditable capability layer
* Enforce allowlists and rate limits
* Record structured invocation logs

---

## Non-Goals

UXC is not:

* A code generator
* An SDK replacement
* An API gateway
* A reverse proxy

It is an execution interface.

---

## Why Universal X-Protocol Call?

Because infrastructure is no longer protocol-bound.

Because services describe themselves.

Because execution should be dynamic.

UXC makes remote schema executable.

---

## Development Status

**Current Version**: v0.1.0 (Alpha)

**Supported Protocols**:
- ✅ OpenAPI 3.x
- ✅ gRPC (with Server Reflection Protocol)
- ✅ GraphQL (with Introspection)
- ✅ MCP (Model Context Protocol) - HTTP & stdio transports
- ✅ JSON-RPC (with OpenRPC discovery)

**Platforms**:
- ✅ Linux (x86_64)
- ✅ macOS (x86_64, ARM64)
- ✅ Windows (x86_64)

**Known Limitations**:
- gRPC currently supports unary invocation only
- gRPC runtime calls require `grpcurl` to be installed
- No connection pooling yet

---

## Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

**Development Requirements**:
- All code must be formatted with `cargo fmt`
- No clippy warnings allowed
- Minimum 65% code coverage required
- All tests must pass

See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed development workflow, testing guidelines, and coverage instructions.

**Areas of Interest**:
- Connection pooling
- Authentication profiles
- Additional protocol adapters (SOAP/WSDL, Thrift, etc.)
- Performance optimizations
- UXCd daemon
- Capability allowlists
- Audit logging

---

## License

MIT License - see LICENSE file for details