✨ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more
Andrii Bidochko
  • Updated: March 22, 2026
  • 7 min read

Tool Use in OpenClaw: A Hands‑On Guide to Extending the Full‑Stack Template

Tool use in OpenClaw lets developers plug custom utilities into an AI‑agent, turning a generic full‑stack template into a purpose‑built assistant that can query databases, call external APIs, or manipulate files on the fly.

1. Introduction

Since the rise of AI agents like ChatGPT and Claude, the developer community has been hunting for frameworks that make agent extension painless. UBOS homepage introduced OpenClaw, a full‑stack template that ships with a ready‑made agent core, a workflow automation studio, and a web app editor. This guide walks you through the tool‑use mechanism that powers OpenClaw, and shows step‑by‑step how to add a brand‑new tool to an OpenClaw agent.

By the end of this article you will be able to:

  • Define a tool class that follows OpenClaw’s contract.
  • Register the tool with the agent’s registry.
  • Update the agent configuration to expose the tool.
  • Run automated tests that prove the tool works inside the agent loop.

All examples are written in Python 3.11 and assume you have a fresh OpenClaw project generated from the UBOS templates for quick start.

2. What is Tool Use in OpenClaw?

In OpenClaw, a tool is a first‑class object that the agent can invoke during a reasoning step. The agent’s LLM (e.g., OpenAI ChatGPT) produces a JSON‑encoded action payload that references a registered tool name and supplies arguments. OpenClaw’s runtime then:

  1. Deserializes the payload.
  2. Looks up the tool in the ToolRegistry.
  3. Executes the tool’s run() method.
  4. Feeds the tool’s output back to the LLM as part of the next prompt.

This loop enables the agent to “extend its brain” with capabilities that are not baked into the language model itself—exactly the pattern that powers AI marketing agents and other domain‑specific assistants.

3. Core Mechanism Overview

Key Components

  • ToolBase: Abstract base class that enforces name, description, and run() signature.
  • ToolRegistry: Singleton that stores {tool_name: ToolBase} mappings.
  • AgentLoop: Orchestrates LLM calls, parses tool actions, and injects tool results.
  • Config.yaml: Declares which tools are active for a given deployment.

The diagram below (conceptual) shows the data flow:

LLM Prompt → LLM Output (JSON Action) → ToolRegistry.lookup → Tool.run() → Result → LLM Prompt (next turn)

Because the tool contract is language‑agnostic, you can swap a WebScraperTool for a Chroma DB integration without touching the agent core. This modularity is the secret sauce behind OpenClaw’s Enterprise AI platform by UBOS.

4. Step‑by‑Step: Adding a New Tool

a. Define the tool class

Start by creating a Python file under tools/. Below is a simple WeatherFetcher tool that calls the OpenWeatherMap API.

# tools/weather_fetcher.py
import requests
from ubos.core.tool_base import ToolBase

class WeatherFetcher(ToolBase):
    name = "weather_fetcher"
    description = "Fetches current weather for a given city using OpenWeatherMap."

    def __init__(self, api_key: str):
        self.api_key = api_key

    def run(self, city: str) -> str:
        url = f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={self.api_key}"
        resp = requests.get(url, timeout=5)
        if resp.status_code != 200:
            return f"Error: Unable to retrieve weather for {city}."
        data = resp.json()
        temp_c = data["main"]["temp"] - 273.15
        description = data["weather"][0]["description"]
        return f"The weather in {city} is {description} with a temperature of {temp_c:.1f}°C."

Notice the three required attributes: name, description, and the run() method that returns a string. This pattern mirrors the OpenAI ChatGPT integration used throughout UBOS.

b. Register the tool with the agent

OpenClaw ships a tool_registry.py that you can extend. Add the following registration code to app/__init__.py or a dedicated init module.

# app/__init__.py
from ubos.core.tool_registry import ToolRegistry
from tools.weather_fetcher import WeatherFetcher

