Skip to main content
Glama

add_endnote_to_document

Insert an endnote into a specific paragraph of a Word document by providing the filename, paragraph index, and endnote text. Simplifies document annotation and referencing within Microsoft Word.

Instructions

Add an endnote to a specific paragraph in a Word document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endnote_textYes
filenameYes
paragraph_indexYes

Implementation Reference

  • The primary handler function implementing the logic to add an endnote reference (dagger symbol) to a specified paragraph and append the endnote text to an 'Endnotes' section at the document end using python-docx.
    async def add_endnote_to_document(filename: str, paragraph_index: int, endnote_text: str) -> str:
        """Add an endnote to a specific paragraph in a Word document.
        
        Args:
            filename: Path to the Word document
            paragraph_index: Index of the paragraph to add endnote to (0-based)
            endnote_text: Text content of the endnote
        """
        filename = ensure_docx_extension(filename)
        
        # Ensure paragraph_index is an integer
        try:
            paragraph_index = int(paragraph_index)
        except (ValueError, TypeError):
            return "Invalid parameter: paragraph_index must be an integer"
        
        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)
            
            # Validate paragraph index
            if paragraph_index < 0 or paragraph_index >= len(doc.paragraphs):
                return f"Invalid paragraph index. Document has {len(doc.paragraphs)} paragraphs (0-{len(doc.paragraphs)-1})."
            
            paragraph = doc.paragraphs[paragraph_index]
            
            # Add endnote reference
            last_run = paragraph.add_run()
            last_run.text = "†"  # Unicode dagger symbol common for endnotes
            last_run.font.superscript = True
            
            # Check if endnotes section exists, if not create it
            endnotes_heading_found = False
            for para in doc.paragraphs:
                if para.text == "Endnotes:" or para.text == "ENDNOTES":
                    endnotes_heading_found = True
                    break
            
            if not endnotes_heading_found:
                # Add a page break before endnotes section
                doc.add_page_break()
                doc.add_heading("Endnotes:", level=1)
            
            # Add the endnote text
            endnote_para = doc.add_paragraph("† " + endnote_text)
            endnote_para.style = "Endnote Text" if "Endnote Text" in doc.styles else "Normal"
            
            doc.save(filename)
            return f"Endnote added to paragraph {paragraph_index} in {filename}"
        except Exception as e:
            return f"Failed to add endnote: {str(e)}"
  • FastMCP tool registration using @mcp.tool() decorator. This wrapper defines the tool's schema (parameters and docstring) for the MCP protocol and delegates execution to the implementation in footnote_tools.add_endnote_to_document.
    @mcp.tool()
    async def add_endnote_to_document(filename: str, paragraph_index: int, endnote_text: str):
        """Add an endnote to a specific paragraph in a Word document."""
        return await footnote_tools.add_endnote_to_document(filename, paragraph_index, endnote_text)
  • Tool input schema defined by the function signature (filename: str, paragraph_index: int, endnote_text: str) and docstring in the MCP registration wrapper.
    async def add_endnote_to_document(filename: str, paragraph_index: int, endnote_text: str):
        """Add an endnote to a specific paragraph in a Word document."""
        return await footnote_tools.add_endnote_to_document(filename, paragraph_index, endnote_text)
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It implies a write operation ('Add') but does not disclose behavioral traits like permissions needed, whether changes are reversible, effects on document structure, or error handling. This is inadequate for a mutation tool with zero annotation coverage.

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 that directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it highly concise and well-structured.

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?

Given the complexity of a document mutation tool with no annotations, 0% schema coverage, and no output schema, the description is incomplete. It lacks details on behavior, parameter usage, and expected outcomes, making it insufficient for effective tool selection and invocation.

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

Parameters2/5

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

Schema description coverage is 0%, so the schema provides no parameter details. The description mentions 'endnote_text', 'filename', and 'paragraph_index' implicitly but does not explain their semantics, such as format requirements or index interpretation. It adds minimal value beyond naming the parameters, failing to compensate for the low coverage.

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 ('Add an endnote') and the target ('to a specific paragraph in a Word document'), distinguishing it from siblings like 'add_footnote_to_document' by specifying 'endnote' instead of 'footnote'. However, it does not explicitly differentiate from other document-modifying tools beyond the type of annotation, making it slightly less specific than a perfect score.

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, such as 'add_footnote_to_document' or other document editing tools. It lacks context about prerequisites, document state, or exclusions, leaving usage unclear beyond the basic action.

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