Ragex.Agent.ToolSchema
(Ragex v0.9.1)
View Source
Converts MCP tool definitions to AI provider tool formats.
Supports:
- OpenAI function calling format (also used by DeepSeek R1)
- Anthropic tool use format
Usage
# Get all tools in OpenAI format
tools = ToolSchema.to_openai_tools()
# Get curated agent tools
tools = ToolSchema.agent_tools(:openai)
# Lookup specific tool
{:ok, tool} = ToolSchema.tool_by_name("semantic_search")
Summary
Functions
Get list of agent tool names.
Get curated subset of tools for agent use.
Get all MCP tools converted to Anthropic tool format.
Get all MCP tools converted to OpenAI function calling format.
Lookup a tool definition by name.
Convert a list of tool names to their definitions.
Get tools for a specific provider by name.
Functions
@spec agent_tool_names() :: [String.t()]
Get list of agent tool names.
Get curated subset of tools for agent use.
Parameters
format- Output format::openai(default, also for DeepSeek) or:anthropic
Returns
List of tool definitions in the requested format.
@spec to_anthropic_tools() :: [map()]
Get all MCP tools converted to Anthropic tool format.
Returns
List of tool definitions in Anthropic format:
[
%{
name: "tool_name",
description: "Tool description",
input_schema: %{...json_schema...}
}
]
@spec to_openai_tools() :: [map()]
Get all MCP tools converted to OpenAI function calling format.
This format is also compatible with DeepSeek R1.
Returns
List of tool definitions in OpenAI format:
[
%{
type: "function",
function: %{
name: "tool_name",
description: "Tool description",
parameters: %{...json_schema...}
}
}
]
Lookup a tool definition by name.
Parameters
name- Tool name as stringformat- Output format::openai,:anthropic, or:mcp(default)
Returns
{:ok, tool}- Tool definition in requested format{:error, :not_found}- Tool not found
Convert a list of tool names to their definitions.
Parameters
names- List of tool namesformat- Output format
Returns
List of tool definitions (skips unknown tools).
Get tools for a specific provider by name.
Parameters
provider- Provider atom::deepseek_r1,:openai,:anthropic,:ollamaopts- Options::only- List of tool names to include (default: all agent tools):except- List of tool names to exclude
Returns
List of tool definitions in the appropriate format for the provider.