Core Interfaces
Relevant source files
The following files were used as context for generating this wiki page:- core/src/utcp/interfaces/communication_protocol.py
- core/src/utcp/interfaces/concurrent_tool_repository.py
- core/src/utcp/interfaces/tool_search_strategy.py
- core/src/utcp/interfaces/variable_substitutor.py
- core/src/utcp/interfaces/tool_post_processor.py
- core/README.md
- README.md
- CLAUDE.md
- plugins/communication_protocols/http/README.md
- plugins/communication_protocols/cli/README.md
The Universal Tool Calling Protocol (UTCP) is built upon a modular, plugin-based architecture designed for extensibility, scalability, and interoperability. At the heart of this design are the core interfaces, which define the contracts for key components within the UTCP ecosystem. These interfaces allow developers to easily add new communication protocols, tool storage mechanisms, search strategies, and other functionalities without modifying the core library.
By adhering to these well-defined Pydantic models and abstract base classes, the UtcpClient can seamlessly interact with a variety of swappable components. This section provides a detailed overview of the primary interfaces that constitute the foundation of the UTCP plugin system.
Sources: core/README.md, README.md, CLAUDE.md
System Architecture Overview
The following diagram illustrates how the UtcpClient orchestrates interactions between the various components through the core interfaces.
This diagram shows the UtcpClient relying on abstract interfaces, which are then implemented by concrete plugin packages.
Sources: core/README.md, CLAUDE.md
CommunicationProtocol Interface
This is the most critical interface for extensibility, defining the contract for all protocol-specific plugins (e.g., utcp-http, utcp-cli). It standardizes how the UtcpClient discovers and executes tools over different transport layers.
Sources: core/src/utcp/interfaces/communication_protocol.py, plugins/communication_protocols/http/README.md, plugins/communication_protocols/cli/README.md
Methods
| Method | Description |
|---|---|
register_manual | Discovers tools from a given CallTemplate. It fetches a UtcpManual, converts it into a list of Tool objects, and returns them to the client for registration. |
call_tool | Executes a specific tool with the given arguments. This method contains the protocol-specific logic for making the actual tool call (e.g., sending an HTTP request or running a shell command). |
call_tool_streaming | Executes a tool that returns a stream of data, such as from an SSE or WebSocket endpoint. It returns an asynchronous iterator that yields data chunks. |
Sources: core/src/utcp/interfaces/communication_protocol.py
ConcurrentToolRepository Interface
This interface defines the contract for storing, retrieving, and managing Tool objects. Implementations must be safe for concurrent access, as multiple operations may occur simultaneously. The default implementation is an in-memory repository.
Sources: core/src/utcp/interfaces/concurrent_tool_repository.py, core/README.md
Methods
| Method | Description |
|---|---|
add_tool | Adds a Tool object to the repository. |
get_tool | Retrieves a single Tool by its unique, namespaced name (e.g., manual_name.tool_name). |
get_all_tools | Returns a list of all Tool objects currently in the repository. |
remove_tool | Removes a tool from the repository by its name. |
tool_exists | Checks if a tool with the given name exists in the repository. |
Sources: core/src/utcp/interfaces/concurrent_tool_repository.py
ToolSearchStrategy Interface
This interface allows the logic for searching and filtering tools to be customized. The UtcpClient delegates tool searching to an implementation of this interface. The default strategy is TagAndDescriptionWordMatchStrategy.
Sources: core/src/utcp/interfaces/tool_search_strategy.py, core/README.md
Methods
| Method | Description |
|---|---|
search_tools | Searches a list of Tool objects based on a string query. It returns a ranked list of matching tools, up to the specified limit. |
Sources: core/src/utcp/interfaces/tool_search_strategy.py
VariableSubstitutor Interface
This interface defines a contract for substituting variables in configuration objects. It is used to resolve placeholders like ${API_KEY} from environment variables, .env files, or other sources before they are used.
Sources: core/src/utcp/interfaces/variable_substitutor.py, core/README.md
Methods
| Method | Description |
|---|---|
substitute | Recursively traverses a target object (like a dictionary or list) and replaces any variable placeholders with values from the variables dictionary. |
Sources: core/src/utcp/interfaces/variable_substitutor.py
ToolPostProcessor Interface
This interface provides a hook for modifying the result of a tool call before it is returned to the end-user. This can be used for filtering, formatting, or transforming the output data.
Sources: core/src/utcp/interfaces/tool_post_processor.py, core/README.md
Methods
| Method | Description |
|---|---|
post_process | Takes the tool_name and the raw result from a tool call and returns a modified result. |
Sources: core/src/utcp/interfaces/tool_post_processor.py
Interaction Flow for call_tool
The sequence diagram below shows how the UtcpClient leverages these interfaces to execute a tool call.
This flow demonstrates the separation of concerns: the client orchestrates, the repository stores, the protocol communicates, and the post-processor transforms.
Sources: core/README.md, CLAUDE.md
Summary
The core interfaces are the architectural backbone of the python-utcp library. They establish clear contracts that enable a decoupled, modular, and highly extensible system. By defining abstract interfaces for communication, storage, search, and data manipulation, UTCP empowers developers to easily integrate new services and customize client behavior, ensuring the protocol remains adaptable and scalable.
Sources: README.md, core/README.md