json-to-toml
Convert JSON data to TOML format for simplified configuration and compatibility. Ideal for developers managing structured data in diverse systems using the IT Tools MCP Server.
Instructions
Convert JSON to TOML format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| json | Yes | JSON string to convert |
Implementation Reference
- Handler function that takes JSON string, parses it, converts to TOML using @iarna/toml library, and returns the TOML content or error message.}, async ({ json }) => { try { const toml = await import("@iarna/toml"); const data = JSON.parse(json); const tomlResult = toml.stringify(data); return { content: [ { type: "text", text: `TOML result:\n${tomlResult}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error converting JSON to TOML: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } }
- Input schema defining 'json' as a required string parameter.inputSchema: { json: z.string().describe("JSON string to convert"), },
- src/tools/data_format/convert_json_to_toml/index.ts:4-41 (registration)Registration function for the 'convert_json_to_toml' tool (matches json-to-toml functionality), registers with MCP server including description, schema, annotations, and handler.export function registerConvertJsonToml(server: McpServer) { server.registerTool("convert_json_to_toml", { description: "Convert JSON to TOML format", inputSchema: { json: z.string().describe("JSON string to convert"), }, // VS Code compliance annotations annotations: { title: "Convert Json To Toml", description: "Convert JSON to TOML format", readOnlyHint: false } }, async ({ json }) => { try { const toml = await import("@iarna/toml"); const data = JSON.parse(json); const tomlResult = toml.stringify(data); return { content: [ { type: "text", text: `TOML result:\n${tomlResult}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error converting JSON to TOML: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } } ); }