Skip to content

Your First Component

This guide walks you through creating a simple ACT component that provides text utility tools.

Create a new Rust library with the WASM target:

Terminal window
cargo new --lib text-tools
cd text-tools

Add 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"

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.

Terminal window
cargo build --target wasm32-wasip2 --release

The output is at target/wasm32-wasip2/release/text_tools.wasm.

Terminal window
# Show component info (reads custom section, no instantiation)
act info target/wasm32-wasip2/release/text_tools.wasm
# List available tools
act tools target/wasm32-wasip2/release/text_tools.wasm
Terminal window
# Call a tool directly
act call target/wasm32-wasip2/release/text_tools.wasm \
to_upper --args '{"text": "hello world"}'
# Serve over HTTP
act serve target/wasm32-wasip2/release/text_tools.wasm
# Serve as MCP server (for Claude, Cursor, etc.)
act mcp target/wasm32-wasip2/release/text_tools.wasm

Add to your Claude Desktop MCP config (claude_desktop_config.json):

{
"mcpServers": {
"text-tools": {
"command": "act",
"args": ["mcp", "/path/to/text_tools.wasm"]
}
}
}