LocalizeMcp. Tools. Invoke
(Localize MCP v0.1.0)
View Source
Implementation of the localize_invoke tool.
Executes one allowlisted MFA from priv/mcp/invocable.exs and
returns its result encoded through LocalizeMcp.TermGrammar.
Three safety layers:
Allowlist. The MFA must appear in
priv/mcp/invocable.exs; everything else returns:not_invokable.Task isolation. The call runs in a
Task.async/1so the caller's process dictionary (current locale, etc.) stays clean and exceptions / exits are captured locally.Resource caps. 5 second wall-clock timeout. The
:max_heap_sizeflag is applied to the task process so a runaway call cannot grow the BEAM unboundedly.
Exceptions and timeouts return as structured {:error, ...}
maps; the tool never raises.