# `ADK.Tool.ModuleTool`
[🔗](https://github.com/zeroasterisk/adk-elixir/blob/main/lib/adk/tool/module_tool.ex#L1)

A tool backed by a module instead of an anonymous function.

This solves the problem of tools with anonymous functions not being
usable in compile-time Plug config (e.g., `plug MyPlug, tools: [...]`).

## Usage

Define a module implementing `ADK.Tool`:

    defmodule MyTool do
      @behaviour ADK.Tool

      @impl true
      def name, do: "my_tool"

      @impl true
      def description, do: "Does something useful"

      @impl true
      def parameters, do: %{type: "object", properties: %{input: %{type: "string"}}}

      @impl true
      def run(_ctx, args), do: {:ok, "Got: #{args["input"]}"}
    end

Then wrap it:

    tool = ADK.Tool.ModuleTool.new(MyTool)

Or use it directly — any module implementing `ADK.Tool` can be used
as a tool struct via `ADK.Tool.ModuleTool.new/1`.

# `t`

```elixir
@type t() :: %ADK.Tool.ModuleTool{
  description: String.t(),
  module: module(),
  name: String.t(),
  parameters: map()
}
```

# `new`

```elixir
@spec new(
  module(),
  keyword()
) :: t()
```

Create a tool struct from a module implementing `ADK.Tool`.

# `run`

```elixir
@spec run(t(), ADK.ToolContext.t(), map()) :: ADK.Tool.result()
```

Execute the module tool.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