def init_tools():
    # Retrieve the API key from environment variables or config
    api_key = os.getenv("OPENWEATHER_API_KEY", "YOUR_DEFAULT_KEY")
    weather_tool = WeatherFetcher(api_key=api_key)
    ToolRegistry.register(weather_tool)

init_tools()

Registration makes the tool discoverable by the AgentLoop. If you’re using the Workflow automation studio, the tool will automatically appear in the “Available Actions” palette.

c. Update the agent configuration

The config.yaml file controls which tools are exposed to the LLM. Add an entry under the tools section:

# config.yaml
agent:
  name: "OpenClaw Weather Assistant"
  llm: "gpt-4o-mini"
  tools:
    - weather_fetcher   # <-- newly added tool
    - search_web       # existing tool
    - summarize_text   # existing tool

After updating the config, restart the OpenClaw server so the new tool is loaded into the runtime.

d. Test the new tool

OpenClaw includes a pytest‑compatible test harness. Create tests/test_weather_tool.py:

# tests/test_weather_tool.py
import os
from ubos.core.agent_loop import AgentLoop
from ubos.core.tool_registry import ToolRegistry

def test_weather_fetcher():
    # Mock environment
    os.environ["OPENWEATHER_API_KEY"] = "test_key"
    # Initialize tools (includes WeatherFetcher)
    from app import init_tools
    init_tools()

    # Simulate an LLM request that calls the tool
    prompt = "What is the weather in Berlin?"
    response = AgentLoop.run(prompt)

    assert "Berlin" in response
    assert "°C" in response

Run pytest -q. If the test passes, your tool is fully integrated and ready for production use.

5. Connecting Tool Use to AI‑Agent Hype

The current wave of AI‑agent hype is driven by the promise of “agents that can act”. Companies are racing to embed tools that let agents:

  • Pull real‑time data (e.g., stock prices, weather, CRM records).
  • Perform secure actions (e.g., send emails, update tickets).
  • Generate multimodal content (e.g., ElevenLabs AI voice integration for spoken replies).

OpenClaw’s tool‑use architecture aligns perfectly with this trend because it decouples the LLM from the execution environment. This separation enables:

  1. Compliance: Tools run in sandboxed containers, satisfying data‑privacy regulations.
  2. Scalability: Each tool can be deployed as a micro‑service behind a load balancer.
  3. Extensibility: New tools (like the Chroma DB integration) can be added without retraining the LLM.

For a real‑world case study, see how AI marketing agents use a combination of ChatGPT and Telegram integration and the Telegram integration on UBOS to automate campaign reporting, lead qualification, and instant messaging with prospects.

Industry analysts predict that by 2027, over 60% of enterprise AI deployments will rely on tool‑enabled agents. OpenClaw gives you a head start by providing a battle‑tested framework that already supports popular integrations such as OpenAI ChatGPT integration and ChatGPT and Telegram integration.

6. Conclusion

Tool use is the linchpin that transforms a generic LLM into a domain‑specific AI assistant. By following the four steps—defining a tool class, registering it, updating the config, and testing—you can extend OpenClaw’s full‑stack template in minutes.

Whether you’re building a UBOS for startups prototype, an UBOS solution for SMBs, or an enterprise‑grade deployment, the same pattern applies.

Stay ahead of the AI‑agent hype by continuously enriching your agent’s toolbox. The more specialized tools you expose, the more valuable and trustworthy your assistant becomes.

7. Call to Action

Ready to accelerate your AI‑agent development?

Got questions or want a custom walkthrough? Drop a comment below or reach out via our About UBOS page.

For deeper insight into the evolution of tool‑enabled agents, read the OpenAI blog post on ChatGPT plugins, which outlines the same principles that OpenClaw implements under the hood.


Andrii Bidochko

CTO UBOS

Andrii Bidochko is an AI entrepreneur and researcher focused on AI agents, reinforcement learning, and autonomous systems. He writes about the technologies shaping the future of machine intelligence, from frontier models and agent architectures to real-world AI applications.

Sign up for our newsletter

Stay up to date with the roadmap progress, announcements and exclusive discounts feel free to sign up with your email.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.