Skip to main content

Universal Tool Calling Protocol (UTCP) integration for Strands Agents SDK

Project description

strands-utcp

PyPI version Python Support License: MIT

Universal Tool Calling Protocol (UTCP) community plugin for Strands Agents SDK

Features

  • Universal Tool Access - Connect to any UTCP-compatible tool source
  • OpenAPI/Swagger Support - Automatic tool discovery from API specifications
  • Multiple Sources - Connect to multiple tool sources simultaneously
  • Async/Await Support - Full async support with context managers
  • Type Safe - Full type hints and validation
  • Easy Integration - Drop-in tool adapter for Strands agents

Key Technical Features:

  • AgentTool Inheritance: Full inheritance from Strands AgentTool base class
  • Tool Name Sanitization: UUID suffixes for names >64 characters (Bedrock requirement)

Requirements

  • Python 3.10+
  • Strands Agents SDK 1.7.0+
  • UTCP core libraries 1.0+

Installation

pip install strands-agents strands-utcp

Quick Start

Basic Usage

from strands import Agent
from strands_utcp import UtcpToolAdapter

# Configure UTCP tool adapter
config = {
    "manual_call_templates": [
        {
            "name": "weather_api",
            "call_template_type": "http",
            "url": "https://api.weather.com/utcp",
            "http_method": "GET"
        }
    ]
}

# Use UTCP tools with Strands agent
async def main():
    async with UtcpToolAdapter(config) as adapter:
        # Get available tools
        tools = adapter.list_tools()
        print(f"Found {len(tools)} UTCP tools")
        
        # Create agent with UTCP tools
        agent = Agent(tools=adapter.to_strands_tools())
        
        # Use the agent
        response = await agent.invoke_async("What's the weather like today?")
        print(response.message)

import asyncio
asyncio.run(main())

Tool Discovery

async with UtcpToolAdapter(config) as adapter:
    # List all available tools
    all_tools = adapter.list_tools()
    
    # Search for specific tools
    weather_tools = await adapter.search_tools("weather")
    
    # Get a specific tool
    weather_tool = adapter.get_tool("get_weather")
    
    if weather_tool:
        result = await weather_tool.call(location="New York")
        print(result)

Multiple Sources

config = {
    "manual_call_templates": [
        {
            "name": "petstore",
            "call_template_type": "http", 
            "url": "https://petstore.swagger.io/v2/swagger.json"
        },
        {
            "name": "openlibrary",
            "call_template_type": "http",
            "url": "https://openlibrary.org/static/openapi.json"
        }
    ]
}

async with UtcpToolAdapter(config) as adapter:
    tools = adapter.list_tools()
    print(f"Total tools from all sources: {len(tools)}")

Configuration

Supported Call Template Types

The plugin supports all UTCP call template types:

HTTP Templates

{
    "name": "api_name",
    "call_template_type": "http",
    "url": "https://api.example.com/utcp",
    "http_method": "GET",  # GET, POST, PUT, DELETE
    "content_type": "application/json"
}

Server-Sent Events (SSE)

{
    "name": "sse_stream",
    "call_template_type": "sse", 
    "url": "https://api.example.com/stream",
    "http_method": "GET"
}

Streamable HTTP

{
    "name": "http_stream",
    "call_template_type": "streamable_http",
    "url": "https://api.example.com/stream",
    "http_method": "POST"
}

Command Line Interface

{
    "name": "cli_tool",
    "call_template_type": "cli",
    "command": "python script.py"
}

GraphQL

{
    "name": "graphql_api",
    "call_template_type": "graphql",
    "url": "https://api.example.com/graphql"
}

Model Context Protocol (MCP)

{
    "name": "mcp_server",
    "call_template_type": "mcp",
    "command": "node mcp-server.js"
}

TCP Socket

{
    "name": "tcp_service",
    "call_template_type": "tcp",
    "host": "localhost",
    "port": 8080
}

UDP Socket

{
    "name": "udp_service", 
    "call_template_type": "udp",
    "host": "localhost",
    "port": 8081
}

Text File

{
    "name": "text_tools",
    "call_template_type": "text",
    "file_path": "/path/to/tools.txt"
}

API Reference

UtcpToolAdapter

Main adapter class for UTCP tool integration.

Methods

  • start() - Initialize the UTCP client
  • stop() - Clean up resources
  • list_tools() - Get all available tools
  • get_tool(name) - Get specific tool by name
  • search_tools(query, max_results) - Search for tools
  • call_tool(name, arguments) - Execute a tool
  • to_strands_tools() - Convert to Strands tool format

UtcpAgentTool

Wrapper for individual UTCP tools.

Properties

  • name - Tool name (sanitized)
  • description - Tool description
  • input_schema - JSON Schema for inputs

Methods

  • call(**kwargs) - Execute the tool

UtcpToolAdapterError

Exception raised for UTCP-specific errors.

Testing

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=strands_utcp --cov-report=html

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Links


Built for the UTCP and Strands communities 🚀

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strands_utcp-0.1.0.tar.gz (47.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strands_utcp-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file strands_utcp-0.1.0.tar.gz.

File metadata

  • Download URL: strands_utcp-0.1.0.tar.gz
  • Upload date:
  • Size: 47.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for strands_utcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eab917b183cf7d6f530e4a4442b9e21bb06e63e72065d4fdfa55a73959e29fc0
MD5 fe525f8139896d6eec2c4ff78c37456e
BLAKE2b-256 250d4396aaa3cbf4c98c67eb19b5e3e124a880aa6de160ef8104e2464df79900

See more details on using hashes here.

File details

Details for the file strands_utcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: strands_utcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for strands_utcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 702a16be6d5e0a796e15ca81ef04e25cdacae1b8c5f0d156635a0a126e0f8432
MD5 5326538ff4008d8a1a2ca6e8693cf2f4
BLAKE2b-256 05aaf68cc7f9c20e3feaaa1bf2d4e896e88f7fa83a7f53a4afedebe1cbd68893

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page