Skip to main content

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.

Metadata

Release files for utcp-http 1.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for utcp-http 1.1.12
File Size Uploaded
utcp_http-1.1.12.tar.gz 68.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for utcp-http 1.1.12
File Interpreter ABI Platform
utcp_http-1.1.12-py3-none-any.whl Python 3 none any Details

Total release size: 114.0 kB

Release files / utcp_http-1.1.12.tar.gz

Download URL utcp_http-1.1.12.tar.gz
Size 68.0 kB
Tags Source
SHA-256 checksum
How to use checksums
aa467ef80ae5ea6d793e413c2c95d3f9c82d8586a9ce46392bf773507119c5e2
BLAKE2b-256 checksum
How to use checksums
18ed8517dfdc5c7e730b319eecb798218c97b41f4ea61e22343e4ac5a9883535
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / utcp_http-1.1.12-py3-none-any.whl

Download URL utcp_http-1.1.12-py3-none-any.whl
Size 46.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3018576f3b9f825ffb57e385c8366b41fbf0f80776e2a4b62fae08a87799472b
BLAKE2b-256 checksum
How to use checksums
f0d7859c2801fae739d4d1ac48048690847bcd6a6b0cdf599d98a490df4e4a9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release history Release notifications | RSS feed

1.1.14

2 release files

This release

1.1.12 This release

2 release files

1.1.11

2 release files

1.1.10

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page