Skip to main content
Glama
GongRzhe

Office Word MCP Server

customize_footnote_style

Modify footnote numbering format, starting number, and font style in Microsoft Word documents to meet specific formatting requirements.

Instructions

Customize footnote numbering and formatting in a Word document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
numbering_formatNo1, 2, 3
start_numberNo
font_nameNo
font_sizeNo

Implementation Reference

  • Primary asynchronous handler for the customize_footnote_style MCP tool. Loads the document, customizes footnote text style, finds footnote references, generates custom numbering symbols, applies formatting via helper functions, and saves the document.
    async def customize_footnote_style(filename: str, numbering_format: str = "1, 2, 3", 
                                      start_number: int = 1, font_name: Optional[str] = None,
                                      font_size: Optional[int] = None) -> str:
        """Customize footnote numbering and formatting in a Word document.
        
        Args:
            filename: Path to the Word document
            numbering_format: Format for footnote numbers (e.g., "1, 2, 3", "i, ii, iii", "a, b, c")
            start_number: Number to start footnote numbering from
            font_name: Optional font name for footnotes
            font_size: Optional font size for footnotes (in points)
        """
        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)
            
            # Create or get footnote style
            footnote_style_name = "Footnote Text"
            footnote_style = None
            
            try:
                footnote_style = doc.styles[footnote_style_name]
            except KeyError:
                # Create the style if it doesn't exist
                footnote_style = doc.styles.add_style(footnote_style_name, WD_STYLE_TYPE.PARAGRAPH)
            
            # Apply formatting to footnote style
            if footnote_style:
                if font_name:
                    footnote_style.font.name = font_name
                if font_size:
                    footnote_style.font.size = Pt(font_size)
            
            # Find all existing footnote references
            footnote_refs = find_footnote_references(doc)
            
            # Generate format symbols for the specified numbering format
            format_symbols = get_format_symbols(numbering_format, len(footnote_refs) + start_number)
            
            # Apply custom formatting to footnotes
            count = customize_footnote_formatting(doc, footnote_refs, format_symbols, start_number, footnote_style)
            
            # Save the document
            doc.save(filename)
            
            return f"Footnote style and numbering customized in {filename}"
        except Exception as e:
            return f"Failed to customize footnote style: {str(e)}"
  • Registers the customize_footnote_style tool with the FastMCP server using the @mcp.tool() decorator. This wrapper delegates to the implementation in footnote_tools.py and defines the tool schema via its signature and docstring.
    @mcp.tool()
    def customize_footnote_style(filename: str, numbering_format: str = "1, 2, 3",
                                start_number: int = 1, font_name: str = None,
                                font_size: int = None):
        """Customize footnote numbering and formatting in a Word document."""
        return footnote_tools.customize_footnote_style(
            filename, numbering_format, start_number, font_name, font_size
        )
  • Core helper function called by the tool handler to apply custom numbering symbols and styles to found footnote references.
    def customize_footnote_formatting(doc, footnote_refs, format_symbols, start_number, footnote_style):
        """Apply custom formatting to footnotes."""
        count = 0
        for i, ref in enumerate(footnote_refs):
            if i < len(format_symbols):
                # Update the footnote reference text
                ref['run'].text = format_symbols[i]
                ref['run'].font.superscript = True
                
                # Apply style if available
                if footnote_style:
                    try:
                        ref['paragraph'].style = footnote_style
                    except:
                        pass
                count += 1
        return count
  • Helper function to locate all superscript runs likely to be footnote references in the document.
    def find_footnote_references(doc):
        """Find all footnote references in the document."""
        footnote_refs = []
        for para_idx, para in enumerate(doc.paragraphs):
            for run_idx, run in enumerate(para.runs):
                # Check if this run has superscript formatting
                if run.font.superscript:
                    # Check if it's likely a footnote reference
                    if run.text.isdigit() or run.text in "¹²³⁴⁵⁶⁷⁸⁹⁰†‡§¶":
                        footnote_refs.append({
                            'paragraph_index': para_idx,
                            'run_index': run_idx,
                            'text': run.text,
                            'paragraph': para,
                            'run': run
                        })
        return footnote_refs
  • Helper function to generate the specified numbering format symbols (numeric, roman, alpha, symbols) for the footnotes.
    def get_format_symbols(format_type: str, count: int) -> list:
        """Generate format symbols for footnote numbering."""
        symbols = []
        
        if format_type == "1, 2, 3":
            symbols = [str(i) for i in range(1, count + 1)]
        elif format_type == "i, ii, iii":
            # Roman numerals
            roman_map = [(10, 'x'), (9, 'ix'), (5, 'v'), (4, 'iv'), (1, 'i')]
            for i in range(1, count + 1):
                result = ''
                num = i
                for value, numeral in roman_map:
                    count_sym, num = divmod(num, value)
                    result += numeral * count_sym
                symbols.append(result)
        elif format_type == "a, b, c":
            # Alphabetic
            for i in range(1, count + 1):
                if i <= 26:
                    symbols.append(chr(96 + i))
                else:
                    # For numbers > 26, use aa, ab, etc.
                    first = (i - 1) // 26
                    second = (i - 1) % 26 + 1
                    symbols.append(chr(96 + first) + chr(96 + second))
        elif format_type == "*, †, ‡":
            # Special symbols
            special = ['*', '†', '‡', '§', '¶', '#']
            for i in range(1, count + 1):
                if i <= len(special):
                    symbols.append(special[i - 1])
                else:
                    # Repeat symbols with numbers
                    symbols.append(special[(i - 1) % len(special)] + str((i - 1) // len(special) + 1))
        else:
            # Default to numeric
            symbols = [str(i) for i in range(1, count + 1)]
        
        return symbols
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'customize' which implies mutation, but doesn't disclose critical behavioral traits like whether changes are destructive to existing footnotes, permission requirements, error conditions, or what happens when applied to documents without footnotes. This leaves significant gaps for a mutation tool.

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 states the core purpose without unnecessary words. It's appropriately sized and front-loaded with the essential information, making every word earn its place.

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 mutation tool with 5 parameters, 0% schema coverage, no annotations, and no output schema, the description is inadequate. It doesn't explain what the tool returns, error conditions, side effects, or how it interacts with existing document structure. Given the complexity and lack of structured documentation, the description should provide much more context.

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?

With 0% schema description coverage for all 5 parameters, the description doesn't compensate at all. It mentions 'numbering and formatting' which hints at some parameters, but provides no specifics about what 'numbering_format' accepts, what 'font_name' values are valid, or how 'start_number' interacts with existing footnotes. The description adds minimal value beyond the parameter names themselves.

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 ('customize') and target ('footnote numbering and formatting in a Word document'), providing a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from sibling footnote-related tools like 'add_footnote_enhanced' or 'validate_document_footnotes', which would be needed for 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. With multiple sibling tools related to footnotes (e.g., add_footnote_enhanced, delete_footnote_from_document, validate_document_footnotes), there's no indication of whether this tool is for initial setup, modification, or other specific contexts.

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

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