An example implementation of the Universal Tool Calling Protocol (UTCP) that demonstrates how to build an agentic assistant capable of discovering, selecting, and using tools from multiple providers.
This repository showcases how the Universal Tool Calling Protocol (UTCP) makes agentic tool calling simpler and more powerful. With UTCP, agents can discover and use external tools by interacting with them directly via their native protocols, eliminating the need for custom wrappers around each tool.
The agent can:
- Load tool providers from configuration files
- Register new tool providers via natural language instructions
- Search for the most relevant tools based on user queries
- Execute tool calls and return results to the user
- Python 3.8+
- OpenAI API key
- Clone this repository
- Install dependencies:
pip install -r requirements.txt
- Create a
.env
file in the root directory with your OpenAI API key:OPENAI_API_KEY=your_api_key_here
Start the agent with:
python main.py
This will:
- Start a FastAPI server on http://localhost:1646
- Initialize the UTCP client and load providers from
providers.json
- Start the interactive CLI agent
The agent supports:
- Natural language queries: Ask the agent questions and it will find and use the most relevant tools.
- Tool registration: Tell the agent to register a new tool provider by URL or manual specification.
Example interactions:
User: What's the latest news about AI?
Agent: Let me check the latest news for you...
[Agent uses newsapi tool to retrieve information]
User: Register a weather API at https://api.weather.com/utcp
Agent: I'll register this weather API provider for you...
[Agent registers the new provider and confirms]
User: What's the weather in New York?
Agent: Let me check the weather in New York...
[Agent uses newly registered weather API tool]
Tool providers are configured in providers.json
. Example providers:
[
{
"name": "newsapi",
"provider_type": "text",
"file_path": "./text_manuals/newsapi_manual.json"
},
{
"name": "utcp_agent",
"provider_type": "http",
"http_method": "GET",
"url": "http://localhost:1646/utcp",
"content_type": "application/json"
}
]
- Agent (
agent.py
): Manages conversations with users, searches for relevant tools, and uses OpenAI to generate responses and tool calls. - UTCP Client: Handles tool provider registration, tool discovery, and tool execution.
- EmbeddingModel (
embedding_model.py
): Local embedding model using all-MiniLM-L6-v2 from HuggingFace for generating vector representations of tools and queries. - TagAnalyzer (
tag_analyzer.py
): Extracts relevant tags from user queries using OpenAI to improve tool search relevance. - ToolSelector (
tool_selector.py
): Implements the UTCPToolSearchStrategy
to find the most appropriate tools based on embedding similarity and tag matching. - EmbeddingInMemRepo (
vector_store.py
): In-memory implementation of the UTCPToolRepository
interface that stores tools and their embeddings.
- FastAPI Server (
main.py
): Provides endpoints for health checks, the UTCP manual, and registering new HTTP providers. - Interactive CLI: Allows users to chat with the agent directly via the command line.
The Universal Tool Calling Protocol (UTCP) is a specification that enables applications to discover and use external tools by interacting with them directly via their native protocols. Key benefits:
- No wrapper tax: Call any tool without changes to the tool itself
- Native security: Leverage existing security mechanisms
- Scalable: Handle a large number of tools and calls
- Simple: Easy to implement and use
For more information about UTCP, visit the UTCP documentation.
Apache License 2.0