Skip to main content

yaml_to_xml

Convert a YAML string to XML, wrapped in a configurable root element.

Parameters​

ParameterTypeRequiredDescription
inputstringYesYAML string to convert.
root_elementstringNoName of the XML root element to wrap the output in (default: root).

Response​

FieldTypeDescription
outputstringThe converted XML string.

Example​

{
"input": "name: Alice\nage: 30\n",
"root_element": "person"
}

Result:

{
"output": "<person>\n <name>Alice</name>\n <age>30</age>\n</person>"
}

Errors​

Each failure carries a precise code in the response. Argument-schema and server errors are JSON-RPC protocol errors; a rejected value is returned as a tool result with isError: true (so the agent can read the code and self-correct).

CodeWhenDelivered as
invalid_argumentsinput is missing or not a string, or root_element is not a string.protocol error (invalid_params)
invalid_yamlThe input string is not valid YAML.tool error (isError)
internal_errorAn unexpected server error.protocol error (internal_error)

Mapping Convention​

YAMLXML
Mapping key foo<foo> child element
Mapping key @idAttribute id="..." on the parent element
Mapping key $textText content of the parent element
Sequence [a, b]Repeated sibling elements
null / ~Self-closing element <foo/>
String, integer, float, booleanElement text content

Notes​

  • Round-trips between yaml_to_xml and xml_to_yaml are not guaranteed to be lossless. In particular, numbers are serialized as text and parsed back as strings.
  • XML special characters in values are automatically escaped.