A CLI to create, deploy and manage Mechs — AI agents that execute tasks on-chain for payment — on the Olas Marketplace.
Note: The codebase uses the term service (from the underlying Open Autonomy framework) interchangeably with AI agent.
pip install mech-server
mech setup -c <chain>
mech run -c <chain>| Chain | Native | OLAS Token | USDC Token | Nevermined |
|---|---|---|---|---|
| Gnosis | ✅ | ✅ | ❌ | ✅ |
| Base | ✅ | ✅ | ❌ | ✅ |
| Polygon | ✅ | ✅ | ✅ | ✅ |
| Optimism | ✅ | ✅ | ❌ | ✅ |
- Python
>=3.10, <3.12 - Docker Engine + Docker Compose
| Command | Description |
|---|---|
mech setup -c <chain> |
Full first-time setup: workspace, agent build, mech deployment, env config, key setup |
mech add-tool <author> <name> |
Scaffold a new mech tool |
mech prepare-metadata -c <chain> |
Recompute package fingerprints, push packages and metadata to IPFS, and write METADATA_HASH and TOOLS_TO_PACKAGE_HASH to .env |
mech prepare-metadata -c <chain> --offchain-url <url> |
Same as above, also sets the offchain URL in metadata and .env |
mech update-metadata -c <chain> |
Update the metadata hash on-chain via Safe transaction |
mech run -c <chain> |
Run the mech AI agent via Docker |
mech stop -c <chain> |
Stop a running mech AI agent |
-
Set up the workspace and deploy the mech on-chain:
mech setup -c <chain>
-
Scaffold a tool:
mech add-tool <author> <tool_name> -d "Tool description"
-
Implement the tool logic in
~/.operate-mech/packages/<author>/customs/<tool_name>/<tool_name>.py. The scaffold generates a working stub with the correct structure:ALLOWED_TOOLS = ["tool_name"] def run(**kwargs: Any) -> MechResponse: prompt = kwargs.get("prompt") if prompt is None: return error_response("No prompt has been given.") result = do_work(prompt) context = None artifact = None callback = None return result, prompt, context, artifact, callback
-
If your tool requires API keys or other secrets, add them to
~/.operate-mech/.env. -
(Optional) If your mech should serve off-chain requests over HTTP, provide a URL that routes to the mech's HTTP server (
localhost:8000). This URL is included in the mech's on-chain metadata so that clients can discover it:mech prepare-metadata -c <chain> --offchain-url <url>
Alternatively, set
MECH_OFFCHAIN_URLin~/.operate-mech/.env.<chain>and runprepare-metadatawithout the flag. -
Generate and publish metadata (to IPFS), then update the on-chain registry:
mech prepare-metadata -c <chain> mech update-metadata -c <chain>
-
Run:
mech run -c <chain>
-
Stop the service:
mech stop -c <chain>
-
Scaffold, implement, and set any required API keys (same as steps 2–4 above).
-
Generate and publish metadata (to IPFS), then update:
mech prepare-metadata -c <chain> mech update-metadata -c <chain>
-
Restart:
mech run -c <chain>
Find the full tutorial (tool development, publishing, sending requests) at stack.olas.network.