Skip to main content

json_to_toml

Convert a JSON string to TOML format.

Parameters​

ParameterTypeRequiredDescription
inputstringYesJSON string to convert. The top-level value must be an object; null values and mixed-type arrays are not allowed.

Response​

FieldTypeDescription
outputstringThe converted TOML string.

Example​

{
"input": "{\"name\": \"Alice\", \"port\": 8080, \"db\": {\"host\": \"localhost\"}}"
}

Result:

{
"output": "name = \"Alice\"\nport = 8080\n\n[db]\nhost = \"localhost\"\n"
}

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.protocol error (invalid_params)
invalid_jsonThe input string is not valid JSON.tool error (isError)
conversion_failedThe JSON is valid but cannot be represented as TOML (e.g. the top-level value is not an object, or it contains null or mixed-type arrays).tool error (isError)
internal_errorAn unexpected server error.protocol error (internal_error)

Notes​

  • TOML does not support null values. Any null in the input will cause an error.
  • Arrays must be homogeneous (all elements the same type). Mixed-type arrays are not allowed.
  • The top-level JSON value must be an object; arrays and primitives at the top level are rejected.