Your First Component
This guide walks you through creating a simple ACT component that provides text utility tools.
Project Setup
Section titled “Project Setup”Create a new Rust library with the WASM target:
cargo new --lib text-toolscd text-toolsAdd rust-toolchain.toml:
[toolchain]channel = "nightly"targets = ["wasm32-wasip2"]Update Cargo.toml:
[package]name = "text-tools"version = "0.1.0"edition = "2024"
[lib]crate-type = ["cdylib"]
[dependencies]act-sdk = "0.2"Write the Component
Section titled “Write the Component”Replace src/lib.rs with:
use act_sdk::prelude::*;
#[act_component( name = "text-tools", description = "Text manipulation utilities", version = "0.1.0")]struct TextTools;
#[act_tool(description = "Convert text to uppercase")]fn to_upper(text: String) -> String { text.to_uppercase()}
#[act_tool(description = "Count words in text")]fn word_count(text: String) -> u32 { text.split_whitespace().count() as u32}
#[act_tool(description = "Reverse a string")]fn reverse(text: String) -> String { text.chars().rev().collect()}The #[act_component] macro generates the WIT bindings, JSON Schema, and component metadata automatically.
cargo build --target wasm32-wasip2 --releaseThe output is at target/wasm32-wasip2/release/text_tools.wasm.
Inspect
Section titled “Inspect”# Show component info (reads custom section, no instantiation)act info target/wasm32-wasip2/release/text_tools.wasm
# List available toolsact tools target/wasm32-wasip2/release/text_tools.wasm# Call a tool directlyact call target/wasm32-wasip2/release/text_tools.wasm \ to_upper --args '{"text": "hello world"}'
# Serve over HTTPact serve target/wasm32-wasip2/release/text_tools.wasm
# Serve as MCP server (for Claude, Cursor, etc.)act mcp target/wasm32-wasip2/release/text_tools.wasmUse with Claude Desktop
Section titled “Use with Claude Desktop”Add to your Claude Desktop MCP config (claude_desktop_config.json):
{ "mcpServers": { "text-tools": { "command": "act", "args": ["mcp", "/path/to/text_tools.wasm"] } }}Next Steps
Section titled “Next Steps”- Architecture overview — understand how ACT works under the hood
- WIT API reference — the full
act:core@0.2.0interface