Call Templates
Relevant source files
The following files were used as context for generating this wiki page:- core/src/utcp/data/call_template.py
- core/README.md
- README.md
- plugins/communication_protocols/http/src/utcp_http/http_call_template.py
- plugins/communication_protocols/text/src/utcp_text/text_call_template.py
- plugins/communication_protocols/cli/README.md
- plugins/communication_protocols/websocket/README.md
- plugins/communication_protocols/mcp/README.md
- core/tests/client/test_utcp_client.py
- scripts/extract_required_docs.py
A Call Template is a core concept in the Universal Tool Calling Protocol (UTCP) that defines how to connect to and interact with a source of tools. It is a protocol-specific configuration object that contains all the necessary information—such as URL, authentication details, and communication method—for the UtcpClient to discover and register a UtcpManual. In UTCP v1.0.0, "Call Template" replaces the term "Provider" from earlier versions.
Call Templates are designed to be extensible, allowing UTCP to support a wide variety of communication protocols through a plugin-based architecture. Each protocol plugin (e.g., utcp-http, utcp-cli) provides its own implementation of a Call Template, tailored to the specifics of that protocol.
Sources: core/README.md:16-25, 74-77, README.md:16-25, 79-82
Core Concept
At its foundation, every Call Template inherits from the abstract base class CallTemplate. This base class establishes the minimum required fields for any template, ensuring a consistent structure across different protocol implementations.
Sources: core/src/utcp/data/call_template.py
Base CallTemplate Class
The CallTemplate class is a Pydantic model that defines the essential attributes common to all call templates.
This diagram shows the abstract CallTemplate base class with its key attributes.
Sources: core/src/utcp/data/call_template.py:8-20
| Field | Type | Description |
|---|---|---|
name | str | A unique identifier for the manual being registered. This name is used to namespace the tools within it (e.g., manual_name.tool_name). |
call_template_type | str | A string literal that identifies the communication protocol (e.g., "http", "cli", "text"). This determines which plugin handles the template. |
auth | Optional[Auth] | An optional authentication object for accessing the tool source (e.g., an OpenAPI specification URL). |
Sources: core/src/utcp/data/call_template.py:14-16, README.md:88
Relationship with UtcpManual and Tool
A Call Template's primary role is to enable the discovery of a UtcpManual. Once the manual is fetched and its tools are registered, each Tool object within that manual contains its own tool_call_template field. This nested template specifies how to execute that particular tool, which may differ from the template used to discover the manual itself.
The following diagram illustrates the relationship between these core data models.
Configuration and Usage
Call Templates are primarily configured within the UtcpClientConfig object or an equivalent JSON file, under the manual_call_templates key. This key holds a list of Call Template objects. When UtcpClient.create() is called, it iterates through this list, using each template to register the corresponding UtcpManual.
Sources: core/README.md:68-71, 117-126, core/tests/client/test_utcp_client.py:408-434
The following sequence diagram shows the process of registering manuals from manual_call_templates during client initialization.
This diagram illustrates how the UtcpClient processes each CallTemplate in the configuration to discover and store tools.
Sources: core/tests/client/test_utcp_client.py:228-245
Call Template Implementations
UTCP's plugin architecture allows for multiple, protocol-specific Call Template implementations.
HTTP Call Template (http)
This is the most common template, used for interacting with RESTful APIs and OpenAPI specifications.
Sources: plugins/communication_protocols/http/src/utcp_http/http_call_template.py
Configuration Example:
{
"name": "my_rest_api",
"call_template_type": "http",
"url": "https://api.example.com/users/{user_id}",
"http_method": "POST",
"content_type": "application/json",
"auth": {
"auth_type": "api_key",
"api_key": "Bearer $API_KEY",
"var_name": "Authorization",
"location": "header"
},
"headers": {
"X-Custom-Header": "value"
},
"body_field": "body",
"header_fields": ["user_id"]
}
Sources: core/README.md:223-241, plugins/communication_protocols/http/src/utcp_http/http_call_template.py:8-100
Text Call Template (text)
Used to load a UtcpManual from a local JSON or YAML file. This is useful for static tool definitions that are version-controlled with the application code.
Sources: plugins/communication_protocols/text/src/utcp_text/text_call_template.py
Configuration Example:
{
"name": "my_text_manual",
"call_template_type": "text",
"file_path": "./manuals/my_manual.json"
}
Sources: core/README.md:290-295, plugins/communication_protocols/text/README.md:70-77
CLI Call Template (cli)
Enables UTCP to wrap command-line tools. It supports multi-command execution in a single subprocess.
| Field | Description |
|---|---|
commands | A list of command objects to execute sequentially. |
env_vars | Optional environment variables to set for the subprocess. |
working_dir | Optional working directory for command execution. |
Configuration Example:
{
"name": "my_cli_tool",
"call_template_type": "cli",
"commands": [
{
"command": "cd UTCP_ARG_target_dir_UTCP_END",
"append_to_final_output": false
},
{
"command": "my-command --input UTCP_ARG_input_file_UTCP_END"
}
],
"env_vars": {
"MY_VAR": "my_value"
}
}
Sources: core/README.md:274-288, plugins/communication_protocols/cli/README.md:38-52
WebSocket Call Template (websocket)
Designed for real-time, bidirectional communication with any WebSocket endpoint. It is highly flexible and does not enforce a specific message structure by default.
| Field | Description |
|---|---|
url | The WebSocket URL (must be wss:// for production). |
message | An optional string or dictionary template for the message to be sent. |
response_format | Optional expected response format ("json", "text", "raw"). |
keep_alive | Boolean to enable persistent connection with heartbeat (default: true). |
Configuration Example:
{
"name": "formatted_ws",
"call_template_type": "websocket",
"url": "wss://api.example.com/ws",
"message": {
"type": "request",
"action": "UTCP_ARG_action_UTCP_ARG",
"params": {
"user_id": "UTCP_ARG_user_id_UTCP_ARG"
}
}
}
Sources: plugins/communication_protocols/websocket/README.md:50-68, plugins/communication_protocols/websocket/tests/test_websocket_call_template.py:44-50
MCP Call Template (mcp)
Provides interoperability with the Model Context Protocol (MCP), allowing UTCP to integrate with existing MCP servers.
| Field | Description |
|---|---|
config | A required object containing the mcpServers configuration. |
auth | Optional OAuth2 authentication for remote HTTP-based MCP servers. |
Configuration Example:
{
"name": "my_mcp_server",
"call_template_type": "mcp",
"config": {
"mcpServers": {
"server_name": {
"transport": "stdio",
"command": ["python", "-m", "my_mcp_server"]
}
}
}
}
Sources: core/README.md:297-313, plugins/communication_protocols/mcp/README.md:39-51
Other HTTP-based Templates
The utcp-http plugin also provides specialized templates for streaming protocols over HTTP.
sse: For Server-Sent Events.streamable_http: For chunked transfer encoding (renamed fromhttp_stream).
Sources: core/README.md:243-272
Summary
Call Templates are a fundamental component of UTCP's extensibility and interoperability. They serve as protocol-specific "recipes" that instruct the UtcpClient on how to connect to diverse tool sources. By standardizing the configuration interface via manual_call_templates while allowing for protocol-specific implementations, UTCP can seamlessly integrate with a vast ecosystem of tools, from modern REST APIs and WebSockets to legacy CLI and MCP-based systems.
Sources: core/README.md:16-25, README.md:16-25