Skip to main content

UTCP communication protocol plugin for HTTP, SSE, and streamable HTTP, plus an OpenAPI converter.

Reason this release was yanked:

Incomplete fix for CVE-2026-44661 / GHSA-39j6-4867-gg4w. Use 1.1.3.

Project description

UTCP HTTP Plugin

PyPI Downloads

HTTP communication protocol plugin for UTCP, supporting REST APIs, Server-Sent Events (SSE), and streaming HTTP.

Features

  • HTTP/REST APIs: Full support for GET, POST, PUT, DELETE, PATCH methods
  • Authentication: API key, Basic Auth, OAuth2 support
  • Server-Sent Events (SSE): Real-time event streaming
  • Streaming HTTP: Large response handling with chunked transfer
  • OpenAPI Integration: Automatic tool generation from OpenAPI specs
  • Path Parameters: URL templating with {parameter} syntax
  • Custom Headers: Static and dynamic header support

Installation

pip install utcp-http

Quick Start

from utcp.utcp_client import UtcpClient

# Basic HTTP API
client = await UtcpClient.create(config={
    "manual_call_templates": [{
        "name": "api_service",
        "call_template_type": "http",
        "url": "https://api.example.com/users/{user_id}",
        "http_method": "GET"
    }]
})

result = await client.call_tool("api_service.get_user", {"user_id": "123"})

Configuration Examples

Basic HTTP Request

{
  "name": "my_api",
  "call_template_type": "http",
  "url": "https://api.example.com/data",
  "http_method": "GET"
}

With API Key Authentication

{
  "name": "secure_api",
  "call_template_type": "http",
  "url": "https://api.example.com/data",
  "http_method": "POST",
  "auth": {
    "auth_type": "api_key",
    "api_key": "${API_KEY}",
    "var_name": "X-API-Key",
    "location": "header"
  }
}

OAuth2 Authentication

{
  "name": "oauth_api",
  "call_template_type": "http",
  "url": "https://api.example.com/data",
  "auth": {
    "auth_type": "oauth2",
    "client_id": "${CLIENT_ID}",
    "client_secret": "${CLIENT_SECRET}",
    "token_url": "https://auth.example.com/token"
  }
}

Server-Sent Events (SSE)

{
  "name": "event_stream",
  "call_template_type": "sse",
  "url": "https://api.example.com/events",
  "event_type": "message",
  "reconnect": true
}

Streaming HTTP

{
  "name": "large_data",
  "call_template_type": "streamable_http",
  "url": "https://api.example.com/download",
  "chunk_size": 8192
}

OpenAPI Integration

Automatically generate UTCP tools from OpenAPI specifications:

from utcp_http.openapi_converter import OpenApiConverter

converter = OpenApiConverter()
manual = await converter.convert_openapi_to_manual(
    "https://api.example.com/openapi.json"
)

client = await UtcpClient.create()
await client.register_manual(manual)

Error Handling

from utcp.exceptions import ToolCallError
import httpx

try:
    result = await client.call_tool("api.get_data", {"id": "123"})
except ToolCallError as e:
    if isinstance(e.__cause__, httpx.HTTPStatusError):
        print(f"HTTP {e.__cause__.response.status_code}: {e.__cause__.response.text}")

Related Documentation

Examples

For complete examples, see the UTCP examples repository.

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

utcp_http-1.1.2.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

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

utcp_http-1.1.2-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file utcp_http-1.1.2.tar.gz.

File metadata

  • Download URL: utcp_http-1.1.2.tar.gz
  • Upload date:
  • Size: 35.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for utcp_http-1.1.2.tar.gz
Algorithm Hash digest
SHA256 dd56f19c6d20aa1a476712374a2aa21a829a64ee14944b34f59ea1760d6ba826
MD5 1c25fa97059cd5f34b47c6d03087d729
BLAKE2b-256 ecdfe7d57e6e685589487d41a9e88441767b27e4bbba8ef8d411641344e2278f

See more details on using hashes here.

File details

Details for the file utcp_http-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: utcp_http-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 29.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for utcp_http-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ab99a4baa94eaffbe5dadc216830bcf593b8b138eb8cc3bc34dae501ba060a8f
MD5 8ca90f900d7aa5576b48af1f265a65fc
BLAKE2b-256 402281fe84e200d6bd932ab87c00d9f10fb150266f55622e488c24222a7807e1

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