Skip to main content
Glama
cablate

Simple Document Processing MCP Server

docx_to_pdf

Convert DOCX files to PDF format by specifying the input DOCX path and the desired output PDF path.

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

  • The main handler function that converts DOCX to PDF using libreoffice-convert. Reads the DOCX file, converts it via LibreOffice, and writes the PDF output.
    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",
        };
      }
    }
  • Tool definition with name 'docx_to_pdf', description, and inputSchema requiring inputPath and outputPath strings.
    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"],
      },
    };
    export interface DocxToPdfArgs {
      inputPath: string;
      outputPath: string;
    }
  • TypeScript interface DocxToPdfArgs defining inputPath and outputPath fields.
    export interface DocxToPdfArgs {
      inputPath: string;
      outputPath: string;
    }
  • Type guard function isDocxToPdfArgs that validates runtime arguments for the 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-82 (registration)
    Server-side handler registration that dispatches 'docx_to_pdf' tool calls to 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);
Behavior2/5

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

No annotations provided. The description fails to disclose behavioral traits such as file overwrite behavior, formatting preservation, or error handling, which are important for a conversion tool.

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

Conciseness4/5

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

The description is a single concise sentence that is to the point. It could benefit from a bit more detail but remains efficient.

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?

The description does not cover return values, error conditions, or prerequisites. Given the tool's simplicity and absence of output schema, more context is needed for an agent to use it correctly.

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?

Input schema has 100% description coverage with two parameters (inputPath, outputPath). The description adds no additional semantics beyond what the schema already provides, meeting the baseline.

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 action (convert) and the resource (DOCX files to PDF format), distinguishing it from sibling tools like docx_to_html and format_convert.

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 on when to use this tool versus alternatives such as docx_to_html or format_convert. The description only states the conversion 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