ExMCP.DSL.Tool (ex_mcp v0.10.0)
View SourceSimplified DSL for defining MCP tools.
Provides the deftool macro for defining tools with metadata and JSON Schema.
Summary
Functions
Validates a tool definition at compile time.
Converts atom keys to string keys recursively in a data structure.
Defines a tool with its schema and metadata.
Sets task execution support for the current tool (new in 2025-11-25).
Sets icons for the current tool (new in 2025-11-25).
Sets a raw JSON Schema for the tool input.
Sets annotations for the current tool.
Functions
Validates a tool definition at compile time.
This function is called during the deftool macro expansion to ensure the tool definition is complete and valid.
Converts atom keys to string keys recursively in a data structure.
This ensures that JSON schemas use string keys as required by the MCP specification.
Defines a tool with its schema and metadata.
Examples
deftool "say_hello" do
meta do
name "Hello Tool"
description "Says hello to a given name"
version "1.0.0"
end
input_schema %{
type: "object",
properties: %{name: %{type: "string"}},
required: ["name"]
}
end
Sets task execution support for the current tool (new in 2025-11-25).
Examples
execution %{taskSupport: :optional}
Sets icons for the current tool (new in 2025-11-25).
Examples
icons [%{type: "icon", uri: "https://example.com/icon.svg", mediaType: "image/svg+xml"}]
Sets a raw JSON Schema for the tool input.
Sets annotations for the current tool.