Core Data Models
Relevant source files
The following files were used as context for generating this wiki page:
The Universal Tool Calling Protocol (UTCP) is built upon a set of simple, well-defined Pydantic models that form the foundation for defining, discovering, and interacting with tools. These core data models ensure a standardized and interoperable way to describe tool capabilities, invocation details, and authentication requirements across various communication protocols.
The primary models are UtcpManual, Tool, CallTemplate, and Auth. Together, they create a comprehensive structure for tool providers to advertise their services and for clients to consume them securely and efficiently. The entire system is designed to be extensible through a plugin-based architecture, where protocol-specific details are encapsulated within CallTemplate implementations.
Sources: core/README.md:14-16, 40-42
This diagram shows the high-level relationship between the core data models.
UtcpManual
The UtcpManual is the top-level discovery document. It serves as the contract between a tool provider and a client, containing the complete set of tools available from that provider. When a client performs tool discovery (e.g., by querying a /utcp endpoint), the provider returns a UtcpManual object.
Sources: core/src/utcp/data/utcp_manual.py:7-13, 23-31
This class diagram illustrates the structure of the UtcpManual.
Fields
| Field | Type | Description |
|---|---|---|
utcp_version | str | The UTCP protocol version supported by the provider. Defaults to the library version. |
manual_version | str | The version of the tool manual itself. Defaults to "1.0.0". |
tools | List[Tool] | A list of Tool objects, each defining an available tool with its complete configuration. |
Sources: core/src/utcp/data/utcp_manual.py:34-36
Tool
The Tool model is the fundamental unit of functionality in UTCP. It represents a single callable action, complete with its metadata, input/output schemas, and the specific CallTemplate required to invoke it.
Sources: core/src/utcp/data/tool.py:100-111
This diagram shows the composition of the Tool model.
Sources: core/src/utcp/data/tool.py:113-120
Fields
| Field | Type | Description |
|---|---|---|
name | str | A unique identifier for the tool. |
description | str | A human-readable description of what the tool does. |
inputs | JsonSchema | A JSON Schema defining the tool's input parameters. |
outputs | JsonSchema | A JSON Schema defining the tool's return value structure. |
tags | List[str] | A list of tags for categorization and search. |
average_response_size | Optional[int] | An optional hint about the typical response size in bytes. |
tool_call_template | CallTemplate | The configuration that specifies how to access and execute this tool. |
Sources: core/src/utcp/data/tool.py:113-120
JsonSchema
The JsonSchema model is used to define the structure and constraints of a tool's inputs and outputs. It is a Pydantic model that represents a standard JSON Schema object, allowing for rich validation and type-checking of tool arguments and results.
Sources: core/src/utcp/data/tool.py:18-36
Key Fields
| Field | Type | Description |
|---|---|---|
type | Optional[Union[str, List[str]]] | The data type (e.g., "object", "string", "number"). |
properties | Optional[Dict[str, JsonSchema]] | For objects, defines the properties and their schemas. |
items | Optional[JsonSchema] | For arrays, defines the schema for items in the array. |
required | Optional[List[str]] | A list of required property names for an object. |
description | Optional[str] | A human-readable description of the schema or field. |
default | Optional[JsonType] | A default value for the field. |
Sources: core/src/utcp/data/tool.py:39-58
CallTemplate
A CallTemplate defines the protocol-specific information required to invoke a tool. It is a base model that is extended by protocol-specific plugins. The call_template_type field acts as a discriminator to determine which plugin should handle the tool call. This design allows UTCP to support any communication protocol in an extensible way.
Sources: core/src/utcp/data/call_template.py:9-19, core/README.md:15-16
This diagram shows how CallTemplate is a base for various protocol-specific implementations.
Base Fields
| Field | Type | Description |
|---|---|---|
call_template_type | str | Required. The type of the call template, which determines the protocol plugin to use (e.g., "http", "cli"). |
name | str | Required. A unique name for the manual this template belongs to. |
auth | Optional[Auth] | An optional authentication configuration for the tool call. |
Sources: core/src/utcp/data/call_template.py:22-25
Auth Models
UTCP provides a flexible authentication system through a set of Auth models. Like CallTemplate, Auth is a base model with a discriminating auth_type field. This allows CallTemplate configurations to specify various authentication schemes such as API keys, Basic Auth, or OAuth2.
Sources: core/src/utcp/data/auth.py:10-14, core/README.md:103-112
This diagram shows the inheritance structure for the different authentication models.
Sources: core/src/utcp/data/auth.py:17-64
Authentication Types
auth_type | Model | Key Fields | Description |
|---|---|---|---|
api_key | ApiKeyAuth | api_key, var_name, location | For API key-based authentication, specifying the key, its name (e.g., Authorization), and its location (header, query, or cookie). |
basic | BasicAuth | username, password | For HTTP Basic Authentication. |
oauth2 | OAuth2 | token_url, client_id, client_secret | For OAuth2 client credentials flow. |
Sources: core/src/utcp/data/auth.py:17-64
Summary
The core data models of UTCP provide a robust and extensible framework for tool integration. By separating the abstract definition of a tool (Tool, JsonSchema) from its concrete invocation details (CallTemplate, Auth), the protocol remains agnostic to the underlying communication method while ensuring a consistent and standardized interface for both tool providers and consumers. This modularity is key to UTCP's goals of scalability, extensibility, and interoperability.
Sources: core/README.md:10-16