Skip to main content

Mech Server

PyPI PyPI - Python Version PyPI - Wheel License Downloads

Sanity checks and tests Coverage flake8 mypy Black bandit

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.

Quick Start

pip install mech-server
mech setup -c <chain>
mech run -c <chain>

Supported Chains

Chain Native OLAS Token USDC Token Nevermined
Gnosis ✅ ✅ ❌ ✅
Base ✅ ✅ ✅ ✅
Polygon ✅ ✅ ✅ ✅
Optimism ✅ ✅ ✅ ✅

Requirements

Commands

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

Developing a new tool

New service (no existing mech)

  1. Set up the workspace and deploy the mech on-chain:

    mech setup -c <chain>
    
  2. Scaffold a tool:

    mech add-tool <author> <tool_name> -d "Tool description"
    
  3. 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
    
  4. If your tool requires API keys or other secrets, add them to ~/.operate-mech/.env.

  5. (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_URL in ~/.operate-mech/.env.<chain> and run prepare-metadata without the flag.

  6. Generate and publish metadata (to IPFS), then update the on-chain registry:

    mech prepare-metadata -c <chain>
    mech update-metadata -c <chain>
    
  7. Run:

    mech run -c <chain>
    

Existing service (mech already running)

  1. Stop the service:

    mech stop -c <chain>
    
  2. Scaffold, implement, and set any required API keys (same as steps 2–4 above).

  3. Generate and publish metadata (to IPFS), then update:

    mech prepare-metadata -c <chain>
    mech update-metadata -c <chain>
    
  4. Restart:

    mech run -c <chain>
    

Documentation

Find the full tutorial (tool development, publishing, sending requests) at stack.olas.network.

Metadata

Release files for mech-server 0.8.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mech-server 0.8.5
File Size Uploaded
mech_server-0.8.5.tar.gz 956.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mech-server 0.8.5
File Interpreter ABI Platform
mech_server-0.8.5-py3-none-any.whl Python 3 none any Details

Total release size: 2.3 MB

Release files / mech_server-0.8.5.tar.gz

Download URL mech_server-0.8.5.tar.gz
Size 956.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3286bc65772b5b6e34119d48b1997fd7301fe98d6a31817123b3f329ac7e1eb0
BLAKE2b-256 checksum
How to use checksums
170d208bc3c729c4315092bcbd15ddc3482c886d435f576fc11d79b15fe774e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / mech_server-0.8.5-py3-none-any.whl

Download URL mech_server-0.8.5-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
07017882a85d55dcfd8dd906a16bfa92183daf062cab6b626a37dd5784f51ef9
BLAKE2b-256 checksum
How to use checksums
10e6b4308b52d6edb73c8f8a3467c755d204a462a4258e0f099c984efc2e6068
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.8.5 This release

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page