Skip to main content
Glama

copy_docx

Copy Microsoft Word documents to new locations for backup, sharing, or version control. Specify source and destination file paths to duplicate DOCX files.

Instructions

Copy a Word document to a new location.

Args: source_filepath: Path to the source document destination_filepath: Path for the copied document

Returns: Dictionary with status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
source_filepathYes
destination_filepathYes

Implementation Reference

  • The 'copy_docx' tool handler implementation, which copies a Word document to a new location using the docx library.
    def copy_docx(source_filepath: str, destination_filepath: str) -> dict[str, Any]:
        """
        Copy a Word document to a new location.
    
        Args:
            source_filepath: Path to the source document
            destination_filepath: Path for the copied document
    
        Returns:
            Dictionary with status
        """
        logger.info(
            "Copying document",
            extra={"tool": "copy_docx", "source": source_filepath, "destination": destination_filepath},
        )
    
        try:
            source_path = validate_docx_file(source_filepath)
            dest_path = normalize_path(destination_filepath)
            dest_path.parent.mkdir(parents=True, exist_ok=True)
    
            # Read and save as new document (preserves all formatting)
            doc = Document(str(source_path))
            doc.save(str(dest_path))
    
            logger.info("Document copied successfully", extra={"destination": destination_filepath})
    
            return {
                "status": "success",
                "source": str(source_path),
                "destination": str(dest_path),
                "message": "Document copied successfully",
            }
        except DocxMcpError as e:
            logger.warning(e.message, extra={"tool": "copy_docx", "error_code": e.error_code})
            return {"status": "error", "error": e.message, "error_code": e.error_code}
        except Exception as e:
            logger.error(f"Unexpected error copying document: {str(e)}")
            return {"status": "error", "error": str(e)}
  • Registration of the 'copy_docx' tool using the @app.tool() decorator.
    @app.tool()

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/Andrew82106/LLM_Docx_Agent_MCP'

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