act-sdk-rs
Build AI-ready WebAssembly components in Rust
Rust SDK for the ACT protocol — define tools as plain functions, compile to .wasm, serve over MCP or HTTP.
use act_sdk::prelude::*;
#[derive(Deserialize, JsonSchema)]
struct GreetArgs {
name: String,
}
#[act_component(name = "greeter", version = "0.1.0", description = "A greeter")]
mod component {
use super::*;
#[act_tool(description = "Say hello", read_only)]
fn greet(args: GreetArgs) -> ActResult<String> {
Ok(format!("Hello, {}!", args.name))
}
}cargo build --target wasm32-wasip2 --release
act serve target/wasm32-wasip2/release/greeter.wasm
# or
act mcp target/wasm32-wasip2/release/greeter.wasm| Crate | Description |
|---|---|
act-sdk |
SDK with #[act_component] and #[act_tool] macros |
act-sdk-macros |
Proc macro implementation |
act-types |
Shared types, CBOR utilities, JSON-RPC and MCP wire formats |
#[act_tool]— derive tool metadata, JSON Schema, and CBOR serialization from a plain Rust function- Streaming — mark tools with
streamingand useActContextto emit progress events - Typed config — define a config struct, get automatic JSON Schema generation and validation
- MCP + HTTP — same
.wasmworks with both transports, zero code changes
| Example | What it shows |
|---|---|
hello-sdk |
Basic tools, streaming with ctx.send_progress() |
config-sdk |
Typed component configuration |
http-client-sdk |
Outbound HTTP via WASI |
hello-world |
Minimal component without SDK (raw wit-bindgen) |
http-client |
Raw HTTP client without SDK |
counter |
Stateful counter |
Requires Rust nightly (for wasm32-wasip2 async support):
# Build all examples
cargo build --target wasm32-wasip2 --release
# Run tests (host-side, not wasm)
cargo test --target x86_64-unknown-linux-gnuSee rust-toolchain.toml for the pinned toolchain.
Licensed under either of Apache License, Version 2.0 or MIT License at your option.