Skip to main content
Glama

get_equation

Extract a specific equation from a Word document by index to obtain its LaTeX representation and optional OMML XML data.

Instructions

Get a specific equation by index from a Word document.

Args: filepath: Path to the document equation_index: Index of the equation (0-based) include_omml: If True, include the raw OMML XML

Returns: Dictionary with equation details including LaTeX representation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes
equation_indexYes
include_ommlNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Implementation of the get_equation tool handler, which fetches specific equation details from a document.
    def get_equation(filepath: str, equation_index: int, include_omml: bool = False) -> dict[str, Any]:
        """
        Get a specific equation by index from a Word document.
    
        Args:
            filepath: Path to the document
            equation_index: Index of the equation (0-based)
            include_omml: If True, include the raw OMML XML
    
        Returns:
            Dictionary with equation details including LaTeX representation
        """
        logger.info(
            "Getting equation",
            extra={"tool": "get_equation", "filepath": filepath, "index": equation_index},
        )
    
        try:
            equations = extract_equations(filepath)
    
            if equation_index < 0 or equation_index >= len(equations):
                raise InvalidParameterError(
                    "equation_index",
                    f"Index {equation_index} out of range (0-{len(equations)-1})",
                )
    
            eq = equations[equation_index]
    
            result = {
                "status": "success",
                "filepath": filepath,
                "equation": {
                    "index": eq["index"],
                    "paragraph_index": eq["paragraph_index"],
                    "type": eq["type"],
                    "latex": eq["latex"],
                    "context": eq["context"],
                },
            }
    
            if include_omml:
                result["equation"]["omml"] = eq["omml"]
    
            return result
        except DocxMcpError as e:
            logger.warning(e.message, extra={"tool": "get_equation", "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 getting equation: {str(e)}")
            return {"status": "error", "error": str(e)}
  • Registration of the get_equation tool using the @app.tool() decorator.
    @app.tool()
    def get_equation(filepath: str, equation_index: int, include_omml: bool = False) -> dict[str, Any]:
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 mentions that it returns a dictionary with equation details including LaTeX representation, which is helpful, but lacks critical behavioral details such as error handling (e.g., what happens if the index is out of bounds), file access permissions, or performance considerations.

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 front-loaded with the core purpose, followed by a structured breakdown of arguments and returns. Every sentence adds value without redundancy, making it efficient and easy to parse.

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

Completeness4/5

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

Given the tool's moderate complexity (3 parameters, no annotations, but has an output schema), the description is reasonably complete. It covers the purpose, parameters, and return value, though it could benefit from more behavioral context (e.g., error cases). The output schema reduces the need to detail return values.

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?

Schema description coverage is 0%, so the description must compensate. It provides clear semantics for all three parameters: 'filepath' (path to the document), 'equation_index' (0-based index), and 'include_omml' (include raw OMML XML if True). This adds meaningful context beyond the bare schema.

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 verb ('Get') and resource ('a specific equation by index from a Word document'), making the purpose explicit. It distinguishes from sibling tools like 'list_equations' (which lists all equations) by specifying retrieval of a single equation by index.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when needing a specific equation from a document, but does not explicitly state when to use this tool versus alternatives like 'list_equations' or other document-reading tools. No exclusions or prerequisites are mentioned.

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