Excessibility.MCP.Tool behaviour (Excessibility v0.14.0)
View SourceBehaviour for MCP tools.
Tools are executable actions that can be called via the MCP protocol.
Example
defmodule MyApp.MCP.Tools.MyTool do
@behaviour Excessibility.MCP.Tool
@impl true
def name, do: "my_tool"
@impl true
def description, do: "Does something useful"
@impl true
def input_schema do
%{
"type" => "object",
"properties" => %{
"arg1" => %{"type" => "string", "description" => "First argument"}
},
"required" => ["arg1"]
}
end
@impl true
def execute(args, _opts) do
{:ok, %{"result" => args["arg1"]}}
end
endCallbacks
name/0- Returns string identifier for this tooldescription/0- Human-readable description of what the tool doesinput_schema/0- JSON Schema for the tool's input argumentsexecute/2- Takes args map and opts keyword list, returns result
Options
The opts keyword list may contain:
:progress_callback- Function to call with progress updates:elicit- A 2-arity functionfn message, schema -> resultfor structured user interaction via the MCP elicitation protocol. Only present when the client supports elicitation. SeeExcessibility.MCP.Elicitationfor details.
Summary
Functions
Formats a successful tool result for MCP response.
Returns the MCP tool definition for a tool module.