Skip to main content
Glama

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
NameRequiredDescriptionDefault
jsonYesJSON 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"), },
  • 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'}`, }, ], }; } } ); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wrenchpilot/it-tools-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server