ExMCP.Server.Tools.ResponseNormalizer (ex_mcp v0.9.2)
View SourceNormalizes tool responses to comply with MCP specification.
This module extracts the response normalization logic from the original Server.Tools module into a focused, testable unit.
Summary
Functions
Normalizes various response formats into MCP-compliant structure.
Normalizes error responses.
Functions
Normalizes various response formats into MCP-compliant structure.
Examples
# String response
normalize("Hello")
# => %{content: [%{type: "text", text: "Hello"}]}
# Map with text key
normalize(%{text: "Hello"})
# => %{content: [%{type: "text", text: "Hello"}]}
# Already normalized
normalize(%{content: [%{type: "text", text: "Hello"}]})
# => %{content: [%{type: "text", text: "Hello"}]}
Normalizes error responses.