Skip to main content

toml_to_xml

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

Parameters​

ParameterTypeRequiredDescription
inputstringYesTOML 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\"\nport = 8080\n\n[db]\nhost = \"localhost\"\n",
"root_element": "config"
}

Result:

{
"output": "<config>\n <db>\n <host>localhost</host>\n </db>\n <name>Alice</name>\n <port>8080</port>\n</config>"
}

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_tomlThe input string is not valid TOML.tool error (isError)
internal_errorAn unexpected server error.protocol error (internal_error)

Mapping Convention​

TOMLXML
Table key foo<foo> child element
Key @idAttribute id="..." on the parent element (key must use TOML quoted-key syntax: "@id" = "value", since bare TOML keys cannot start with @)
Key $textText content of the parent element
Array of tables / array valuesRepeated sibling elements
String, integer, float, booleanElement text content

Notes​

  • TOML datetime values are serialized as strings in the XML output.
  • Round-trips between toml_to_xml and xml_to_toml are not guaranteed to be lossless.
  • XML special characters in values are automatically escaped.