Skip to main content

No project description provided

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mech_server-0.8.3.tar.gz (846.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mech_server-0.8.3-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file mech_server-0.8.3.tar.gz.

File metadata

  • Download URL: mech_server-0.8.3.tar.gz
  • Upload date:
  • Size: 846.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mech_server-0.8.3.tar.gz
Algorithm Hash digest
SHA256 9f8a40475015dbf4a572e420edcf0207f79ddb6227202cedf14b5365b6ef0413
MD5 efe507cb555cc2c422419a87d3d3bc16
BLAKE2b-256 73c23f0ec3e6d2a3211a1287f9f9a21f7e0cc650004ea43c172ef37da6fa37cb

See more details on using hashes here.

File details

Details for the file mech_server-0.8.3-py3-none-any.whl.

File metadata

  • Download URL: mech_server-0.8.3-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mech_server-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 47b30af42af364889c3d97de2052a7c9a472e90ca927c32953cb98cf8f361d8b
MD5 e0a1b12d483a01f2584d3b557b9b28c4
BLAKE2b-256 29651a5f7c6f5bb91937ab1cde3a4a90534546c867b96e300bc024c9b84ca0fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page