Overview
WASM tools are WebAssembly components that:- Run in a sandboxed environment with capability-based permissions
- Execute faster than external processes
- Declare capabilities in a
capabilities.jsonfile - Never see actual credentials (host injects them at runtime)
Quick Start
Prerequisites
- Rust 1.85+ with
wasm32-wasip2target wasm-toolsCLI (optional, for component adaptation)
Project Structure
Step 1: Create Cargo.toml
Step 2: Implement the Tool
Import WIT Bindings
Implement the Guest Trait
Step 3: Create Capabilities File
Createmy-tool.capabilities.json:
Step 4: Build the Tool
Step 5: Install the Tool
Host Functions Available
Logging
HTTP Requests
Workspace Access
Time
Credential Injection
Never hardcode secrets! Use placeholders:{SECRET_NAME} where SECRET_NAME is the credential name in uppercase with underscores.
Testing
Add tests tolib.rs:
LLM-Assisted Building
IronClaw can build tools for you:- Generate the Rust source code
- Create the capabilities file
- Build to WASM
- Install the tool
- Make it available for use
src/tools/builder/ for implementation details.
Troubleshooting
Compilation Errors
Error: can’t find crate forstd
Ensure you’re using wasm32-wasip2 target:
Credential Placeholders Not Replaced
- Check the secret name matches (lowercase with underscores in capabilities)
- Verify the secret is in
allowed_namesin capabilities - Ensure the secret is stored:
ironclaw tool auth my_tool - Check logs for “unresolved placeholders” warnings
HTTP Requests Blocked
- Add the host to
http.allowlistin capabilities - Check path_prefix matches the request path
- Verify the host is exactly as it appears in the URL
Best Practices
- Keep tools focused: One tool, one purpose
- Validate inputs: Check all parameters before processing
- Handle errors gracefully: Return clear error messages
- Use rate limits: Protect against abuse
- Test thoroughly: Include unit tests and integration tests
- Document parameters: Clear descriptions in the schema
- Never expose secrets: Use placeholders, not hardcoded values
Examples
Check the bundled tools intools-src/:
github/- GitHub API integrationslack/- Slack messaginggmail/- Gmail operationsgoogle-calendar/- Calendar managementweb-search/- Web search
Next Steps
- Read the WASM vs MCP guide to understand when to use each
- Explore Docker sandbox for command execution
- Learn about building channels for messaging platforms
