Skip to main content
Glama

create_document

Generate a new Microsoft Word document with customizable metadata such as filename, title, and author. Ideal for managing and organizing documents efficiently.

Instructions

Create a new Word document with optional metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
authorNo
filenameYes
titleNo

Implementation Reference

  • Core handler function that creates a new Word document (.docx) file using python-docx library. Handles filename extension, writability checks, sets document properties (title, author), ensures required styles (headings, tables), saves the file, 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)}"
  • MCP tool registration using FastMCP @mcp.tool() decorator. Defines the tool entrypoint with input schema inferred from parameters, docstring, and delegates execution to the core handler in document_tools.create_document.
    @mcp.tool()
    async def create_document(filename: str, title: Optional[str] = None, author: Optional[str] = None):
        """Create a new Word document with optional metadata."""
        return await document_tools.create_document(filename, title, author)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the basic action. It doesn't disclose behavioral traits like permissions needed, whether the document is saved automatically, format limitations, or error conditions. 'Create' implies a write operation, but details are missing.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool that creates documents with 3 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on what happens after creation, error handling, or how it integrates with sibling tools, leaving significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description mentions 'optional metadata', which hints at parameters like author and title, but with 0% schema description coverage, it doesn't fully compensate. It adds minimal meaning beyond the schema's property names, so baseline 3 is appropriate given the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create') and resource ('new Word document'), making the purpose evident. It distinguishes from siblings like 'copy_document' by specifying creation rather than duplication, though it doesn't explicitly contrast with all alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'copy_document' or 'list_available_documents'. It mentions optional metadata but doesn't explain prerequisites, constraints, or typical use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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