ExMCP.Validation.ToolName (ex_mcp v0.9.2)
View SourceValidates MCP tool names according to the 2025-11-25 specification.
Tool names must:
- Be 1-128 characters long
- Only contain alphanumeric characters, dots, hyphens, and underscores
- Match the pattern:
^[a-zA-Z0-9_.\-]+$
Summary
Functions
Returns true if the tool name is valid.
Validates a tool name.
Returns {:ok, name} if valid, {:error, reason} if invalid.
Examples
iex> ExMCP.Validation.ToolName.validate("my_tool")
{:ok, "my_tool"}
iex> ExMCP.Validation.ToolName.validate("my tool")
{:error, "Tool name contains invalid characters. Must match [a-zA-Z0-9_.\\-]+"}
iex> ExMCP.Validation.ToolName.validate("")
{:error, "Tool name must be between 1 and 128 characters"}