subako-function-sdk
Write Subako function packages in Rust. Each #[function] becomes a tool an agent can call:
- the function's name is the tool's name;
- its doc comment is the description the model reads;
- its input and output types, which derive
JsonSchema, become the tool's schemas.
use JsonSchema;
use ;
use ;
/// Greet someone by name.
package!
To show the model an image, return an Answer: the model reads its value as JSON first, then the image. The image travels as an MCP resource_link to volume:///<path beneath /volume>; Core reads the file from the session volume after the call returns, and downscales it to at most 2000 pixels on its long edge.
use ;
/// Plot a chart and show it.
To call an HTTP API, use http::request. The worker sends the request for the function: only https, only to hosts the agent's function grant allows, and with any stored credential the grant names for that origin attached on the way out. An HttpError converts into a ToolError, so ? hands the model the reason.
use ;
/// Fetch a page's text.
The body comes back inline as text, up to http::INLINE_MAX_BYTES. Set output to ResponseOutput::File { path } to stream a larger or binary body into the session volume instead, and send a volume file as the body with RequestBody::File { path }.
Build the module for wasm32-wasip1. The same crate built for your machine prints the package's subako-package.json with cargo run -- --subako-manifest: its ABI, name, and description. Subako learns the tools from the module itself when the package is uploaded.
The protocol
The SDK speaks ABI 1, which any language that compiles to WASI preview 1 can speak too. A module is an MCP server over MCP's stdio transport, on the stateless revision 2026-07-28: one JSON-RPC 2.0 message per line, every request carrying its protocol version and client capabilities in _meta.
- On upload, Subako sends
server/discover, thentools/listuntil its last page. The package serves exactly the tools listed. - On a call, Subako sends one
tools/calland closes stdin once it is answered. The module exits 0 when stdin ends. - A failure the model should read is a result with
isError. A JSON-RPC error, a request from the module, a result that is notcomplete, or a stdout line that is not a message crashes the call. - Notifications are ignored, and a block Subako does not show is replaced by a line saying so.
To start a new package, use the template, which also packages the bundle Subako takes:
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.