Files
python-sdk/examples/tools/__main__.py
T
zeekay ec0d1769d0 regenerate from cloud 939b09d4
The projection was 113 commits behind the document it claims to describe, and
`generate.py --all --check` reported every one of the thirteen clients DRIFTED —
the same +19 models in each, because they all fell behind the same emission.

Regenerated in place from hanzo-inc/cloud openapi.yaml at 939b09d4
(sha256 087024f6…), which is the only description of this API that cannot name a
route the binary does not serve. `--check` is clean across all thirteen after.

.spec-lock moved with the code. The generator READS that file and never writes
it — hanzoai/ci`s lane does — so a hand run leaves every lock naming the previous
document. A lock that disagrees with the tree beside it is worse than no lock:
the next `--check` without `--spec` fetches what production serves, compares it
to a digest that was already wrong, and reports drift that is really staleness.
2026-08-24 23:32:41 -07:00

36 lines
1.2 KiB
Python

"""tools — list the tools this key can reach.
``GET /v1/tools`` (operationId ``get_tools``), the catalog behind the
MCP surface: each entry is a tool name, its description and its input schema.
A note on the MCP endpoints, because it is easy to pick the wrong one. There is a
JSON-RPC endpoint at ``POST /v1/mcp`` that answers ``tools/list`` with the same
catalog — but it is NOT in the document, so the generator emits no method for it
and an example would have to bypass the SDK to call it, which defeats the point
of an SDK example. Of the MCP routes that ARE declared, ``/v1/automations/mcp``
404s at api.hanzo.ai. So this catalog read is the one that is both generated and
served. When ``/v1/mcp`` is added to the spec, this flow should move to it.
python -m examples.tools
"""
from hanzoai.cloud import ToolsApi
from examples.client import client, run
def main() -> None:
with client() as api:
catalog = ToolsApi(api).get_tools()
tools = catalog.tools or []
print(f"{len(tools)} tools")
for tool in tools[:20]:
print(f" {tool.name} — {tool.description or '(no description)'}")
if len(tools) > 20:
print(f" … and {len(tools) - 20} more")
if __name__ == "__main__":
run(main)