# `Excessibility.MCP.Tool`
[🔗](https://github.com/lessthanseventy/excessibility/blob/v0.18.1/lib/excessibility/mcp/tool.ex#L1)

Behaviour for MCP tools.

Tools are executable actions that can be called via the MCP protocol.

## Example

    defmodule MyApp.MCP.Tools.MyTool do
      @behaviour Excessibility.MCP.Tool

      @impl true
      def name, do: "my_tool"

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

      @impl true
      def input_schema do
        %{
          "type" => "object",
          "properties" => %{
            "arg1" => %{"type" => "string", "description" => "First argument"}
          },
          "required" => ["arg1"]
        }
      end

      @impl true
      def execute(args, _opts) do
        {:ok, %{"result" => args["arg1"]}}
      end
    end

## Callbacks

- `name/0` - Returns string identifier for this tool
- `description/0` - Human-readable description of what the tool does
- `input_schema/0` - JSON Schema for the tool's input arguments
- `execute/2` - Takes args map and opts keyword list, returns result

## Options

The `opts` keyword list may contain:
- `:progress_callback` - Function to call with progress updates
- `:elicit` - A 2-arity function `fn message, schema -> result` for structured
  user interaction via the MCP elicitation protocol. Only present when the client
  supports elicitation. See `Excessibility.MCP.Elicitation` for details.

# `description`

```elixir
@callback description() :: String.t()
```

# `execute`

```elixir
@callback execute(args :: map(), opts :: keyword()) :: {:ok, map()} | {:error, String.t()}
```

# `input_schema`

```elixir
@callback input_schema() :: map()
```

# `name`

```elixir
@callback name() :: String.t()
```

# `format_result`

Formats a successful tool result for MCP response.

# `to_mcp_definition`

Returns the MCP tool definition for a tool module.

---

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