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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"filename": "<filename>"
},
"name": "add_page_break"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes |
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)}" - word_document_server/main.py:722-725 (registration)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)