Skip to main content
Glama

list_styles

Retrieve all paragraph and character styles from a Microsoft Word document to analyze formatting options and maintain consistency.

Instructions

List all paragraph and character styles available in a document.

Args: filepath: Path to the document

Returns: Dictionary with list of styles

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The implementation of the 'list_styles' tool, which is decorated with @app.tool() for MCP registration, and handles the logic for extracting and returning paragraph and character styles from a DOCX file.
    @app.tool()
    def list_styles(filepath: str) -> dict[str, Any]:
        """
        List all paragraph and character styles available in a document.
    
        Args:
            filepath: Path to the document
    
        Returns:
            Dictionary with list of styles
        """
        logger.info("Listing styles", extra={"tool": "list_styles", "filepath": filepath})
    
        try:
            doc = safe_open_document(filepath)
            styles = {
                "paragraph_styles": [],
                "character_styles": [],
            }
    
            # Get styles from style definitions
            for style in doc.styles:
                style_info = {
                    "name": style.name,
                    "type": str(style.type),
                }
    
                if style.type == 1:  # Paragraph style
                    styles["paragraph_styles"].append(style_info)
                elif style.type == 2:  # Character style
                    styles["character_styles"].append(style_info)
    
            return {
                "status": "success",
                "filepath": filepath,
                "styles": styles,
                "total_styles": len(list(doc.styles)),
            }
        except DocxMcpError as e:
            logger.warning(e.message, extra={"tool": "list_styles", "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 listing styles: {str(e)}")
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 offers minimal behavioral insight. It states the tool lists styles but doesn't disclose critical details like whether it requires file access permissions, how it handles errors (e.g., invalid filepaths), or if it's read-only (implied but not confirmed). More context on operational behavior is needed.

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

Conciseness4/5

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

The description is front-loaded with the core purpose, followed by structured Args and Returns sections, making it efficient. However, the 'Returns' section is somewhat redundant given the presence of an output schema, slightly reducing conciseness. Overall, it's well-organized with minimal waste.

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

Completeness3/5

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

Given the tool's low complexity (1 parameter) and the existence of an output schema, the description is adequate but has gaps. It covers the purpose and parameter semantics but lacks usage guidelines and sufficient behavioral transparency (e.g., error handling, permissions). For a read operation, it meets minimum viability but could be more complete.

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

Parameters4/5

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

The description includes an 'Args' section that explains the single parameter ('filepath: Path to the document'), adding meaningful semantics beyond the schema's 0% coverage. This compensates well for the lack of schema descriptions, though it could specify format expectations (e.g., absolute vs. relative paths).

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

Purpose5/5

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

The description clearly states the specific action ('List all paragraph and character styles') and resource ('available in a document'), with a precise scope that distinguishes it from siblings like list_content_controls or list_equations. It explicitly identifies what types of styles are included (paragraph and character).

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?

No guidance is provided on when to use this tool versus alternatives. While it's implied this is for retrieving style information from a document, there's no mention of prerequisites, alternatives for different style types, or exclusions (e.g., table styles). The description lacks explicit usage context.

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

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