Skip to main content
Glama

create_document

Generate a new Word document with custom filename, title, and author metadata. Simplifies document creation for structured and standardized workflows.

Instructions

Create a new Word document with optional metadata.

Input Schema

NameRequiredDescriptionDefault
authorNo
filenameYes
titleNo

Input Schema (JSON Schema)

{ "properties": { "author": { "default": null, "title": "Author", "type": "string" }, "filename": { "title": "Filename", "type": "string" }, "title": { "default": null, "title": "Title", "type": "string" } }, "required": [ "filename" ], "type": "object" }

Implementation Reference

  • Core handler function that implements the logic to create a new Word document (.docx) using python-docx library. Handles filename extension, writability check, sets title/author metadata, ensures required styles (headings, tables), saves the document, and returns success/error message.
    async def create_document(filename: str, title: Optional[str] = None, author: Optional[str] = None) -> str: """Create a new Word document with optional metadata. Args: filename: Name of the document to create (with or without .docx extension) title: Optional title for the document metadata author: Optional author for the document metadata """ filename = ensure_docx_extension(filename) # Check if file is writeable is_writeable, error_message = check_file_writeable(filename) if not is_writeable: return f"Cannot create document: {error_message}" try: doc = Document() # Set properties if provided if title: doc.core_properties.title = title if author: doc.core_properties.author = author # Ensure necessary styles exist ensure_heading_style(doc) ensure_table_style(doc) # Save the document doc.save(filename) return f"Document {filename} created successfully" except Exception as e: return f"Failed to create document: {str(e)}"
  • FastMCP tool registration for 'create_document' using @mcp.tool() decorator. This is the entry point handler that delegates execution to the core implementation in document_tools.create_document.
    @mcp.tool() def create_document(filename: str, title: str = None, author: str = None): """Create a new Word document with optional metadata.""" return document_tools.create_document(filename, title, author)

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