Normandy.MCP.ToolWrapper (normandy v0.6.2)

View Source

Wraps an MCP tool as a Normandy BaseTool implementation.

This allows MCP tools discovered via any Claudio.MCP.Client adapter to be registered in a Normandy tool registry and used in the agent's tool execution loop.

Example

alias Claudio.MCP.Client.Tool
alias Normandy.MCP.ToolWrapper

mcp_tool = %Tool{
  name: "search",
  description: "Search the web",
  input_schema: %{"type" => "object", "properties" => %{"query" => %{"type" => "string"}}}
}

wrapper = %ToolWrapper{
  adapter: Claudio.MCP.Adapters.ExMCP,
  client: mcp_client_pid,
  tool: mcp_tool,
  prefix: "my_server"
}

# Register in agent
agent = BaseAgent.register_tool(agent, wrapper)

Summary

Functions

Creates a new ToolWrapper for an MCP tool.

Prepares the tool with LLM-provided input parameters.

Types

t()

@type t() :: %Normandy.MCP.ToolWrapper{
  adapter: module(),
  client: term(),
  input: map(),
  prefix: String.t() | nil,
  tool: Claudio.MCP.Client.Tool.t()
}

Functions

new(adapter, client, tool, opts \\ [])

@spec new(module(), term(), Claudio.MCP.Client.Tool.t(), keyword()) :: t()

Creates a new ToolWrapper for an MCP tool.

Parameters

prepare_input(wrapper, input)

@spec prepare_input(t(), map()) :: t()

Prepares the tool with LLM-provided input parameters.

Called by the BaseAgent tool loop instead of struct/2 for tools with dynamic input schemas.