ExUtcp

Hex.pmHex.pmHex.pmHexDocs.pm

Elixir implementation of the Universal Tool Calling Protocol (UTCP).

Introduction

The Universal Tool Calling Protocol (UTCP) is a modern, flexible, and scalable standard for defining and interacting with tools across a wide variety of communication protocols. It is designed to be easy to use, interoperable, and extensible, making it a powerful choice for building and consuming tool-based services.

In contrast to other protocols like MCP, UTCP places a strong emphasis on:

Features

Installation

Add ex_utcp to your list of dependencies in mix.exs:

def deps do
[
{:ex_utcp, "~> 0.2.0"}
]
end

Getting Started

Basic Usage

alias ExUtcp.{Client, Config}
# Create a client configuration
config = Config.new(providers_file_path: "providers.json")
# Start a UTCP client
{:ok, client} = Client.start_link(config)
# Search for tools
{:ok, tools} = Client.search_tools(client, "", 10)
# Call a tool
{:ok, result} = Client.call_tool(client, "provider.tool_name", %{"arg" => "value"})

Programmatic Provider Registration

alias ExUtcp.{Client, Config, Providers}
# Create a client
config = Config.new()
{:ok, client} = Client.start_link(config)
# Create an HTTP provider
provider = Providers.new_http_provider([
name: "my_api",
url: "https://api.example.com/tools",
http_method: "POST"
])
# Register the provider
{:ok, tools} = Client.register_tool_provider(client, provider)
# Call a discovered tool
{:ok, result} = Client.call_tool(client, "my_api.echo", %{"message" => "Hello!"})

CLI Provider Example

alias ExUtcp.{Client, Config, Providers}
# Create a client
config = Config.new()
{:ok, client} = Client.start_link(config)
# Create a CLI provider
provider = Providers.new_cli_provider([
name: "my_script",
command_name: "python my_script.py",
working_dir: "/path/to/script"
])
# Register the provider
{:ok, tools} = Client.register_tool_provider(client, provider)
# Call a tool
{:ok, result} = Client.call_tool(client, "my_script.greet", %{"name" => "World"})

Configuration

Provider Configuration File

Create a providers.json file to define your providers:

{
"providers": [
{
"name": "http_api",
"type": "http",
"http_method": "POST",
"url": "https://api.example.com/tools",
"content_type": "application/json",
"headers": {
"User-Agent": "ExUtcp/0.2.0"
},
"auth": {
"type": "api_key",
"api_key": "${API_KEY}",
"location": "header",
"var_name": "Authorization"
}
},
{
"name": "cli_tool",
"type": "cli",
"command_name": "python my_tool.py",
"working_dir": "/opt/tools",
"env_vars": {
"PYTHONPATH": "/opt/tools"
}
}
]
}

Variable Substitution

UTCP supports variable substitution using ${VAR} or $VAR syntax:

# Load variables from .env file
{:ok, env_vars} = Config.load_from_env_file(".env")
config = Config.new(
variables: env_vars,
providers_file_path: "providers.json"
)

Architecture

The library is organized into several main components:

Implementation Status

Gap Analysis: Elixir UTCP vs Go UTCP

Feature CategoryGo ImplementationElixir ImplementationCoverage
Core ClientCompleteComplete100%
ConfigurationCompleteBasic70%
Transports12 types4 types33%
Providers12 types4 types33%
Authentication3 types3 types100%
Tool ManagementCompleteComplete100%
StreamingCompleteBasic60%
SearchAdvancedBasic60%
PerformanceOptimizedBasic30%
Error HandlingRobustBasic70%

Priority Recommendations

High Priority (Core Functionality)

Medium Priority (Enhanced Features)

Low Priority (Nice to Have)

Current Implementation Status

Completed Features

In Progress

Planned

Supported Transports

Implemented

In Progress

Planned

Examples

Check the examples/ directory for complete working examples:

Testing

Run the test suite:

mix test

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MPL-2.0 License - see the LICENSE file for details.