Sanitizes and serializes Ectomancer tool results into JSON-safe output.
Ecto structs are converted to plain maps, Ecto internals (__meta__,
#Ecto.Association.NotLoaded<>) are removed or replaced with null, and
datetime/decimal values are rendered as ISO-8601 strings so that MCP clients
receive valid, parseable JSON.
Field filtering is applied recursively so only:/except: redaction also
reaches nested records (e.g. batch results and preloaded associations).
Summary
Functions
Encodes a value as a JSON string, sanitizing Ecto structs along the way.
Recursively filters the fields of Ecto structs to the given allowlist.
Functions
Encodes a value as a JSON string, sanitizing Ecto structs along the way.
- Structs are converted to maps (keys as strings), dropping
__meta__. Ecto.Association.NotLoadedbecomesnull.Date/Time/NaiveDateTime/DateTimebecome ISO-8601 strings.Decimalbecomes a string.- Plain binaries are returned verbatim (not quoted).
Recursively filters the fields of Ecto structs to the given allowlist.
Works on single structs, lists, plain maps, paginated results, and batch result maps. Non-struct values (strings, numbers, datetimes) pass through unchanged.