# `LlmToolkit.Tool`
[🔗](https://github.com/fosferon/llm_toolkit/blob/v0.1.0/{path}#L{line})

Provider-neutral tool definition.

A tool is a pure data structure: name, description, and a JSON Schema
describing the parameters the tool accepts. The callback (how to actually
execute the tool) is **not** part of this struct — it is resolved at
runtime by the host application via a `LlmToolkit.ToolResolver`.

This separation ensures tool definitions are serializable (YAML config,
MCP exposure, storage) while callbacks remain a runtime concern.

## Fields

  * `name` - Unique tool identifier (required)
  * `description` - Human-readable description for the LLM (required)
  * `parameters` - JSON Schema map describing accepted arguments (required)
  * `metadata` - Optional map for tags, version, source, etc.

## Examples

    iex> LlmToolkit.Tool.new(%{
    ...>   name: "search",
    ...>   description: "Search the knowledge base",
    ...>   parameters: %{
    ...>     "type" => "object",
    ...>     "properties" => %{"query" => %{"type" => "string"}}
    ...>   }
    ...> })
    {:ok,
     %LlmToolkit.Tool{
       name: "search",
       description: "Search the knowledge base",
       parameters: %{
         "type" => "object",
         "properties" => %{"query" => %{"type" => "string"}}
       },
       metadata: %{}
     }}

# `t`

```elixir
@type t() :: %LlmToolkit.Tool{
  description: String.t(),
  metadata: map(),
  name: String.t(),
  parameters: map()
}
```

# `from_map`

```elixir
@spec from_map(map()) :: {:ok, t()} | {:error, term()}
```

Creates a Tool from a plain map, typically loaded from YAML.

Accepts string keys and converts them.

# `new`

```elixir
@spec new(map()) :: {:ok, t()} | {:error, term()}
```

Creates a new Tool from a map of attributes.

Returns `{:ok, tool}` on success or `{:error, reason}` when required
fields are missing or invalid.

---

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