# `A2UICore.Functions.MCP`
[🔗](https://github.com/a2ui-elixir/a2ui/blob/v0.1.1/umbrella/apps/a2ui_core/lib/a2ui_core/functions/mcp.ex#L1)

Implementations of the MCP catalog's functions (see
`A2UICore.Catalog.MCP`).

  * `callMcpTool` calls a tool through the host's
    `A2UICore.MCP.Client` and returns the tool's `CallToolResult`.
    The A2UI messages the result carries — in the UI resources it
    names (`_meta.ui.resourceUri`, else those its tool descriptor
    declares) and embedded in its content — come back as
    `{:messages, %{messages: messages, source: :resource | :inline}}`
    effects for the renderer to apply; messages without a `version`
    get the catalog's (`v0.9` or `v1.0`). With `targetDataPath` (v1.0),
    the MCP App a resource holds is written there as
    `%{"uri", "htmlContent", "csp", "permissions", "toolInput", "toolResult"}`
    (a `{:write, ...}` effect), ready for an `McpApp` component to
    bind.
  * `jmespath` evaluates a JMESPath expression (`A2UICore.JMESPath`).
  * `split`, `regexCapture` and `regexReplace` work on a string, or on
    each string of an array. Patterns are RE2 expressions, run by PCRE
    with RE2's meaning of `$` (end of text) and ASCII `\d`, `\w`, `\b`.
  * `updateDataModel` asks for its updates to be written: one
    `{:write, %{path: path, value: value}}` effect per entry, the path
    resolved against the calling scope.

Effects reach the renderer from an action (see
`A2UICore.Resolution.NodeResolver.invoke/5`); a renderer applies them
in order. Failures are errors with category `:expression`.

# `client`
*since 0.1.0* 

```elixir
@type client() ::
  A2UICore.MCP.Client.t() | (String.t() -&gt; A2UICore.MCP.Client.t() | nil)
```

The MCP client: `{module, state}`, or a function from a tool name to one.

# `implementations`
*since 0.1.0* 

```elixir
@spec implementations(String.t(), keyword()) :: %{
  optional(String.t()) =&gt; A2UICore.Catalog.Function.execute()
}
```

The function implementations of the MCP catalog of `version`.

Options: `:client` — the `t:client/0` `callMcpTool` uses. Without one,
`callMcpTool` fails.

---

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