Skip to main content
Glama

add_page_break

Insert a page break in Microsoft Word documents to separate content sections or start new pages where needed.

Instructions

Add a page break to the document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes

Implementation Reference

  • Core handler function that loads the Word document, adds a page break using python-docx, saves the file, 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 decorator @mcp.tool() with a thin synchronous wrapper that delegates to the async handler in content_tools.
    @mcp.tool() def add_page_break(filename: str): """Add a page break to the document.""" return content_tools.add_page_break(filename)
  • Import of the add_page_break function for exposure in the tools package.
    from word_document_server.tools.content_tools import ( add_heading, add_paragraph, add_table, add_picture, add_page_break, add_table_of_contents, delete_paragraph, search_and_replace )

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/GongRzhe/Office-Word-MCP-Server'

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