Architecture Overview
Relevant source files
The following files were used as context for generating this wiki page:The Universal Tool Calling Protocol (UTCP) is a standard for defining and interacting with tools across various communication protocols. Its Python implementation is designed with a modular, plugin-based architecture that emphasizes scalability, extensibility, and interoperability. This allows developers to easily add support for new communication protocols, tool storage mechanisms, and search strategies without modifying the core library.
The architecture is fundamentally split into a core package, which provides the foundational components and interfaces, and a series of plugins that implement specific communication protocols. This separation ensures the core remains stable while the ecosystem of tools and protocols can expand independently.
Sources: README.md:8-18, core/README.md:8-11
High-Level Architecture
The UTCP architecture centers around the UtcpClient, which acts as the main entry point for all interactions. The client utilizes core components for tool management and a plugin system for protocol-specific communication.
This diagram shows the main architectural components and their interactions.
Sources: README.md:28-36, core/README.md:13-19, CLAUDE.md:31-48
Repository Structure
The project is organized into two main directories, reflecting the core/plugin architecture.
| Directory | Description |
|---|---|
core/ | Contains the core utcp package with foundational components, data models, client interface, and the plugin system's interfaces. |
plugins/communication_protocols/ | Contains individual, installable packages for each communication protocol plugin, such as HTTP, CLI, MCP, and Text. |
Sources: README.md:20-27
Core Package (utcp)
The core package contains the essential components that form the foundation of the UTCP framework.
Sources: core/README.md:14-19, CLAUDE.md:31-48
Core Components
| Component | Description | Source File |
|---|---|---|
UtcpClient | The main entry point for interacting with the UTCP ecosystem. It manages tool discovery, registration, and execution. | CLAUDE.md:32 |
| Data Models | Pydantic models defining the structure of Tool, CallTemplate, UtcpManual, and Auth. | core/README.md:15 |
| Plugin System | A set of extensible interfaces for communication protocols, tool repositories, and search strategies. | core/README.md:17 |
ToolRepository | An interface for storing and retrieving discovered tools. The default implementation is InMemToolRepository. | CLAUDE.md:35 |
ToolSearchStrategy | An interface for tool search algorithms. The default is TagAndDescriptionWordMatchStrategy. | CLAUDE.md:36, README.md:100 |
Client Initialization and Tool Discovery
The UtcpClient is initialized via the asynchronous create method, which takes a configuration object. During initialization, it performs several key steps:
- Loads variables from sources like
.envfiles. - Initializes the tool repository and search strategy.
- Processes
manual_call_templatesfrom the configuration to discover tools. - For each template, it uses the appropriate protocol plugin to fetch a
UtcpManual. - Tools from the manual are registered in the
ToolRepository.
The following sequence diagram illustrates the client creation and tool discovery process.
Sources: README.md:84-142, core/README.md:26-34
Plugin System
UTCP's extensibility is achieved through a plugin-based architecture. Communication protocols are implemented as separate, installable packages that extend the core functionality.
Sources: README.md:11, 44-55
Plugin Registration
Plugins are discovered and registered at runtime using Python's entry point mechanism. Each plugin's pyproject.toml file defines an entry point under the utcp.plugins group.
Here is an example from the utcp-http plugin:
# plugins/communication_protocols/http/pyproject.toml
[project.entry-points."utcp.plugins"]
http = "utcp_http:register"
This tells the UTCP core that the http protocol type is handled by the register function in the utcp_http package. The PluginLoader in the core is responsible for finding and loading these entry points.
Sources: plugins/communication_protocols/http/pyproject.toml:37-38, core/src/utcp/plugins/plugin_loader.py
Available Protocol Plugins
The repository includes several stable and in-progress plugins.
| Plugin | Description | Status |
|---|---|---|
utcp-http | HTTP/REST APIs, SSE, streaming, and OpenAPI conversion. | ✅ Stable |
utcp-cli | Executes local command-line tools. | ✅ Stable |
utcp-mcp | Interoperability with the Model Context Protocol (MCP). | ✅ Stable |
utcp-text | Reads local files as tool outputs (e.g., for mocks). | ✅ Stable |
utcp-websocket | Real-time bidirectional communication via WebSockets. | ✅ Stable |
utcp-socket | TCP/UDP protocols. | 🚧 In Progress |
utcp-gql | GraphQL APIs. | 🚧 In Progress |
Sources: README.md:57-66
Tool Calling Flow
When a user calls a tool, the UtcpClient orchestrates the execution via the appropriate plugin.
- The user calls
client.call_tool("manual_name.tool_name", ...). - The client retrieves the
Toolobject from theToolRepository. - The
tool_call_templatewithin theToolobject specifies thecall_template_type(e.g.,http,cli). - The client invokes the
call_toolmethod on the corresponding communication protocol plugin. - The plugin handles the protocol-specific logic (e.g., making an HTTP request, running a shell command).
- The plugin returns the result to the client, which then returns it to the user.
This flow is visualized in the sequence diagram below.
Sources: README.md:40-42, CLAUDE.md:33, 41-48
Configuration
Client behavior is defined through a configuration object, which can be provided as a dictionary, a UtcpClientConfig object, or a path to a JSON file.
A key part of the configuration is the manual_call_templates list, which replaces the legacy providers_file_path. Each item in this list defines a source for tools, such as an OpenAPI specification URL or a local file path.
Example config.json:
{
"variables": {
"openlibrary_URL": "https://openlibrary.org/static/openapi.json"
},
"manual_call_templates": [
{
"name": "openlibrary",
"call_template_type": "http",
"url": "${openlibrary_URL}"
}
],
"tool_repository": {
"tool_repository_type": "in_memory"
}
}
This configuration tells the client to create a manual named openlibrary by using the http plugin to fetch and process the content at the specified URL.
Sources: README.md:90-96, 106-123, core/README.md:83-112
Summary
The UTCP Python architecture is a decoupled system comprising a lightweight core and an extensible set of protocol plugins. The core provides standardized interfaces and workflows for tool management, while plugins implement the specific logic for communicating with different types of tools. This modularity, combined with a powerful configuration system and runtime plugin discovery, makes UTCP a flexible and scalable framework for integrating a diverse range of tools.
Sources: README.md:8-18, core/README.md:8-11