Skip to main content
Glama

set_list_level

Adjust list indentation levels in Word documents to organize content hierarchy. Specify paragraph index and desired level (0-8) for structured formatting.

Instructions

Set indentation level for a list paragraph.

Args: filepath: Path to the document paragraph_index: Index of the paragraph level: Indentation level (0-8)

Returns: Dictionary with status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes
paragraph_indexYes
levelYes

Implementation Reference

  • Implementation of the set_list_level tool handler.
    @app.tool()
    def set_list_level(filepath: str, paragraph_index: int, level: int) -> dict[str, Any]:
        """
        Set indentation level for a list paragraph.
    
        Args:
            filepath: Path to the document
            paragraph_index: Index of the paragraph
            level: Indentation level (0-8)
    
        Returns:
            Dictionary with status
        """
        logger.info("Setting list level", extra={"tool": "set_list_level", "filepath": filepath})
    
        try:
            if level < 0 or level > 8:
                raise InvalidParameterError("level", "Level must be between 0 and 8")
    
            doc = safe_open_document(filepath)
    
            if paragraph_index < 0 or paragraph_index >= len(doc.paragraphs):
                raise InvalidParameterError("paragraph_index", "Index out of range")
    
            paragraph = doc.paragraphs[paragraph_index]
            paragraph.paragraph_format.left_indent = Inches(0.5 * level)
    
            safe_save_document(doc, filepath)
            logger.info(f"Set list level to {level} for paragraph", extra={"filepath": filepath})
    
            return {
                "status": "success",
                "filepath": filepath,
                "paragraph_index": paragraph_index,
                "level": level,
            }
        except DocxMcpError as e:
            logger.warning(e.message, extra={"tool": "set_list_level", "error_code": e.error_code})
            return {"status": "error", "error": e.message, "error_code": e.error_code}
        except Exception as e:
            logger.error(f"Unexpected error setting list level: {str(e)}")

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