Adapts an already supervised Noizu.MCP.Client to GenAI.Tool.Source.
This module deliberately calls Noizu.MCP.Client at runtime. GenAI therefore
keeps its Elixir 1.16 floor and consumers that do not use MCP do not need to
install :noizu_mcp.
Register clients with an explicit source id so model-facing tool names remain stable across restarts:
registry = GenAI.Tool.Registry.new(telemetry: &MyApp.tool_event/3)
{:ok, registry} =
GenAI.Tool.Source.MCP.register(
registry,
:workspace,
MyApp.MCP.Workspace,
context,
telemetry_metadata: %{trace_id: trace_id}
)
# Tools are exposed as workspace__read_file, workspace__search, ...
GenAI.run_with_tools(thread, registry, context)The client process remains owned by the consumer's supervision tree. MCP
_meta values are excluded by default because servers may put opaque or
sensitive values there. Set include_mcp_meta: true only for trusted servers.
GenAI registry telemetry excludes arguments and results by default. Enable
include_payloads: true only when the payloads are safe to record.
Summary
Functions
Snapshots the tools exposed by a supervised MCP client into a registry.
Functions
@spec register( GenAI.Tool.Registry.t(), String.t() | atom(), GenServer.server(), term(), keyword() ) :: {:ok, GenAI.Tool.Registry.t()} | {:error, term()}
Snapshots the tools exposed by a supervised MCP client into a registry.
source_id is required rather than inferred from a pid. This produces a
deterministic namespace (source_id__tool_name) even when process identities
change between VM starts.