Tools Documentation

Tools are the core components of the AgentHive platform. Each tool is a containerized microservice that performs a specific function, such as sending emails, classifying text, or interacting with external APIs.

Creating a New Tool

To create your own tool, you’ll define its behavior, inputs, outputs, and environment configuration. Every tool runs inside a Docker container for portability and security.

Requirements

  • A valid hosted Dockerfile in a public repo at Dockerhub
  • Defined input and output schema
  • Required environment variables (if applicable)

Example: Email Sender Tool

Below is an example of a simple Python-based tool that sends an email using SMTP.

# email_sender.py
from fastapi import FastAPI
from pydantic import BaseModel
import smtplib, os

app = FastAPI()

class RunInput(BaseModel):
    email: str
    message: str

@app.post("/run")
async def run_tool(data: RunInput):
    try:
        sender = os.getenv("SMTP_USER", "noreply@example.com")
        password = os.getenv("SMTP_PASS", "")
        host = os.getenv("SMTP_HOST", "smtp.gmail.com")
        port = int(os.getenv("SMTP_PORT", "587"))

        with smtplib.SMTP(host, port) as server:
            server.starttls()
            if password:
                server.login(sender, password)
            server.sendmail(sender, data.email, f"Subject: Message\n\n{data.message}")

        return {"status": "sent", "details": f"Message sent to {data.email}"}
    except Exception as e:
        return {"status": "failed", "error": str(e)"}

Registering Your Tool

Once your container is ready, register it on AgentHive through the platform interface or API. The registration includes metadata like the Docker image, input/output shapes, and required environment variables.

Example Tool Registration Request

{
  "name": "EmailSender",
  "description": "Send an email to whoever you want!",
  "dockerImageUrl": "goldendragon4/emailertool",
  "usagePrice": 0,
  "requiredEnv": ["SMTP_PASS", "SMTP_USER", "SMTP_HOST", "SMTP_PORT"],
  "inputShape": "{'email': 'email@gmail.com', 'message': 'message'}",
  "outputShape": "{'status': 'sent', 'details': 'Message sent to email@gmail.com'}"
}

Ensure that all environment variables used in your code are listed in requiredEnv for secure configuration during execution.

Testing Your Tool

Local Testing

  1. Build the image: docker build -t emailer .
  2. Run locally: docker run -p 8080:80 emailer
  3. Send a test POST request to /run
  4. Check logs and outputs for validation.

Platform Testing

  1. Upload or register the tool on AgentHive.
  2. You'll be redirected to the Testing Interface
  3. Run test executions using sample input data.
  4. View logs and outputs after each run.

Best Practices

  • Keep tools modular and single-purpose.
  • Implement consistent response formats ({ "status": "sent" }).
  • Use environment variables for all secrets and API keys.
  • Include meaningful logs for debugging.
  • Version your tools properly (1.0.0, 1.1.0, etc.).
  • Document your input and output formats clearly.

Sample Tools

Explore these examples for reference implementations:

  • EmailSender : send emails through SMTP
  • TextClassifier : classify text using AI models

Important Note

Always follow security best practices when deploying to production. Never hardcode credentials — use secure environment variables instead.