ConduitMcp.Client.ToolSet (ConduitMCP v0.11.0)

Copy Markdown View Source

The tools offered to an LLM, keyed by the name the model sees.

Built by ConduitMcp.Client.Naming.build/2. Every exposed name matches ^[A-Za-z0-9_-]{1,64}$ (valid for Anthropic, OpenAI and Gemini) and maps to exactly one ConduitMcp.Client.Tool.

Reverse lookup is a table lookup (resolve/2 is a Map.fetch/2): an exposed name is never split back into a server id and a tool name, so a tool name containing __ cannot be used to reach another server's tool.

entries keeps the build order (servers in the given order, then each server's tools in listed order), which keeps the provider tool list stable between turns and so helps prompt caching.

Summary

Functions

The {exposed_name, tool} pairs, in build order.

The exposed name of server_id's tool tool_name, if it is in the set.

The exposed names, in build order.

Builds a toolset from ordered {exposed_name, tool} pairs.

Looks up the tool behind a model-issued name.

The number of tools in the set.

Types

exposed_name()

@type exposed_name() :: String.t()

t()

@type t() :: %ConduitMcp.Client.ToolSet{
  by_name: %{required(exposed_name()) => ConduitMcp.Client.Tool.t()},
  by_tool: %{required({String.t(), String.t()}) => exposed_name()},
  entries: [{exposed_name(), ConduitMcp.Client.Tool.t()}]
}

Functions

entries(tool_set)

@spec entries(t()) :: [{exposed_name(), ConduitMcp.Client.Tool.t()}]

The {exposed_name, tool} pairs, in build order.

exposed_name(tool_set, server_id, tool_name)

@spec exposed_name(t(), String.t(), String.t()) :: {:ok, exposed_name()} | :error

The exposed name of server_id's tool tool_name, if it is in the set.

names(tool_set)

@spec names(t()) :: [exposed_name()]

The exposed names, in build order.

new(entries)

@spec new([{exposed_name(), ConduitMcp.Client.Tool.t()}]) :: t()

Builds a toolset from ordered {exposed_name, tool} pairs.

Exposed names must be unique; ConduitMcp.Client.Naming.build/2 guarantees that, so call this directly only with names you have already deduplicated. Raises ArgumentError on a duplicate exposed name.

resolve(tool_set, exposed_name)

@spec resolve(t(), term()) :: {:ok, ConduitMcp.Client.Tool.t()} | :error

Looks up the tool behind a model-issued name.

:error means the name is unknown: the caller answers the model with an error result and sends nothing to any server.

size(tool_set)

@spec size(t()) :: non_neg_integer()

The number of tools in the set.