Skip to content

Commit d28c0af

Browse files
authored
Update documentation and fix MCP plugin
2 parents 0f2af7e + 666eb1e commit d28c0af

37 files changed

+1782
-302
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest, windows-latest, macos-latest]
15-
python-version: ["3.10", "3.11", "3.12", "3.13"]
15+
python-version: ["3.11", "3.12", "3.13"]
1616

1717
steps:
1818
- uses: actions/checkout@v4

README.md

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Universal Tool Calling Protocol (UTCP) 1.0.1
1+
# Universal Tool Calling Protocol (UTCP)
22

33
[![Follow Org](https://img.shields.io/github/followers/universal-tool-calling-protocol?label=Follow%20Org&logo=github)](https://github.com/universal-tool-calling-protocol)
44
[![PyPI Downloads](https://static.pepy.tech/badge/utcp)](https://pepy.tech/projects/utcp)
@@ -19,47 +19,76 @@ In contrast to other protocols, UTCP places a strong emphasis on:
1919

2020
![MCP vs. UTCP](https://github.com/user-attachments/assets/3cadfc19-8eea-4467-b606-66e580b89444)
2121

22-
## New Architecture in 1.0.0
22+
## Repository Structure
2323

24-
UTCP has been refactored into a core library and a set of optional plugins.
24+
This repository contains the complete UTCP Python implementation:
25+
26+
- **[`core/`](core/)** - Core `utcp` package with foundational components ([README](core/README.md))
27+
- **[`plugins/communication_protocols/`](plugins/communication_protocols/)** - Protocol-specific plugins:
28+
- [`http/`](plugins/communication_protocols/http/) - HTTP/REST, SSE, streaming, OpenAPI ([README](plugins/communication_protocols/http/README.md))
29+
- [`cli/`](plugins/communication_protocols/cli/) - Command-line tools ([README](plugins/communication_protocols/cli/README.md))
30+
- [`mcp/`](plugins/communication_protocols/mcp/) - Model Context Protocol ([README](plugins/communication_protocols/mcp/README.md))
31+
- [`text/`](plugins/communication_protocols/text/) - File-based tools ([README](plugins/communication_protocols/text/README.md))
32+
- [`socket/`](plugins/communication_protocols/socket/) - TCP/UDP (🚧 In Progress)
33+
- [`gql/`](plugins/communication_protocols/gql/) - GraphQL (🚧 In Progress)
34+
35+
## Architecture Overview
36+
37+
UTCP uses a modular architecture with a core library and protocol plugins:
2538

2639
### Core Package (`utcp`)
2740

28-
The `utcp` package provides the central components and interfaces:
29-
* **Data Models**: Pydantic models for `Tool`, `CallTemplate`, `UtcpManual`, and `Auth`.
30-
* **Pluggable Interfaces**:
31-
* `CommunicationProtocol`: Defines the contract for protocol-specific communication (e.g., HTTP, CLI).
32-
* `ConcurrentToolRepository`: An interface for storing and retrieving tools with thread-safe access.
33-
* `ToolSearchStrategy`: An interface for implementing tool search algorithms.
34-
* `VariableSubstitutor`: Handles variable substitution in configurations.
35-
* `ToolPostProcessor`: Allows for modifying tool results before they are returned.
36-
* **Default Implementations**:
37-
* `UtcpClient`: The main client for interacting with the UTCP ecosystem.
38-
* `InMemToolRepository`: An in-memory tool repository with asynchronous read-write locks.
39-
* `TagAndDescriptionWordMatchStrategy`: An improved search strategy that matches on tags and description keywords.
40-
41-
### Protocol Plugins
42-
43-
Communication protocols are now separate, installable packages. This keeps the core lean and allows users to install only the protocols they need.
44-
* `utcp-http`: Supports HTTP, SSE, and streamable HTTP, plus an OpenAPI converter.
45-
* `utcp-cli`: For wrapping local command-line tools.
46-
* `utcp-mcp`: For interoperability with the Model Context Protocol (MCP).
47-
* `utcp-text`: For reading text files.
48-
* `utcp-socket`: Scaffolding for TCP and UDP protocols. (Work in progress, requires update)
49-
* `utcp-gql`: Scaffolding for GraphQL. (Work in progress, requires update)
50-
51-
## Installation
52-
53-
Install the core library and any required protocol plugins.
41+
The [`core/`](core/) directory contains the foundational components:
42+
- **Data Models**: Pydantic models for `Tool`, `CallTemplate`, `UtcpManual`, and `Auth`
43+
- **Client Interface**: Main `UtcpClient` for tool interaction
44+
- **Plugin System**: Extensible interfaces for protocols, repositories, and search
45+
- **Default Implementations**: Built-in tool storage and search strategies
46+
47+
## Quick Start
48+
49+
### Installation
50+
51+
Install the core library and any required protocol plugins:
5452

5553
```bash
56-
# Install the core client and the HTTP plugin
54+
# Install core + HTTP plugin (most common)
5755
pip install utcp utcp-http
5856

59-
# Install the CLI plugin as well
60-
pip install utcp-cli
57+
# Install additional plugins as needed
58+
pip install utcp-cli utcp-mcp utcp-text
6159
```
6260

61+
### Basic Usage
62+
63+
```python
64+
from utcp.utcp_client import UtcpClient
65+
66+
# Create client with HTTP API
67+
client = await UtcpClient.create(config={
68+
"manual_call_templates": [{
69+
"name": "my_api",
70+
"call_template_type": "http",
71+
"url": "https://api.example.com/utcp"
72+
}]
73+
})
74+
75+
# Call a tool
76+
result = await client.call_tool("my_api.get_data", {"id": "123"})
77+
```
78+
79+
## Protocol Plugins
80+
81+
UTCP supports multiple communication protocols through dedicated plugins:
82+
83+
| Plugin | Description | Status | Documentation |
84+
|--------|-------------|--------|---------------|
85+
| [`utcp-http`](plugins/communication_protocols/http/) | HTTP/REST APIs, SSE, streaming | ✅ Stable | [HTTP Plugin README](plugins/communication_protocols/http/README.md) |
86+
| [`utcp-cli`](plugins/communication_protocols/cli/) | Command-line tools | ✅ Stable | [CLI Plugin README](plugins/communication_protocols/cli/README.md) |
87+
| [`utcp-mcp`](plugins/communication_protocols/mcp/) | Model Context Protocol | ✅ Stable | [MCP Plugin README](plugins/communication_protocols/mcp/README.md) |
88+
| [`utcp-text`](plugins/communication_protocols/text/) | Local file-based tools | ✅ Stable | [Text Plugin README](plugins/communication_protocols/text/README.md) |
89+
| [`utcp-socket`](plugins/communication_protocols/socket/) | TCP/UDP protocols | 🚧 In Progress | [Socket Plugin README](plugins/communication_protocols/socket/README.md) |
90+
| [`utcp-gql`](plugins/communication_protocols/gql/) | GraphQL APIs | 🚧 In Progress | [GraphQL Plugin README](plugins/communication_protocols/gql/README.md) |
91+
6392
For development, you can install the packages in editable mode from the cloned repository:
6493

6594
```bash
@@ -68,7 +97,7 @@ git clone https://github.com/universal-tool-calling-protocol/python-utcp.git
6897
cd python-utcp
6998

7099
# Install the core package in editable mode with dev dependencies
71-
pip install -e core[dev]
100+
pip install -e "core[dev]"
72101

73102
# Install a specific protocol plugin in editable mode
74103
pip install -e plugins/communication_protocols/http
@@ -269,7 +298,7 @@ app = FastAPI()
269298
def utcp_discovery():
270299
return {
271300
"manual_version": "1.0.0",
272-
"utcp_version": "1.0.1",
301+
"utcp_version": "1.0.2",
273302
"tools": [
274303
{
275304
"name": "get_weather",

core/README.md

Lines changed: 69 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Universal Tool Calling Protocol (UTCP) 1.0.1
1+
# Universal Tool Calling Protocol (UTCP)
22

33
[![Follow Org](https://img.shields.io/github/followers/universal-tool-calling-protocol?label=Follow%20Org&logo=github)](https://github.com/universal-tool-calling-protocol)
44
[![PyPI Downloads](https://static.pepy.tech/badge/utcp)](https://pepy.tech/projects/utcp)
@@ -7,7 +7,7 @@
77

88
## Introduction
99

10-
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. UTCP 1.0.0 introduces a modular core with a plugin-based architecture, making it more extensible, testable, and easier to package.
10+
The Universal Tool Calling Protocol (UTCP) is a secure, scalable standard for defining and interacting with tools across a wide variety of communication protocols. UTCP 1.0.0 introduces a modular core with a plugin-based architecture, making it more extensible, testable, and easier to package.
1111

1212
In contrast to other protocols, UTCP places a strong emphasis on:
1313

@@ -19,47 +19,76 @@ In contrast to other protocols, UTCP places a strong emphasis on:
1919

2020
![MCP vs. UTCP](https://github.com/user-attachments/assets/3cadfc19-8eea-4467-b606-66e580b89444)
2121

22-
## New Architecture in 1.0.0
22+
## Repository Structure
2323

24-
UTCP has been refactored into a core library and a set of optional plugins.
24+
This repository contains the complete UTCP Python implementation:
25+
26+
- **[`core/`](core/)** - Core `utcp` package with foundational components ([README](core/README.md))
27+
- **[`plugins/communication_protocols/`](plugins/communication_protocols/)** - Protocol-specific plugins:
28+
- [`http/`](plugins/communication_protocols/http/) - HTTP/REST, SSE, streaming, OpenAPI ([README](plugins/communication_protocols/http/README.md))
29+
- [`cli/`](plugins/communication_protocols/cli/) - Command-line tools ([README](plugins/communication_protocols/cli/README.md))
30+
- [`mcp/`](plugins/communication_protocols/mcp/) - Model Context Protocol ([README](plugins/communication_protocols/mcp/README.md))
31+
- [`text/`](plugins/communication_protocols/text/) - File-based tools ([README](plugins/communication_protocols/text/README.md))
32+
- [`socket/`](plugins/communication_protocols/socket/) - TCP/UDP (🚧 In Progress)
33+
- [`gql/`](plugins/communication_protocols/gql/) - GraphQL (🚧 In Progress)
34+
35+
## Architecture Overview
36+
37+
UTCP uses a modular architecture with a core library and protocol plugins:
2538

2639
### Core Package (`utcp`)
2740

28-
The `utcp` package provides the central components and interfaces:
29-
* **Data Models**: Pydantic models for `Tool`, `CallTemplate`, `UtcpManual`, and `Auth`.
30-
* **Pluggable Interfaces**:
31-
* `CommunicationProtocol`: Defines the contract for protocol-specific communication (e.g., HTTP, CLI).
32-
* `ConcurrentToolRepository`: An interface for storing and retrieving tools with thread-safe access.
33-
* `ToolSearchStrategy`: An interface for implementing tool search algorithms.
34-
* `VariableSubstitutor`: Handles variable substitution in configurations.
35-
* `ToolPostProcessor`: Allows for modifying tool results before they are returned.
36-
* **Default Implementations**:
37-
* `UtcpClient`: The main client for interacting with the UTCP ecosystem.
38-
* `InMemToolRepository`: An in-memory tool repository with asynchronous read-write locks.
39-
* `TagAndDescriptionWordMatchStrategy`: An improved search strategy that matches on tags and description keywords.
40-
41-
### Protocol Plugins
42-
43-
Communication protocols are now separate, installable packages. This keeps the core lean and allows users to install only the protocols they need.
44-
* `utcp-http`: Supports HTTP, SSE, and streamable HTTP, plus an OpenAPI converter.
45-
* `utcp-cli`: For wrapping local command-line tools.
46-
* `utcp-mcp`: For interoperability with the Model Context Protocol (MCP).
47-
* `utcp-text`: For reading text files.
48-
* `utcp-socket`: Scaffolding for TCP and UDP protocols. (Work in progress, requires update)
49-
* `utcp-gql`: Scaffolding for GraphQL. (Work in progress, requires update)
50-
51-
## Installation
52-
53-
Install the core library and any required protocol plugins.
41+
The [`core/`](core/) directory contains the foundational components:
42+
- **Data Models**: Pydantic models for `Tool`, `CallTemplate`, `UtcpManual`, and `Auth`
43+
- **Client Interface**: Main `UtcpClient` for tool interaction
44+
- **Plugin System**: Extensible interfaces for protocols, repositories, and search
45+
- **Default Implementations**: Built-in tool storage and search strategies
46+
47+
## Quick Start
48+
49+
### Installation
50+
51+
Install the core library and any required protocol plugins:
5452

5553
```bash
56-
# Install the core client and the HTTP plugin
54+
# Install core + HTTP plugin (most common)
5755
pip install utcp utcp-http
5856

59-
# Install the CLI plugin as well
60-
pip install utcp-cli
57+
# Install additional plugins as needed
58+
pip install utcp-cli utcp-mcp utcp-text
6159
```
6260

61+
### Basic Usage
62+
63+
```python
64+
from utcp.utcp_client import UtcpClient
65+
66+
# Create client with HTTP API
67+
client = await UtcpClient.create(config={
68+
"manual_call_templates": [{
69+
"name": "my_api",
70+
"call_template_type": "http",
71+
"url": "https://api.example.com/utcp"
72+
}]
73+
})
74+
75+
# Call a tool
76+
result = await client.call_tool("my_api.get_data", {"id": "123"})
77+
```
78+
79+
## Protocol Plugins
80+
81+
UTCP supports multiple communication protocols through dedicated plugins:
82+
83+
| Plugin | Description | Status | Documentation |
84+
|--------|-------------|--------|---------------|
85+
| [`utcp-http`](plugins/communication_protocols/http/) | HTTP/REST APIs, SSE, streaming | ✅ Stable | [HTTP Plugin README](plugins/communication_protocols/http/README.md) |
86+
| [`utcp-cli`](plugins/communication_protocols/cli/) | Command-line tools | ✅ Stable | [CLI Plugin README](plugins/communication_protocols/cli/README.md) |
87+
| [`utcp-mcp`](plugins/communication_protocols/mcp/) | Model Context Protocol | ✅ Stable | [MCP Plugin README](plugins/communication_protocols/mcp/README.md) |
88+
| [`utcp-text`](plugins/communication_protocols/text/) | Local file-based tools | ✅ Stable | [Text Plugin README](plugins/communication_protocols/text/README.md) |
89+
| [`utcp-socket`](plugins/communication_protocols/socket/) | TCP/UDP protocols | 🚧 In Progress | [Socket Plugin README](plugins/communication_protocols/socket/README.md) |
90+
| [`utcp-gql`](plugins/communication_protocols/gql/) | GraphQL APIs | 🚧 In Progress | [GraphQL Plugin README](plugins/communication_protocols/gql/README.md) |
91+
6392
For development, you can install the packages in editable mode from the cloned repository:
6493

6594
```bash
@@ -68,7 +97,7 @@ git clone https://github.com/universal-tool-calling-protocol/python-utcp.git
6897
cd python-utcp
6998

7099
# Install the core package in editable mode with dev dependencies
71-
pip install -e core[dev]
100+
pip install -e "core[dev]"
72101

73102
# Install a specific protocol plugin in editable mode
74103
pip install -e plugins/communication_protocols/http
@@ -87,7 +116,7 @@ Version 1.0.0 introduces several breaking changes. Follow these steps to migrate
87116
3. **Update Imports**: Change your imports to reflect the new modular structure. For example, `from utcp.client.transport_interfaces.http_transport import HttpProvider` becomes `from utcp_http.http_call_template import HttpCallTemplate`.
88117
4. **Tool Search**: If you were using the default search, the new strategy is `TagAndDescriptionWordMatchStrategy`. This is the new default and requires no changes unless you were implementing a custom strategy.
89118
5. **Tool Naming**: Tool names are now namespaced as `manual_name.tool_name`. The client handles this automatically.
90-
6 **Variable Substitution Namespacing**: Variables that are subsituted in different `call_templates`, are first namespaced with the name of the manual with the `_` duplicated. So a key in a tool call template called `API_KEY` from the manual `manual_1` would be converted to `manual__1_API_KEY`.
119+
6. **Variable Substitution Namespacing**: Variables that are substituted in different `call_templates`, are first namespaced with the name of the manual with the `_` duplicated. So a key in a tool call template called `API_KEY` from the manual `manual_1` would be converted to `manual__1_API_KEY`.
91120

92121
## Usage Examples
93122

@@ -226,7 +255,7 @@ if __name__ == "__main__":
226255

227256
### 2. Providing a UTCP Manual
228257

229-
A `UTCPManual` describes the tools you offer. The key change is replacing `tool_provider` with `call_template`.
258+
A `UTCPManual` describes the tools you offer. The key change is replacing `tool_provider` with `tool_call_template`.
230259

231260
**`server.py`**
232261

@@ -269,7 +298,7 @@ app = FastAPI()
269298
def utcp_discovery():
270299
return {
271300
"manual_version": "1.0.0",
272-
"utcp_version": "1.0.1",
301+
"utcp_version": "1.0.2",
273302
"tools": [
274303
{
275304
"name": "get_weather",
@@ -288,7 +317,7 @@ def utcp_discovery():
288317
"conditions": {"type": "string"}
289318
}
290319
},
291-
"call_template": {
320+
"tool_call_template": {
292321
"call_template_type": "http",
293322
"url": "https://example.com/api/weather",
294323
"http_method": "GET"
@@ -311,7 +340,7 @@ You can find full examples in the [examples repository](https://github.com/unive
311340

312341
### `UtcpManual` and `Tool` Models
313342

314-
The `tool_provider` object inside a `Tool` has been replaced by `call_template`.
343+
The `tool_provider` object inside a `Tool` has been replaced by `tool_call_template`.
315344

316345
```json
317346
{
@@ -324,7 +353,7 @@ The `tool_provider` object inside a `Tool` has been replaced by `call_template`.
324353
"inputs": { ... },
325354
"outputs": { ... },
326355
"tags": ["string"],
327-
"call_template": {
356+
"tool_call_template": {
328357
"call_template_type": "http",
329358
"url": "https://...",
330359
"http_method": "GET"

core/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "utcp"
7-
version = "1.0.1"
7+
version = "1.0.2"
88
authors = [
99
{ name = "UTCP Contributors" },
1010
]

core/src/utcp/__init__.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import logging
22
import sys
33

4-
logger = logging.getLogger("utcp")
5-
6-
if not logger.handlers: # Only add default handler if user didn't configure logging
7-
handler = logging.StreamHandler(sys.stderr)
8-
handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(filename)s:%(lineno)d - %(message)s"))
9-
logger.addHandler(handler)
10-
logger.setLevel(logging.INFO)
4+
logging.basicConfig(
5+
level=logging.INFO,
6+
format="%(asctime)s [%(levelname)s] %(filename)s:%(lineno)d - %(message)s"
7+
)
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
class UtcpSerializerValidationError(Exception):
22
"""REQUIRED
3-
Exception raised when a serializer validation fails."""
3+
Exception raised when a serializer validation fails.
4+
5+
Thrown by serializers when they cannot validate or convert data structures
6+
due to invalid format, missing required fields, or type mismatches.
7+
Contains the original validation error details for debugging.
8+
9+
Usage:
10+
Typically caught when loading configuration files or processing
11+
external data that doesn't conform to UTCP specifications.
12+
"""

core/src/utcp/implementations/post_processors/filter_dict_post_processor.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@
1010
from utcp.utcp_client import UtcpClient
1111

1212
class FilterDictPostProcessor(ToolPostProcessor):
13+
"""REQUIRED
14+
Post-processor that filters dictionary keys from tool results.
15+
16+
Provides flexible filtering capabilities to include or exclude specific keys
17+
from dictionary results, with support for nested dictionaries and lists.
18+
Can be configured to apply filtering only to specific tools or manuals.
19+
20+
Attributes:
21+
tool_post_processor_type: Always "filter_dict" for this processor.
22+
exclude_keys: List of keys to remove from dictionary results.
23+
only_include_keys: List of keys to keep in dictionary results (all others removed).
24+
exclude_tools: List of tool names to skip processing for.
25+
only_include_tools: List of tool names to process (all others skipped).
26+
exclude_manuals: List of manual names to skip processing for.
27+
only_include_manuals: List of manual names to process (all others skipped).
28+
"""
1329
tool_post_processor_type: Literal["filter_dict"] = "filter_dict"
1430
exclude_keys: Optional[List[str]] = None
1531
only_include_keys: Optional[List[str]] = None
@@ -89,6 +105,8 @@ def _filter_dict_only_include_keys(self, result: Any) -> Any:
89105
return result
90106

91107
class FilterDictPostProcessorConfigSerializer(Serializer[FilterDictPostProcessor]):
108+
"""REQUIRED
109+
Serializer for FilterDictPostProcessor configuration."""
92110
def to_dict(self, obj: FilterDictPostProcessor) -> dict:
93111
return obj.model_dump()
94112

0 commit comments

Comments
 (0)