๐ Features
- ๐ 12 Transport Protocols - HTTP, MCP, WebSocket, gRPC, CLI, GraphQL, TCP, UDP, SSE, WebRTC, HTTP Streams, and Text-based
- ๐ Async/Await Native - Built with Tokio for high-performance concurrent operations
- ๐ฆ Config-Driven - Load tool providers from JSON with automatic discovery and registration
- ๐ Smart Tool Discovery - Tag-based semantic search across all registered tools
- ๐ค LLM Integration - Built-in Codemode orchestrator for AI-driven workflows
- ๐ Auto-Migration - Seamless compatibility with UTCP v0.1 and v1.0 formats
- ๐ OpenAPI Support - Automatic tool generation from OpenAPI 3.0 specifications
- ๐ Multi-Auth - Support for API keys, Basic Auth, OAuth2, and custom authentication
- ๐พ Streaming - First-class support for streaming responses across compatible transports
- ๐งช Well-Tested - 90+ tests ensuring reliability and correctness
๐ฆ Installation
Add rs-utcp to your Cargo.toml:
[]
= "0.1.8"
= { = "1.0", = ["full"] }
Or use cargo add:
๐ Quick Start
Basic Usage
use ;
use ;
async
Configuration File (providers.json)
๐ Supported Transports
rs-utcp supports a comprehensive range of transport protocols, each with full async support:
Production-Ready Transports
| Transport | Description | Status | Streaming |
|---|---|---|---|
| HTTP | REST APIs with UTCP manifest or OpenAPI | โ Stable | โ |
| MCP | Model Context Protocol (stdio & SSE) | โ Stable | โ |
| WebRTC | P2P data channels with signaling | โ Stable | โ |
| WebSocket | Real-time bidirectional communication | โ Stable | โ |
| CLI | Execute local binaries as tools | โ Stable | โ |
| gRPC | High-performance RPC with TLS & auth metadata | โ Stable | โ |
| GraphQL | Query-based tool calling with type-aware variables | โ Stable | โ |
| SSE | Server-Sent Events | โ Stable | โ |
| HTTP Streams | Streaming HTTP responses | โ Stable | โ |
| TCP | Low-level socket transport (framed JSON) | โ Stable | โ |
| UDP | Low-level datagram transport | โ Stable | โ |
| Text | File-based tool providers (JS/SH/Python/exe) | โ Stable | โ |
๐ก Examples
HTTP Provider with OpenAPI
use OpenApiConverter;
// Automatically convert OpenAPI spec to UTCP tools
let converter = new_from_url.await?;
let manual = converter.convert;
println!;
MCP Stdio Provider
let config = json!;
let client = create_client_from_config.await?;
let result = client.call_tool.await?;
Streaming Tools
// Call a streaming tool
let mut stream = client.call_tool_stream.await?;
// Process stream results
while let Some = stream.next.await
stream.close.await?;
WebRTC Peer-to-Peer
WebRTC enables direct peer-to-peer tool calling:
# Terminal 1: Start WebRTC server with signaling
# Terminal 2: Connect and call tools
See examples/webrtc_server/ for the complete implementation.
๐ค Codemode & LLM Orchestration
rs-utcp includes a powerful Codemode feature that enables dynamic script execution with full access to registered tools. This is perfect for LLM-driven workflows.
Codemode Basics
use ;
let codemode = new;
// Execute a Rhai script that calls tools
let script = r#"
let weather = call_tool("weather.get_forecast", #{
"city": "Tokyo"
});
let summary = call_tool("ai.summarize", #{
"text": weather.to_string()
});
summary
"#;
let result = codemode.execute.await?;
println!;
LLM Orchestration
The CodemodeOrchestrator provides a 4-step AI-driven workflow:
- Decide - LLM determines if tools are needed
- Select - LLM chooses relevant tools
- Generate - LLM writes a Rhai script
- Execute - Script runs in sandboxed environment
use CodemodeOrchestrator;
let codemode = new;
let llm_model = new;
let orchestrator = new;
// Let the LLM figure out how to accomplish the task
let result = orchestrator
.call_prompt
.await?;
match result
See the Gemini example for a complete LLM integration.
๐ฏ Use Cases
1. Multi-Protocol API Gateway
Call tools across HTTP, gRPC, and MCP from a single unified interface.
2. LLM Agent Toolkit
Provide language models with a consistent way to execute tools regardless of their implementation.
3. Microservices Orchestration
Coordinate calls across heterogeneous services using different protocols.
4. Plugin System
Build extensible applications where plugins can be added via configuration.
5. Testing & Mocking
Easily swap implementations (e.g., HTTP โ CLI) for testing without code changes.
๐ Documentation
- API Documentation - Complete API reference
- UTCP Specification - Protocol specification
- Examples - Working examples for all transports
- CHANGELOG - Version history and changes
๐งช Testing
Run the comprehensive test suite:
# Run all tests
# Run with output
# Run specific test
# Run examples
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ UtcpClient โ
โ (Unified interface for all tool operations) โ
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโดโโโโโโโโโ
โ โ
โโโโโโโโผโโโโโโโ โโโโโโโผโโโโโโโ
โ Repository โ โ Transports โ
โ - Tools โ โ - HTTP โ
โ - Search โ โ - MCP โ
โโโโโโโโโโโโโโโ โ - gRPC โ
โ - WebSocketโ
โ - CLI โ
โ - etc. โ
โโโโโโโโโโโโโโโ
Key Components
- UtcpClient - Main entry point for all operations
- TransportRegistry - Manages all transport implementations
- ToolRepository - Stores and indexes discovered tools
- SearchStrategy - Semantic search across tools
- Codemode - Script execution environment
- Loader - Configuration and provider loading
๐ง Advanced Configuration
Authentication
Environment Variables
Custom Search Strategy
use ToolSearchStrategy;
use async_trait;
;
๐ค Contributing
Contributions are welcome! Here's how you can help:
- Found a bug? Open an issue
- Have a feature idea? Start a discussion
- Want to contribute code? Submit a PR
Development Setup
# Clone the repository
# Run tests
# Format code
# Run lints
# Build all examples
๐ License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
๐ Acknowledgments
- Inspired by go-utcp
- Built on the UTCP specification
- Powered by the amazing Rust async ecosystem
๐ฌ Contact & Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- UTCP Community: utcp.io