Ragex.MCP.Formattable protocol (Ragex v0.16.0)

View Source

Protocol for compacting MCP tool responses.

Types that implement this protocol define how to produce a compact representation (signatures, locations, counts only) versus a verbose one (full detail -- the current default behavior).

The formatter calls compact/2 when verbose: false (the new default) and falls through to the raw value when verbose: true.

Implementing for a new struct

defimpl Ragex.MCP.Formattable, for: MyResult do
  def compact(result, opts) do
    %{summary: result.summary, count: result.count}
  end
end

Summary

Types

t()

All the types that implement this protocol.

Functions

Produce a compact representation of the value.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

compact(value, opts)

@spec compact(
  t(),
  keyword()
) :: term()

Produce a compact representation of the value.

Options

  • :max_items -- truncate lists to this many items
  • :tool_name -- the tool that produced this result (for context-aware compaction)