json_to_toml
Convert a JSON string to TOML format.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | JSON string to convert. The top-level value must be an object; null values and mixed-type arrays are not allowed. |
Response
| Field | Type | Description |
|---|---|---|
output | string | The 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).
| Code | When | Delivered as |
|---|---|---|
invalid_arguments | input is missing or not a string. | protocol error (invalid_params) |
invalid_json | The input string is not valid JSON. | tool error (isError) |
conversion_failed | The 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_error | An unexpected server error. | protocol error (internal_error) |
Notes
- TOML does not support
nullvalues. Anynullin 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.