Anthropic::MCP
Convert Model Context Protocol payloads into Anthropic content blocks.
This is a dependency-free port of the content converters from the
TypeScript SDK's helpers/beta/mcp module: inputs are raw JSON::Any
values shaped like MCP SDK responses, so no MCP client library is
needed.
content = JSON.parse(%({"type":"text","text":"hello"}))
block = Anthropic::MCP.content(content)
Constants
SUPPORTED_IMAGE_TYPES = ["image/jpeg", "image/png", "image/gif", "image/webp"]
Class methods
Convert one MCP prompt content item to an Anthropic content block.
Handles text, image, and embedded resource items. audio and
resource_link items are rejected, as is any unknown type.
Malformed items raise UnsupportedMCPValueError.
Convert one MCP prompt message to an Anthropic message param.
Convert MCP prompt messages (e.g. from getPrompt) to Anthropic
message params.