toml-to-json
Convert TOML strings to JSON format for simplified data parsing and integration. A tool within the IT Tools MCP Server, designed for developers and system administrators.
Instructions
Convert TOML to JSON format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| toml | Yes | TOML string to convert |
Implementation Reference
- src/tools/data_format/convert_toml_to_json/index.ts:4-40 (registration)Registration of the 'convert_toml_to_json' tool, which is the TOML to JSON converter. Includes inline schema and handler.export function registerConvertTomlJson(server: McpServer) { server.registerTool("convert_toml_to_json", { description: "Convert TOML to JSON format", inputSchema: { toml: z.string().describe("TOML string to convert"), }, // VS Code compliance annotations annotations: { title: "Convert Toml To Json", description: "Convert TOML to JSON format", readOnlyHint: false } }, async ({ toml: tomlString }) => { try { const toml = await import("@iarna/toml"); const result = toml.parse(tomlString); return { content: [ { type: "text", text: `JSON result:\n${JSON.stringify(result, null, 2)}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error converting TOML to JSON: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } } ); }
- The handler function that parses TOML input using @iarna/toml and returns formatted JSON or error.}, async ({ toml: tomlString }) => { try { const toml = await import("@iarna/toml"); const result = toml.parse(tomlString); return { content: [ { type: "text", text: `JSON result:\n${JSON.stringify(result, null, 2)}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error converting TOML to JSON: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } } );
- Zod schema for input: toml string.inputSchema: { toml: z.string().describe("TOML string to convert"), },