Skip to main content
Glama
cablate

Simple Document Processing MCP Server

docx_to_pdf

Convert DOCX files to PDF format by specifying input and output file paths for document processing.

Instructions

Convert DOCX files to PDF format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputPathYesPath to the input DOCX file
outputPathYesPath where the output PDF file should be saved

Implementation Reference

  • Core handler function that performs DOCX to PDF conversion using libreoffice-convert.
    export async function convertDocxToPdf(inputPath: string, outputPath: string) {
      try {
        const ext = path.extname(inputPath).toLowerCase();
        if (ext !== ".docx") {
          throw new Error("Input file must be a .docx file");
        }
    
        if (path.extname(outputPath).toLowerCase() !== ".pdf") {
          throw new Error("Output file must have .pdf extension");
        }
    
        const docxBuffer = await fs.readFile(inputPath);
        const pdfBuffer = await convertAsyncPromise(docxBuffer, ".pdf", undefined);
        await fs.writeFile(outputPath, pdfBuffer);
    
        return {
          success: true,
          data: `Successfully converted ${inputPath} to ${outputPath}`,
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : "Unknown error",
        };
      }
    }
  • MCP Tool object definition including name, description, and input schema for registration.
    export const DOCX_TO_PDF_TOOL: Tool = {
      name: "docx_to_pdf",
      description: "Convert DOCX files to PDF format",
      inputSchema: {
        type: "object",
        properties: {
          inputPath: {
            type: "string",
            description: "Path to the input DOCX file",
          },
          outputPath: {
            type: "string",
            description: "Path where the output PDF file should be saved",
          },
        },
        required: ["inputPath", "outputPath"],
      },
    };
  • TypeScript interface defining the input arguments for the docx_to_pdf tool.
    export interface DocxToPdfArgs {
      inputPath: string;
      outputPath: string;
    }
  • Type guard function to validate input arguments for docx_to_pdf tool.
    export function isDocxToPdfArgs(args: unknown): args is DocxToPdfArgs {
      return (
        typeof args === "object" &&
        args !== null &&
        "inputPath" in args &&
        "outputPath" in args &&
        typeof (args as DocxToPdfArgs).inputPath === "string" &&
        typeof (args as DocxToPdfArgs).outputPath === "string"
      );
    }
  • src/index.ts:77-93 (registration)
    Tool dispatch handler in the MCP server that validates arguments and calls the convertDocxToPdf function.
    if (name === "docx_to_pdf") {
      if (!isDocxToPdfArgs(args)) {
        throw new Error("Invalid arguments for docx_to_pdf");
      }
    
      const result = await convertDocxToPdf(args.inputPath, args.outputPath);
      if (!result.success) {
        return {
          content: [{ type: "text", text: `Error: ${result.error}` }],
          isError: true,
        };
      }
      return {
        content: [{ type: "text", text: fileOperationResponse(result.data) }],
        isError: false,
      };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Convert' implies a transformation operation, it doesn't specify whether this is a read-only conversion or if it modifies files, what happens on failure, or any performance characteristics like processing time or file size limits. This leaves significant behavioral gaps.

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 with a single, clear sentence that states the tool's purpose without any wasted words. It's front-loaded and efficiently communicates the essential information.

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 simple file conversion tool with 2 well-documented parameters and no output schema, the description is minimally adequate. However, it lacks important context about behavioral aspects (like error handling or file requirements) and doesn't help differentiate from sibling tools, making it incomplete for optimal agent use.

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, clearly documenting both parameters. The description adds no additional parameter information beyond what's in the schema, so it meets the baseline score of 3 where the schema does the heavy lifting.

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 with a specific verb ('Convert') and resource ('DOCX files to PDF format'), making it immediately understandable. However, it doesn't distinguish this tool from similar sibling tools like 'format_convert' or 'pdf_merger', which prevents a perfect score.

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 like 'format_convert' or 'docx_to_html'. It lacks any context about prerequisites, file requirements, or typical use cases, leaving the agent with no usage direction beyond the basic purpose.

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