# `Cadmpeg.Mcp.Tools`
[🔗](https://github.com/d-led/ex.cadmpeg/blob/main/lib/cadmpeg/mcp/tools.ex#L1)

The tools the MCP server offers, and the one place a name becomes a function.

A tool answers `{:ok, %{text: text, structured: map}, state}` or
`{:error, message, state}`. The text is what a model reads; the structured part
is the same answer for a program that would rather not parse prose. The
protocol layer turns the second form into `isError`, which is how the
specification says "this call failed, the message says how" rather than "the
server is broken".

Two tools read and one writes: `cadmpeg_convert` puts a file where the caller
named it and nothing else.

## Where the files come from

A call names a path, and the server keeps the document it opened, so asking
three questions about one file reads it once — and a tool never takes a
*handle* from a caller, because a handle is not something a model should have
to hold.

# `call`

```elixir
@spec call(String.t(), map(), Cadmpeg.Mcp.state()) ::
  {atom(), term(), Cadmpeg.Mcp.state()}
```

One tool call: its answer and the state after it.

# `catalogue`

```elixir
@spec catalogue() :: [map()]
```

The tools, as the protocol wants them listed.

---

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