### Verify act-cli Installation Source: https://actcore.dev/docs/getting-started/installation Checks the installed version of the act-cli to confirm successful installation. ```bash act --version ``` -------------------------------- ### Rust Toolchain Setup for WebAssembly Source: https://actcore.dev/docs/getting-started/installation Installs the nightly Rust toolchain and adds the wasm32-wasip2 target, which is required for ACT components targeting WebAssembly. ```bash rustup toolchain install nightly rustup target add wasm32-wasip2 --toolchain nightly ``` -------------------------------- ### Quick Example: Base64 Encoding Tool Source: https://actcore.dev/docs A practical example demonstrating how to create a simple base64 encoding tool using the ACT SDK and how to build, serve, and call it. ```APIDOC ## Quick Example: Base64 Encoding Tool This example shows a basic ACT component that exposes a `base64_encode` tool. ### Rust Code (`src/lib.rs`) ```rust use act_sdk::prelude::*; #[act_component] struct MyTools; #[act_tool(description = "Encode text as base64")] fn base64_encode(input: String) -> String { use base64::Engine; base64::engine::general_purpose::STANDARD.encode(input) } ``` ### Build and Serve 1. **Build the component for WASI:** ```bash cargo build --target wasm32-wasip2 --release ``` 2. **Serve over MCP (for AI agents):** ```bash act mcp my-tools.wasm ``` 3. **Serve over HTTP (for applications):** ```bash act serve my-tools.wasm ``` 4. **Call directly via CLI:** ```bash act call my-tools.wasm base64_encode --args '{"input": "hello"}' ``` ### Request Example (CLI Call) ```json { "input": "hello" } ``` ### Response Example (CLI Call) ```json { "output": "aGVsbG8=" } ``` ``` -------------------------------- ### Install act-cli using npm Source: https://actcore.dev/docs/getting-started/installation Installs the act-cli globally using npm. This is a common method for Node.js package management. ```bash npm install -g @actcore/act-cli ``` -------------------------------- ### Start HTTP server for a component Source: https://actcore.dev/docs/reference/cli Starts an HTTP server to host a WebAssembly component. Allows configuration of the port and bind address via command-line options. ```bash act serve [options] ``` -------------------------------- ### Install act-cli using pip Source: https://actcore.dev/docs/getting-started/installation Installs the act-cli using pip, the package installer for Python. This is suitable for Python environments. ```bash pip install actcore ``` -------------------------------- ### Scaffold a Component Manually (Rust) Source: https://actcore.dev/docs/getting-started/installation Manually creates a new Rust library project for a component and adds necessary dependencies to `Cargo.toml`. ```bash cargo new --lib my-component cd my-component ``` ```toml [lib] crate-type = ["cdylib"] [dependencies] act-sdk = "0.2" ``` -------------------------------- ### Install act-cli using Cargo Source: https://actcore.dev/docs/getting-started/installation Installs the act-cli using Cargo, the Rust package manager. This is the preferred method for Rust developers. ```bash cargo install act-cli ``` -------------------------------- ### Scaffold a Component using copier Source: https://actcore.dev/docs/getting-started/installation Uses the `copier` tool to scaffold a new Actcore component from a template. Requires pip to install copier. ```bash pip install copier copier copy gh:actcore/act-component-template my-component ``` -------------------------------- ### Rust Project Setup for ACT Component Source: https://actcore.dev/docs/getting-started/first-component Initializes a new Rust library project with the WASM target and configures the toolchain and dependencies for ACT SDK. ```bash cargo new --lib text-tools cd text-tools ``` ```toml [toolchain] channel = "nightly" targets = ["wasm32-wasip2"] ``` ```toml [package] name = "text-tools" version = "0.1.0" edition = "2024" [lib] crate-type = ["cdylib"] [dependencies] act-sdk = "0.2" ``` -------------------------------- ### act serve Source: https://actcore.dev/docs/reference/cli Starts an HTTP server for a WebAssembly component. ```APIDOC ## act serve ### Description Starts an HTTP server for a component. ### Method CLI Command ### Endpoint N/A (CLI command) ### Parameters #### Path Parameters - **component.wasm** (string) - Required - The path to the WebAssembly component file. #### Query Parameters N/A #### Request Body N/A ### Request Example ```bash act serve my-component.wasm --port 8080 --host 0.0.0.0 ``` ### Response #### Success Response (200) N/A (Server starts and listens for requests) #### Response Example N/A ``` -------------------------------- ### Pin Rust Toolchain using rust-toolchain.toml Source: https://actcore.dev/docs/getting-started/installation Configures a project to use the nightly Rust toolchain with the wasm32-wasip2 target by creating a `rust-toolchain.toml` file. ```toml [toolchain] channel = "nightly" targets = ["wasm32-wasip2"] ``` -------------------------------- ### Start MCP Stdio Server Source: https://actcore.dev/docs/concepts/transports Initializes an MCP server using the ACT CLI. This allows integration with tools like Claude Desktop or Cursor. ```bash act mcp my-component.wasm ``` -------------------------------- ### Rust ACT Component Example Source: https://actcore.dev/docs Example of a Rust ACT component defining a tool for base64 encoding. This snippet demonstrates the basic structure of an ACT component using the `act_sdk` and `#[act_component]` macro. ```rust use act_sdk::prelude::*; #[act_component] struct MyTools; #[act_tool(description = "Encode text as base64")] fn base64_encode(input: String) -> String { use base64::Engine; base64::engine::general_purpose::STANDARD.encode(input) } ``` -------------------------------- ### Start MCP stdio server Source: https://actcore.dev/docs/reference/cli Initializes an MCP server that communicates via stdin and stdout. Designed for integration with MCP clients like Claude Desktop or Cursor. ```bash act mcp ``` -------------------------------- ### act mcp Source: https://actcore.dev/docs/reference/cli Starts an MCP stdio server for a WebAssembly component. ```APIDOC ## act mcp ### Description Starts an MCP stdio server. Reads JSON-RPC from stdin and writes to stdout. Use with Claude Desktop, Cursor, or any MCP client. ### Method CLI Command ### Endpoint N/A (CLI command) ### Parameters #### Path Parameters - **component.wasm** (string) - Required - The path to the WebAssembly component file. #### Query Parameters N/A #### Request Body N/A ### Request Example ```bash act mcp my-component.wasm ``` ### Response #### Success Response (200) N/A (Server starts and communicates via stdio) #### Response Example N/A ``` -------------------------------- ### Claude Desktop MCP Configuration Source: https://actcore.dev/docs/getting-started/first-component Example JSON configuration for Claude Desktop to integrate the 'text-tools' ACT component as an MCP server, specifying the command and arguments to launch it. ```json { "mcpServers": { "text-tools": { "command": "act", "args": ["mcp", "/path/to/text_tools.wasm"] } } } ``` -------------------------------- ### GET /tools Source: https://actcore.dev/docs/concepts/transports Retrieves a list of all available tools provided by the ACT component. ```APIDOC ## GET /tools ### Description Returns a list of all tools exposed by the component. ### Method GET ### Endpoint /tools ### Response #### Success Response (200) - **tools** (array) - List of available tool definitions. #### Response Example { "tools": [ { "name": "base64_encode", "description": "Encodes string to base64" } ] } ``` -------------------------------- ### ACT-HTTP Server and REST Operations Source: https://actcore.dev/docs/concepts/transports Commands to start an ACT-HTTP server and interact with it using curl. It supports listing tools, calling tools, and retrieving metadata schemas via standard REST endpoints. ```bash # Start HTTP server (default [::1]:3000) act serve my-component.wasm --port 8080 # List tools curl http://localhost:8080/tools # Call a tool curl -X POST http://localhost:8080/call/base64_encode \ -H "Content-Type: application/json" \ -d '{"arguments": {"input": "hello"}}' ``` -------------------------------- ### GET /metadata-schema Source: https://actcore.dev/docs/concepts/transports Retrieves the JSON Schema for the component's required metadata. ```APIDOC ## GET /metadata-schema ### Description Returns the JSON Schema defining the expected metadata structure for the component. ### Method GET ### Endpoint /metadata-schema ### Response #### Success Response (200) - **schema** (object) - The JSON schema definition. #### Response Example { "type": "object", "properties": { "api_key": { "type": "string" } } } ``` -------------------------------- ### Tool Provider Interface Source: https://actcore.dev/docs/reference/wit-api Defines the interface for a tool provider, including methods to get metadata schema, list available tools, and call tools. ```wit interface tool-provider { get-metadata-schema: async func(metadata: metadata) -> option; list-tools: async func(metadata: metadata) -> result; call-tool: async func(call: tool-call) -> stream; } ``` -------------------------------- ### Running ACT Component Tools Source: https://actcore.dev/docs/getting-started/first-component Demonstrates how to execute the ACT component's tools directly via the CLI, serve the component over HTTP, or as an MCP server for AI models. ```bash # 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 ``` -------------------------------- ### List available tools Source: https://actcore.dev/docs/reference/cli Displays a list of all tools exposed by the specified WebAssembly component. ```bash act tools ``` -------------------------------- ### Building and Inspecting ACT Component Source: https://actcore.dev/docs/getting-started/first-component Commands to build the Rust ACT component for the WASM target and inspect its metadata and available tools using the 'act' CLI. ```bash cargo build --target wasm32-wasip2 --release ``` ```bash # 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 ``` -------------------------------- ### ACT Component Build and Serve Commands Source: https://actcore.dev/docs Commands for building an ACT component for WASM, serving it over MCP for AI agents, serving it over HTTP for applications, and calling a tool directly via the CLI. ```shell # Build cargo build --target wasm32-wasip2 --release # Serve over MCP (for AI agents) act mcp my-tools.wasm # Serve over HTTP (for apps) act serve my-tools.wasm # Call directly act call my-tools.wasm base64_encode --args '{"input": "hello"}' ``` -------------------------------- ### Run a Component from Registry Source: https://actcore.dev/docs/concepts/components Executes a specified component version from the ACT registry, which is automatically cached locally. ```bash act run dev.actcore:component-sqlite@0.1.0 ``` -------------------------------- ### WIT Interface for Tool Provider Source: https://actcore.dev/docs Defines the Web Interface Description Language (WIDL) interface that ACT components implement for providing tools. ```APIDOC ## WIT Interface ACT components implement the `act:core@0.2.0` interface, specifically the `tool-provider`. ```wit interface tool-provider { get-metadata-schema: async func(metadata: metadata) -> option; list-tools: async func(metadata: metadata) -> result; call-tool: async func(call: tool-call) -> stream; } ``` Component information is stored in a WASM custom section (`act:component`, CBOR-encoded), not an exported function. ``` -------------------------------- ### Define Localized Strings Source: https://actcore.dev/docs/concepts/components Demonstrates how to define tool descriptions using the localized_string variant, supporting both plain text and multi-language BCP 47 strings. ```rust // Simple — single language localized_string::plain("Encode text as base64") // Localized — multiple languages (BCP 47) localized_string::localized(vec![ ("en", "Encode text as base64"), ("ru", "Закодировать текст в base64"), ]) ``` -------------------------------- ### POST /call/{tool} Source: https://actcore.dev/docs/concepts/transports Executes a specific tool by name with provided arguments. ```APIDOC ## POST /call/{tool} ### Description Invokes a specific tool defined within the component. ### Method POST ### Endpoint /call/{tool} ### Parameters #### Path Parameters - **tool** (string) - Required - The name of the tool to execute. #### Request Body - **arguments** (object) - Required - The input arguments required by the tool. ### Request Example { "arguments": { "input": "hello" } } ### Response #### Success Response (200) - **result** (any) - The output returned by the tool execution. #### Response Example { "result": "aGVsbG8=" } ``` -------------------------------- ### Call a component tool Source: https://actcore.dev/docs/reference/cli Invokes a specific tool within a WebAssembly component. Supports passing arguments and metadata as JSON strings. ```bash act call [options] act call my-tools.wasm search --args '{"query": "rust wasm"}' ``` -------------------------------- ### act tools Source: https://actcore.dev/docs/reference/cli Lists available tools within a WebAssembly component. ```APIDOC ## act tools ### Description List available tools in a component. ### Method CLI Command ### Endpoint N/A (CLI command) ### Parameters #### Path Parameters - **component.wasm** (string) - Required - The path to the WebAssembly component file. #### Query Parameters N/A #### Request Body N/A ### Request Example ```bash act tools my-component.wasm ``` ### Response #### Success Response (200) - **tools** (array) - A list of available tool names. #### Response Example ```json { "tools": ["tool1", "tool2"] } ``` ``` -------------------------------- ### Inspect Component Metadata Source: https://actcore.dev/docs/concepts/components Uses the ACT CLI to inspect the metadata of a compiled WebAssembly component file without requiring instantiation. ```bash $ act info my-component.wasm ``` -------------------------------- ### ACT Component Implementation in Rust Source: https://actcore.dev/docs/getting-started/first-component Defines an ACT component named 'text-tools' with three utility functions: converting text to uppercase, counting words, and reversing a string. It utilizes ACT SDK macros for component and tool registration. ```rust 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() } ``` -------------------------------- ### Tool Definition Record Source: https://actcore.dev/docs/reference/wit-api Defines the structure for a tool definition, including its name, optional description, input schema, annotations, and extensions. ```wit record tool-definition { name: string, description: option, input-schema: option, annotations: option>>>, extensions: option>>>, } ``` -------------------------------- ### Package Declaration Source: https://actcore.dev/docs/reference/wit-api Declares the package name and version for the actcore library. ```wit package act:core@0.2.0; ``` -------------------------------- ### act info Source: https://actcore.dev/docs/reference/cli Displays metadata for a WebAssembly component. ```APIDOC ## act info ### Description Show component metadata. Reads the `act:component` custom section without instantiating the component. ### Method CLI Command ### Endpoint N/A (CLI command) ### Parameters #### Path Parameters - **component.wasm** (string) - Required - The path to the WebAssembly component file. #### Query Parameters N/A #### Request Body N/A ### Request Example ```bash act info my-component.wasm ``` ### Response #### Success Response (200) - **metadata** (object) - The metadata of the component. #### Response Example ```json { "metadata": { "name": "MyComponent", "version": "1.0.0" } } ``` ``` -------------------------------- ### ACT Core Concepts Source: https://actcore.dev/docs Overview of the fundamental concepts within the ACT protocol, including Components, Tools, Transport Adapters, and Metadata. ```APIDOC ## Core Concepts - **Component**: A `.wasm` file that exports the `act-world` world. - **Tool**: A named callable function exposed via the `tool-provider` interface. - **Transport Adapter**: Translates protocols like MCP, HTTP, or others into ACT host calls. - **Metadata**: Per-call context passed through the host, used for authentication, tracing, and configuration. ``` -------------------------------- ### WIT Interface Definition for ACT Tools Source: https://actcore.dev/docs The Web Interface Description (WIT) for the ACT tool provider interface. This defines the contract for how ACT components expose their tools, including metadata handling, tool listing, and tool calling. ```wit interface tool-provider { get-metadata-schema: async func(metadata: metadata) -> option; list-tools: async func(metadata: metadata) -> result; call-tool: async func(call: tool-call) -> stream; } ``` -------------------------------- ### ACT CLI Component Management Source: https://actcore.dev/docs/concepts/transports Direct command-line interface operations for invoking specific tools, listing available tools, and retrieving component metadata. ```bash # Call a specific tool act call my-component.wasm tool-name \ --args '{"key": "value"}' \ --metadata '{"key": "value"}' # List tools act tools my-component.wasm # Show component info act info my-component.wasm ``` -------------------------------- ### Show component metadata Source: https://actcore.dev/docs/reference/cli Retrieves and displays metadata from the component's custom section without executing the component code. ```bash act info ``` -------------------------------- ### Tool Call Record Source: https://actcore.dev/docs/reference/wit-api Defines the structure for a tool call, including the tool's name, optional CBOR-encoded arguments, metadata, and extensions. ```wit record tool-call { name: string, arguments: option>, metadata: metadata, extensions: option>>>, } ``` -------------------------------- ### World Definition Source: https://actcore.dev/docs/reference/wit-api Defines the world for the actcore component, exporting the tool-provider interface. ```wit world act-world { export tool-provider; } ``` -------------------------------- ### Content Part Record Source: https://actcore.dev/docs/reference/wit-api Defines the structure for a content part within a stream event, including optional MIME type, data, annotations, and extensions. Data encoding varies by MIME type. ```wit record content-part { mime-type: option, data: option>, annotations: option>>>, extensions: option>>>, } ``` -------------------------------- ### Define an ACT Component World Source: https://actcore.dev/docs/concepts/components Defines the core interface for an ACT component by exporting the act:core/tool-provider world within a WebAssembly module. ```wit world act-world { export act:core/tool-provider; } ``` -------------------------------- ### Tool Error Record Source: https://actcore.dev/docs/reference/wit-api Defines the structure for a tool error, including its kind, an optional localized message, and extensions. ```wit record tool-error { kind: error-kind, message: option, extensions: option>>>, } ``` -------------------------------- ### Metadata Type Definition Source: https://actcore.dev/docs/reference/wit-api Defines the metadata type as a list of key-value pairs, where keys are strings and values are CBOR-encoded bytes. ```wit type metadata = list>>; ``` -------------------------------- ### act call Source: https://actcore.dev/docs/reference/cli Calls a tool directly within a WebAssembly component. ```APIDOC ## act call ### Description Call a tool directly. ### Method CLI Command ### Endpoint N/A (CLI command) ### Parameters #### Path Parameters - **component.wasm** (string) - Required - The path to the WebAssembly component file. - **tool-name** (string) - Required - The name of the tool to call. #### Query Parameters N/A #### Request Body N/A #### Options - **--args** (string) - Optional - Tool arguments as JSON. - **--metadata** (string) - Optional - Metadata key-value pairs as JSON. ### Request Example ```bash act call my-tools.wasm search --args '{"query": "rust wasm"}' --metadata '{"user_id": "123"}' ``` ### Response #### Success Response (200) - **result** (any) - The result of the tool call. #### Response Example ```json { "result": "Search results..." } ``` ``` -------------------------------- ### Stream Event Variant Source: https://actcore.dev/docs/reference/wit-api Defines the possible types of events that can be streamed from a tool call: content, error, or metadata. ```wit variant stream-event { content(content-part), error(tool-error), metadata(list>>), } ``` -------------------------------- ### Error Kind Variant Source: https://actcore.dev/docs/reference/wit-api Defines the possible kinds of errors that can occur during tool execution, such as not-found, invalid-args, timeout, etc. ```wit variant error-kind { not-found, invalid-args, timeout, capability-denied, internal, other(string), } ``` -------------------------------- ### Localized String Type Definition Source: https://actcore.dev/docs/reference/wit-api Defines a localized string type that can be either plain text or a list of strings with BCP 47 language tags for multi-language support. ```wit variant localized-string { plain(string), localized(list>), } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.