Skip to main content
Glama

add_page_break

Insert a page break into a Microsoft Word document to organize content and improve readability, using the Office Word MCP Server for document formatting.

Instructions

Add a page break to the document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes

Implementation Reference

  • Core handler function that loads the specified Word document, appends a page break using python-docx, saves the document, and returns a success or error message.
    async def add_page_break(filename: str) -> str:
        """Add a page break to the document.
        
        Args:
            filename: Path to the Word document
        """
        filename = ensure_docx_extension(filename)
        
        if not os.path.exists(filename):
            return f"Document {filename} does not exist"
        
        # Check if file is writeable
        is_writeable, error_message = check_file_writeable(filename)
        if not is_writeable:
            return f"Cannot modify document: {error_message}. Consider creating a copy first."
        
        try:
            doc = Document(filename)
            doc.add_page_break()
            doc.save(filename)
            return f"Page break added to {filename}."
        except Exception as e:
            return f"Failed to add page break: {str(e)}"
  • MCP tool registration in the main server file using the FastMCP @mcp.tool() decorator. This defines the tool schema via the function signature and docstring, and delegates execution to the handler in content_tools.py.
    @mcp.tool()
    async def add_page_break(filename: str):
        """Add a page break to the document."""
        return await content_tools.add_page_break(filename)

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/franlealp1/mcp-word'

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