Behaviour + registry for Caravela MCP tools.
A tool module implements:
name/0— the wire-level tool name, exposed to the MCP client. By convention, prefix withcaravela__so tools show up grouped in host UIs.description/0— short prose explaining what the tool does.input_schema/0— JSON Schema for the tool's arguments.call/1— invoke the tool; returns structured content or an error.
Return shape
call/1 returns either {:ok, content} or {:error, message}.
content is a list of MCP content items. The common case is a
single text item containing JSON:
{:ok, [%{"type" => "text", "text" => Jason.encode!(payload)}]}The server wraps the result into the {content: [...], isError: false} shape MCP clients expect.
Summary
Functions
Look up a tool module by its wire-level name.
The MCP tools/list response shape — one entry per registered
tool with its name, description, and input schema.
Helper: wrap a plain string as a single text-content item.
The list of tool modules the server exposes. Add new tools here; the server picks them up automatically.
Helper: wrap a JSON-serializable term as a single text-content
item. Tools use this to return structured payloads (their JSON
shape shows up to the LLM as the text of the content item).
Callbacks
Functions
Look up a tool module by its wire-level name.
@spec list() :: [map()]
The MCP tools/list response shape — one entry per registered
tool with its name, description, and input schema.
Helper: wrap a plain string as a single text-content item.
@spec registry() :: [module()]
The list of tool modules the server exposes. Add new tools here; the server picks them up automatically.
Helper: wrap a JSON-serializable term as a single text-content
item. Tools use this to return structured payloads (their JSON
shape shows up to the LLM as the text of the content item).