Skip to main content

Prerequisites

Before installing MoFA, ensure you have the following:

Rust toolchain

Rust 1.85 or newer (edition 2024)

Git

For cloning the repository

LLM API key

OpenAI, Anthropic, or other provider

Build tools

C compiler and linker (platform-specific)

Install Rust

MoFA requires Rust 1.85 or newer. If you don’t have Rust installed:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup default stable
Add Cargo to your PATH (usually automatic):
source $HOME/.cargo/env

Verify installation

rustc --version   # Should show 1.85.0 or newer
cargo --version
If the version is below 1.85, update Rust:
rustup update stable

Get MoFA source

MoFA is currently distributed via source code:
git clone https://github.com/mofa-org/mofa.git
cd mofa
Note: A crates.io package (mofa-sdk) is available, but we recommend using the latest source during active development.

Build MoFA

1

Build the workspace

Build all crates in release mode for optimal performance:
cargo build --release
This compiles:
  • mofa-kernel - Microkernel core
  • mofa-foundation - Business logic layer
  • mofa-runtime - Agent lifecycle management
  • mofa-plugins - Plugin system
  • mofa-sdk - Main SDK
  • mofa-cli - Command-line tools
First build may take 5-10 minutes as Cargo downloads and compiles dependencies.
2

Run tests

Verify everything works:
cargo test -p mofa-sdk
cargo test -p mofa-kernel
All tests should pass. If you see failures, check your Rust version and system configuration.
3

Build specific features

MoFA has optional features you can enable:
# Build with PostgreSQL persistence
cargo build --features persistence-postgres

# Build with Dora-rs distributed runtime
cargo build --features dora

# Build with monitoring dashboard
cargo build --features monitoring

# Build with all features
cargo build --all-features

Platform-specific setup

Install build dependencies:
sudo apt update
sudo apt install build-essential pkg-config libssl-dev

Optional: PostgreSQL

If using persistence features:
# Ubuntu/Debian
sudo apt install postgresql postgresql-contrib libpq-dev

# Fedora/RHEL
sudo dnf install postgresql postgresql-server postgresql-devel

Configure LLM provider

MoFA supports multiple LLM providers. Choose one and set up credentials:
Get an API key from OpenAICreate .env in your project root:
OPENAI_API_KEY=sk-...
OPENAI_MODEL=gpt-4o           # Optional, default: gpt-4o
Or set environment variables:
export OPENAI_API_KEY=sk-...
export OPENAI_MODEL=gpt-4o

Optional: Database setup

If you’re using persistence features, set up a database:
Install PostgreSQL (see platform-specific instructions above)Create a database:
psql -U postgres
CREATE DATABASE mofa_dev;
CREATE USER mofa WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE mofa_dev TO mofa;
\q
Configure .env:
DATABASE_URL=postgres://mofa:your_password@localhost/mofa_dev
Build with PostgreSQL feature:
cargo build --features persistence-postgres

IDE setup

Install recommended extensions:
  1. rust-analyzer - Rust language server
  2. CodeLLDB - Debugger
  3. crates - Dependency management
Open the workspace:
code mofa
rust-analyzer will automatically detect Cargo.toml and provide IntelliSense.

Verify installation

Run a simple example to confirm everything works:
cd examples
cargo run -p chat_stream
You should see:
========================================
  MoFA LLM Agent
========================================

Agent loaded: LLM Agent
If you see this output, your installation is complete!

Troubleshooting

Make sure you’re in the mofa directory:
cd mofa
cargo build
Install C compiler and build tools (see platform-specific setup above).Linux: sudo apt install build-essentialmacOS: xcode-select --installWindows: Install Visual Studio Build Tools
Install OpenSSL development libraries:
# Ubuntu/Debian
sudo apt install libssl-dev

# Fedora/RHEL
sudo dnf install openssl-devel

# macOS
brew install openssl
Set your API key:
export OPENAI_API_KEY=sk-...
Or create a .env file:
echo "OPENAI_API_KEY=sk-..." > .env
Update Rust to 1.85 or newer:
rustup update stable
rustup default stable
rustc --version  # Should show 1.85+

Feature flags reference

MoFA uses Cargo features for optional functionality:
FeatureDescription
defaultCore functionality only
doraEnable Dora-rs distributed runtime
persistence-postgresPostgreSQL database backend
persistence-mysqlMySQL database backend
persistence-sqliteSQLite database backend
monitoringBuilt-in monitoring dashboard
uniffiMulti-language bindings (Python, Java, Swift, Kotlin, Go)
openaiOpenAI provider (enabled by default)
kokoroKokoro TTS engine
Enable features when building:
cargo build --features "dora,persistence-postgres,monitoring"
Or in your Cargo.toml:
[dependencies]
mofa-sdk = { version = "0.1", features = ["dora", "persistence-postgres"] }

Next steps

Quick start

Build your first agent in under 10 minutes

Architecture

Learn about MoFA’s microkernel design

Examples

Explore 27+ working examples

API docs

Browse the Rust API reference
Tip: Join our Discord community if you need help with installation or configuration.

Build docs developers (and LLMs) love