Skip to main content
Glama
brendon92

Specialized AI Search Tools

by brendon92

typeconversion

typeconversion

Convert data between JSON, XML, YAML, CSV, and TOML formats with options for pretty printing, minification, and format-specific settings like CSV delimiters.

Instructions

Convert data between different formats: JSON, XML, YAML, CSV, and TOML. Supports pretty printing, minification, and format-specific options like CSV delimiters and headers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesInput data as string
fromFormatYesSource data format
toFormatYesTarget data format
optionsNo

Implementation Reference

  • Registration function that instantiates the TypeConversionTool and registers it along with other tools to the MCP server using server.registerTools
    export function registerAllTools(server: MCPServer): void {
        const tools: BaseTool[] = [
            new WebSearchTool(),
            new WebFetchTool(),
            new TypeConversionTool(),
        ];
    
        // Register all tools
        if (tools.length > 0) {
            server.registerTools(tools);
            logger.info(`Registered ${tools.length} tool(s): ${tools.map(t => t.name).join(', ')}`);
        } else {
            logger.warn('No tools registered - add tool implementations to src/tools/index.ts');
        }
    }
  • Zod schemas defining supported formats, conversion options, input parameters (TypeConversionParams) for the typeconversion tool
    const formatEnum = z.enum(['json', 'xml', 'yaml', 'csv', 'toml']);
    type DataFormat = z.infer<typeof formatEnum>;
    
    /**
     * Conversion options schema
     */
    const conversionOptionsSchema = z
        .object({
            pretty: z.boolean().optional().default(true).describe('Pretty print output (with indentation)'),
            indent: z.number().int().min(0).max(8).optional().default(2).describe('Indentation spaces for pretty printing'),
            csvDelimiter: z.string().optional().default(',').describe('CSV delimiter character'),
            csvHeaders: z.boolean().optional().default(true).describe('CSV has headers in first row'),
        })
        .optional();
    
    /**
     * Type conversion tool schema
     */
    const typeConversionSchema = z.object({
        input: z.string().min(1).describe('Input data as string'),
        fromFormat: formatEnum.describe('Source data format'),
        toFormat: formatEnum.describe('Target data format'),
        options: conversionOptionsSchema,
    });
    
    type TypeConversionParams = z.infer<typeof typeConversionSchema>;
  • TypeConversionTool class with name, description, schema reference, and execute handler method that orchestrates parsing input to JS object and formatting to target output using private helpers
    export class TypeConversionTool extends BaseTool<typeof typeConversionSchema> {
        readonly name = 'typeconversion';
        readonly description =
            'Convert data between different formats: JSON, XML, YAML, CSV, and TOML. Supports pretty printing, minification, and format-specific options like CSV delimiters and headers.';
        readonly schema = typeConversionSchema;
    
        protected async execute(params: TypeConversionParams): Promise<string> {
            logger.info(`Converting from ${params.fromFormat} to ${params.toFormat}`);
    
            try {
                // Parse input to intermediate format (JavaScript object)
                const data = await this.parseInput(params.input, params.fromFormat, params.options);
    
                // Convert to target format
                const output = await this.formatOutput(data, params.toFormat, params.options);
    
                logger.info(`Conversion completed successfully`);
                return output;
            } catch (error) {
                throw new Error(
                    `Conversion failed: ${error instanceof Error ? error.message : 'Unknown error'}`
                );
            }
        }
  • parseInput helper: dispatches input parsing based on fromFormat to specific parser methods
    private async parseInput(
        input: string,
        format: DataFormat,
        options?: z.infer<typeof conversionOptionsSchema>
    ): Promise<any> {
        switch (format) {
            case 'json':
                return this.parseJson(input);
            case 'xml':
                return await this.parseXmlToObject(input);
            case 'yaml':
                return this.parseYaml(input);
            case 'csv':
                return this.parseCsvToObject(input, options);
            case 'toml':
                return this.parseToml(input);
            default:
                throw new Error(`Unsupported input format: ${format}`);
        }
    }
  • formatOutput helper: dispatches object formatting based on toFormat to specific formatter methods
    private async formatOutput(
        data: any,
        format: DataFormat,
        options?: z.infer<typeof conversionOptionsSchema>
    ): Promise<string> {
        switch (format) {
            case 'json':
                return this.formatJson(data, options);
            case 'xml':
                return await this.formatXml(data, options);
            case 'yaml':
                return this.formatYaml(data, options);
            case 'csv':
                return this.formatCsv(data, options);
            case 'toml':
                return this.formatToml(data);
            default:
                throw new Error(`Unsupported output format: ${format}`);
        }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'supports pretty printing, minification, and format-specific options' which adds some behavioral context, but doesn't cover important aspects like error handling, performance characteristics, limitations, or what happens with malformed input data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise and front-loaded. The first sentence establishes the core purpose, and the second sentence efficiently lists key capabilities. Every word earns its place with zero wasted text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 4 parameters (3 required), 75% schema coverage, no annotations, and no output schema, the description provides adequate but incomplete context. It covers the what and some how, but lacks information about error cases, performance, limitations, and output format details that would be needed for comprehensive understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 75%, so the schema already documents most parameters well. The description adds value by mentioning 'pretty printing, minification, and format-specific options like CSV delimiters and headers' which gives context for the 'options' parameter, but doesn't provide additional semantic meaning beyond what the schema already covers for other parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('convert data between different formats') and resources (JSON, XML, YAML, CSV, TOML). It distinguishes itself from sibling tools (webfetch, websearch) by focusing on data format conversion rather than web operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. While it's clearly different from sibling tools (webfetch, websearch), there's no mention of when to choose type conversion over other data processing methods or what scenarios it's best suited for.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/brendon92/mcp-server'

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