mirror of
https://github.com/zap-proto/dev.git
synced 2026-10-30 15:05:18 +00:00
Folds rich SDK content out of hanzoai/docs into zap-proto/dev (canonical brand). Per-SDK pages: typescript, go, python, rust, cpp, c, java, csharp, ocaml, haskell, erlang. Each carries install, quick-start, client API, gateway, error handling, server impl, and testing. Top-level /sdks/ adds the matrix of all 33 zap-proto repos (core SDKs, community SDKs, wire encoders, editor plugins, tools, protocols over ZAP, spec/research).
52 lines
1.1 KiB
Plaintext
52 lines
1.1 KiB
Plaintext
---
|
|
title: OCaml
|
|
description: ZAP OCaml SDK - Functional binding with Lwt
|
|
---
|
|
|
|
# OCaml Binding
|
|
|
|
The OCaml binding provides a functional interface with Lwt-based async I/O.
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
opam install zap
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
```ocaml
|
|
open Zap
|
|
open Lwt.Infix
|
|
|
|
let () =
|
|
Lwt_main.run begin
|
|
Zap.connect "zap://localhost:9000" >>= fun client ->
|
|
|
|
let info = { name = "my-agent"; version = "1.0.0" } in
|
|
Zap.init client info >>= fun server ->
|
|
Lwt_io.printf "Connected to: %s v%s\n" server.name server.version >>= fun () ->
|
|
|
|
Zap.list_tools client >>= fun tools ->
|
|
Lwt_list.iter_s (fun tool ->
|
|
Lwt_io.printf " %s - %s\n" tool.name tool.description
|
|
) tools >>= fun () ->
|
|
|
|
let call = {
|
|
id = "call-1";
|
|
name = "read_file";
|
|
args = {|{"path": "/etc/hosts"}|};
|
|
metadata = [];
|
|
} in
|
|
Zap.call_tool client call >>= fun result ->
|
|
|
|
match result.error with
|
|
| Some err -> Lwt_io.eprintf "Error: %s\n" err
|
|
| None -> Lwt_io.printf "Result: %s\n" result.content
|
|
end
|
|
```
|
|
|
|
## Documentation
|
|
|
|
Full documentation at [zap-proto/ocaml](https://github.com/zap-proto/ocaml).
|