Skip to main content
Glama

list_content_controls

Extract all content controls from a Microsoft Word document to identify editable regions, placeholders, and structured elements for document automation or analysis.

Instructions

List all content controls in a document.

Args: filepath: Path to the document

Returns: Dictionary with list of content controls

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes

Implementation Reference

  • The implementation of the 'list_content_controls' tool, which extracts content controls (tags and titles) from a Word document.
    def list_content_controls(filepath: str) -> dict[str, Any]:
        """
        List all content controls in a document.
    
        Args:
            filepath: Path to the document
    
        Returns:
            Dictionary with list of content controls
        """
        logger.info(
            "Listing content controls",
            extra={"tool": "list_content_controls", "filepath": filepath},
        )
    
        try:
            doc = safe_open_document(filepath)
            controls = []
    
            # Find content controls in document
            for element in doc.element.body:
                # Look for content control elements
                sdt_elements = element.xpath(".//w:sdt")
                for sdt in sdt_elements:
                    # Extract control properties
                    properties = sdt.xpath(".//w:sdtPr")
                    if properties:
                        prop = properties[0]
                        tag_elements = prop.xpath(".//w:tag")
                        title_elements = prop.xpath(".//w:alias")
    
                        ns_val = (
                            "{http://schemas.openxmlformats.org/wordprocessingml/"
                            "2006/main}val"
                        )
                        tag = tag_elements[0].get(ns_val, "")
                        title = title_elements[0].get(ns_val, "")
    
                        controls.append({
                            "tag": tag,
                            "title": title,
                        })
    
            return {
                "status": "success",
                "filepath": filepath,
                "content_controls": controls,
                "count": len(controls),
            }
  • The tool is registered using the @app.tool() decorator.
    @app.tool()

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/Andrew82106/LLM_Docx_Agent_MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server