Files
zeekayandHanzo Dev 412d7b2a11 feat: the six capabilities, and a credential the client mints itself
budget, policy, audit, search, kb and graph hang off the client as one word
each — the same word in the Go, Python and TypeScript SDKs, capitalized here
because that is Go's rule. They live in their own packages because they must:
the generated client already spells Answer, Page, Hit, Backend, Wrote,
Allowance, Charge, Policy, Audit, Graph and Link as projections of unrelated
operations, and a hand-written type cannot share a package with a generated one
of the same name.

A refusal is a value. Anything a gate can refuse answers call.Answer[T], whose
value is reachable only through Value(), which hands back a *Denied where a
budget or a policy said no, a *Held where a person was asked, and a *Fault where
nothing decided anything. One rule maps a status to an arm and no capability
varies it: 2xx is the value, a 202 whose body says held is a hold, 402 is a
denial whatever the code, a 403 carrying a refusal code is a denial, and
everything else is a fault. That last allow-list exists only because cloud
spells "no validated principal" as 403 forbidden; reading a bare forbidden as a
denial would tell an unauthenticated caller their budget said no.

IAM mints and the SDK never accepts a bearer. New exchanges the client's own
clientId and clientSecret for an access token — client_credentials under
client_secret_basic, scoped by the RFC 8707 resource — holds it to a minute
before expiry and mints again on a 401, once. NewClient(apiKey), NewConfig,
HANZO_API_KEY, Read and Result[T] are removed rather than deprecated: a
credential an SDK is handed is a credential nobody rotates, and two ways to do
one thing is the defect the contract exists to prevent.

Measured against api.hanzo.ai, not inferred. /v1/authz/check binds
{subject, verb, path}, which is not the {sub, obj, act} its own description
states, so the SDK sends what the handler reads. The two money routes declare an
address and no shape, so budget models them. /v1/audit accepts no requestId
filter though every row carries one, so audit.Filter.Request narrows
client-side. LLM.md carries the whole list.

examples/six walks the composition end to end: what the wallet holds decides
whether to ask, the wallet's own account names the org a policy question is
scoped to, a search states its degradation, a graph write answers a request id,
and that id finds the row the server wrote about it. examples/agent and
examples/tools stop calling operations that were renamed out from under them.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-10 14:51:06 -07:00

37 lines
884 B
Go

// tools — list the MCP tools this credential can reach.
//
// Operation: GET /v1/tool (get_tool).
//
// This is the served tool list: every tool the caller's org can see, which is
// what an MCP tools/list answers. To CALL one, the next route is
// POST /v1/tool/call (post_tool_call).
//
// HANZO_CLIENT_ID=... HANZO_CLIENT_SECRET=... go run ./examples/tools
package main
import (
"context"
"fmt"
"log"
hanzoai "github.com/hanzoai/go-sdk/v8"
)
func main() {
client := hanzoai.New(hanzoai.Options{})
list, _, err := client.ToolAPI.GetTool(context.Background()).Execute()
if err != nil {
log.Fatalf("tools: %v", err)
}
tools := list.Tools
if len(tools) == 0 {
log.Fatal("tools: the list is empty")
}
fmt.Printf("%d tools\n", len(tools))
for _, tool := range tools[:min(3, len(tools))] {
fmt.Printf(" %-32s %s\n", tool.GetName(), tool.GetDescription())
}
}