Skip to main content

HTBP (HTTP Tool Bridge Protocol) server SDK: expose functions as self-describing HTTP tool endpoints, FastAPI-style.

Project description

htbp-sdk

HTBP (HTTP Tool Bridge Protocol) server SDK for Python. Expose functions as self-describing HTTP tool endpoints, FastAPI-style. Pure ASGI — runs under uvicorn/hypercorn and mounts inside FastAPI or Starlette.

Install

pip install htbp-sdk            # import name: htbp
pip install 'htbp-sdk[remote]'  # + httpx, needed only for app.remote()

Quickstart

from htbp import Htbp

app = Htbp(title="Math tools")

@app.tool(effect="read")
def add(a: int, b: int = 0) -> int:
    """Add two integers."""
    return a + b
uvicorn main:app

Input schemas are derived from type hints via pydantic (FastAPI-style); a single parameter annotated with a BaseModel subclass uses that model as the body schema directly. Async functions are awaited; sync functions run in a thread. A ToolContext-annotated parameter receives request context.

Every node answers GET {path}/~help (JSON by default, RFC-0001 text DSL with Accept: text/plain); tools are invoked with POST {path} and respond with {"resource", "result"}.

Cascading

docs = Htbp(title="Docs tools")

@docs.tool()
def search(q: str) -> dict:
    return {"hits": [q]}

app.mount("/docs", docs)                                # local nesting
app.remote("/ext", "https://other.example.com/~help")   # federate a remote HTBP server

Remote nodes pass through ~help for any sub-path and proxy calls; the inbound Authorization header is never forwarded upstream.

Mount inside FastAPI:

fastapi_app.mount("/tools", app)

Options

Htbp(
    title="My tools",
    description="...",
    auth={"bearer_token": "..."},   # 401 + WWW-Authenticate without it
    skill="# Markdown served at /~skill",
    base_path="/htbp",               # serve under a path prefix
    cors=False,                      # CORS is on by default
)

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

htbp_sdk-0.1.1.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

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

htbp_sdk-0.1.1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file htbp_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: htbp_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for htbp_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7cb60c9f1ce0b8e7b9d792248f2676a228baef0dfc742155f33837b7d76448a8
MD5 1939f27a6c904b02cd49e08612f6d896
BLAKE2b-256 8e22f4dba109c647267043303fe053aaa23014d62892e3c977b18a8bf24e2540

See more details on using hashes here.

File details

Details for the file htbp_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: htbp_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for htbp_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c52e9fd14766edb592c77a819fd07d1e3a91eb15b7e0beee3bef18cbe2c8a364
MD5 0175ecb2cce18427f2c8f63734f5942a
BLAKE2b-256 0783b247a633327ee010a0fa9d327b1bf152fb1f9bee9c80c13638e19ac7f4f2

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