# `Alternera.Plugin.Provisional.Tools`
[🔗](https://github.com/10e-ab/alternera-sdk/blob/v0.9.0/alternera_plugin_sdk/lib/alternera/plugin/provisional/tools.ex#L1)

Provisional: added for the Camel step's written routes, and a change to it
needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The
namespace has nothing to do with the context's `:provisional?` key.

Tools a plugin adds to the proxy's MCP server, for agents writing its steps:
checking what a step holds against the plugin's outside world, or reading
what that world offers. The proxy reads `c:tools/0` when it compiles, from
every plugin the build knows (shipped, experimental and configured), and
offers a plugin's tools only while the plugin is installed. A tool runs in
the calling tenant, through `c:run_tool/3`.

A tool's name starts with the plugin's id and an underscore
(`camel_check_route`), in lower case letters, digits and underscores; the
proxy refuses to compile a tool named otherwise or named twice.

`access` says what a tool reads or does, which decides who may call it and
whether the in-app assistant may:

  * `:config` reads configuration and nothing a request carried: offered to
    every role and to the assistant.
  * `:data` reads or returns what traffic carried, or a live answer from
    outside: every role, and the assistant only where the tenant lets it
    read data.
  * `:editing` writes nothing but acts as an editor of pipelines does, on
    text the caller chooses (a check that resolves the tenant's secrets
    into it and hands it to an outside process): a tenant admin, and the
    assistant without asking.
  * `:card` changes something: a tenant admin, and the assistant asks the
    user first.

# `access`

```elixir
@type access() :: :config | :data | :editing | :card
```

# `argument`

```elixir
@type argument() :: %{
  :name =&gt; String.t(),
  :type =&gt; :string | :integer | :boolean | :map | {:array, :string | :map},
  :description =&gt; String.t(),
  optional(:required?) =&gt; boolean()
}
```

An argument: its type (`:string`, `:integer`, `:boolean`, `:map`, or a list
of strings or maps), what it is for, and whether a call must give it.

# `tool`

```elixir
@type tool() :: %{
  name: String.t(),
  description: String.t(),
  arguments: [argument()],
  access: access()
}
```

# `run_tool`

```elixir
@callback run_tool(
  name :: String.t(),
  arguments :: map(),
  context :: %{tenant_id: term()}
) ::
  {:ok, map()} | {:error, String.t()}
```

Runs tool `name` with `arguments` (string keys, only those the call gave)
for `context`'s `:tenant_id`: `{:ok, answer}`, a map the proxy returns as
JSON, or `{:error, message}`, which the caller reads.

# `tools`

```elixir
@callback tools() :: [tool()]
```

The plugin's tools.

---

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