ExMCP.Content.Transformer (ex_mcp v0.9.2)
View SourceContent transformation utilities for MCP content.
This module handles all content transformation operations including format conversion, normalization, and media processing. Extracted from the original Content.Validation module.
Summary
Types
Transformation operation
Functions
Compresses image data.
Converts text encoding to UTF-8.
Converts content from one format to another.
Extracts plain text from various content types.
Generates a thumbnail from image content.
Normalizes whitespace in text content.
Resizes image to fit within specified dimensions.
Transforms content by applying a list of transformation operations.
Transforms content with validation after each operation.
Types
Functions
Compresses image data.
Converts text encoding to UTF-8.
@spec convert_format(ExMCP.Content.Protocol.content(), atom()) :: {:ok, ExMCP.Content.Protocol.content()} | {:error, String.t()}
Converts content from one format to another.
@spec extract_text(ExMCP.Content.Protocol.content()) :: {:ok, String.t()} | {:error, String.t()}
Extracts plain text from various content types.
Generates a thumbnail from image content.
Normalizes whitespace in text content.
Resizes image to fit within specified dimensions.
@spec transform(ExMCP.Content.Protocol.content(), [transformation_op()]) :: {:ok, ExMCP.Content.Protocol.content()} | {:error, String.t()}
Transforms content by applying a list of transformation operations.
Examples
{:ok, transformed} = Transformer.transform(content, [
:normalize_whitespace,
{:resize_images, max_width: 800},
:compress_images
])
@spec transform_with_validation(ExMCP.Content.Protocol.content(), [ transformation_op() ]) :: {:ok, ExMCP.Content.Protocol.content()} | {:error, String.t()}
Transforms content with validation after each operation.