Skip to main content
Glama
cablate

Simple Document Processing MCP Server

format_convert

Convert document content between Markdown, HTML, XML, and JSON formats to enable cross-format compatibility and processing.

Instructions

Convert between different document formats (Markdown, HTML, XML, JSON)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesInput content to convert
fromFormatYesSource format
toFormatYesTarget format

Implementation Reference

  • The main handler function that performs the actual format conversion logic, validating inputs and dispatching to specific helper converters based on from/to format pair.
    export async function convertFormat(input: string, fromFormat: FormatType, toFormat: FormatType) {
      try {
        console.log(`Converting from ${fromFormat} to ${toFormat}`);
    
        // Validate formats
        if (!Object.values(FormatType).includes(fromFormat)) {
          return {
            success: false,
            error: `Unsupported source format: ${fromFormat}`,
          };
        }
        if (!Object.values(FormatType).includes(toFormat)) {
          return {
            success: false,
            error: `Unsupported target format: ${toFormat}`,
          };
        }
    
        // Handle different conversion paths
        let result: string;
        switch (`${fromFormat}-${toFormat}`) {
          case `${FormatType.MARKDOWN}-${FormatType.HTML}`:
            result = await markdownToHtml(input);
            break;
          case `${FormatType.HTML}-${FormatType.MARKDOWN}`:
            return {
              success: false,
              error: "HTML to Markdown conversion is not supported yet",
            };
          case `${FormatType.XML}-${FormatType.JSON}`:
            result = await xmlToJson(input);
            break;
          case `${FormatType.JSON}-${FormatType.XML}`:
            result = jsonToXml(input);
            break;
          default:
            return {
              success: false,
              error: `Unsupported conversion path: ${fromFormat} to ${toFormat}`,
            };
        }
    
        return {
          success: true,
          data: result,
        };
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
        console.error(`Error converting format: ${errorMessage}`);
        return {
          success: false,
          error: errorMessage,
        };
      }
    }
  • Input JSON schema defining the parameters for the format_convert tool: input content, source format, and target format.
    inputSchema: {
      type: "object",
      properties: {
        input: {
          type: "string",
          description: "Input content to convert",
        },
        fromFormat: {
          type: "string",
          enum: Object.values(FormatType),
          description: "Source format",
        },
        toFormat: {
          type: "string",
          enum: Object.values(FormatType),
          description: "Target format",
        },
      },
      required: ["input", "fromFormat", "toFormat"],
    },
  • Registration of the format_convert tool (as FORMAT_CONVERTER_TOOL) in the central tools array exported for use in the MCP server.
    export const tools = [DOCUMENT_READER_TOOL, PDF_MERGE_TOOL, PDF_SPLIT_TOOL, DOCX_TO_PDF_TOOL, DOCX_TO_HTML_TOOL, HTML_CLEAN_TOOL, HTML_TO_TEXT_TOOL, HTML_TO_MARKDOWN_TOOL, HTML_EXTRACT_RESOURCES_TOOL, HTML_FORMAT_TOOL, TEXT_DIFF_TOOL, TEXT_SPLIT_TOOL, TEXT_FORMAT_TOOL, TEXT_ENCODING_CONVERT_TOOL, EXCEL_READ_TOOL, FORMAT_CONVERTER_TOOL];
  • Type guard function for validating input arguments match FormatConverterArgs.
    export function isFormatConverterArgs(args: unknown): args is FormatConverterArgs {
      return typeof args === "object" && args !== null && "input" in args && "fromFormat" in args && "toFormat" in args && typeof (args as FormatConverterArgs).input === "string" && Object.values(FormatType).includes((args as FormatConverterArgs).fromFormat) && Object.values(FormatType).includes((args as FormatConverterArgs).toFormat);
    }
  • Enumeration of supported format types used in schema and logic.
    export enum FormatType {
      MARKDOWN = "markdown",
      HTML = "html",
      XML = "xml",
      JSON = "json",
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it states the conversion action, it fails to describe important behavioral traits such as error handling (e.g., invalid input formats), performance characteristics (e.g., speed or size limits), or output specifics (e.g., formatting preservation). For a mutation tool with zero annotation coverage, this is a significant gap.

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 extremely concise and front-loaded, consisting of a single sentence that directly states the tool's function. There is no wasted text or redundancy, making it efficient for an agent to parse while still conveying the core purpose.

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

Completeness2/5

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

Given the tool's complexity (format conversion with 3 parameters) and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns, how errors are handled, or any behavioral nuances. While the schema covers parameters well, the overall context for safe and effective use is insufficient.

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?

The input schema has 100% description coverage, with clear parameter descriptions and enum values. The description adds minimal value beyond the schema by listing the supported formats, but doesn't provide additional context like format compatibility, conversion rules, or examples. With high schema coverage, the baseline is 3, and the description doesn't significantly enhance parameter understanding.

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

Purpose4/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: converting between document formats (Markdown, HTML, XML, JSON). It uses a specific verb ('Convert') and identifies the resources (document formats). However, it doesn't explicitly distinguish this tool from similar sibling tools like 'html_to_markdown', 'text_encoding_converter', or 'text_formatter', which reduces the score from a perfect 5.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, limitations, or compare it to sibling tools like 'html_to_markdown' or 'text_encoding_converter', leaving the agent to infer usage context. This lack of explicit when/when-not/alternatives information results in a low score.

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/cablate/mcp-doc-forge'

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