list_equations
Extract mathematical equations from Word documents and convert them to LaTeX format for analysis or reuse.
Instructions
List all mathematical equations/formulas in a Word document.
Extracts equations stored in Office Math Markup Language (OMML) format and converts them to LaTeX notation for readability.
Args: filepath: Path to the document
Returns: Dictionary with list of equations including LaTeX representation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filepath | Yes |
Implementation Reference
- src/docx_mcp/server.py:1019-1059 (handler)The 'list_equations' tool handler is implemented in src/docx_mcp/server.py. It uses '@app.tool()' decorator to register the tool and calls 'extract_equations' to perform the logic.
@app.tool() def list_equations(filepath: str) -> dict[str, Any]: """ List all mathematical equations/formulas in a Word document. Extracts equations stored in Office Math Markup Language (OMML) format and converts them to LaTeX notation for readability. Args: filepath: Path to the document Returns: Dictionary with list of equations including LaTeX representation """ logger.info("Listing equations", extra={"tool": "list_equations", "filepath": filepath}) try: equations = extract_equations(filepath) return { "status": "success", "filepath": filepath, "equations": [ { "index": eq["index"], "paragraph_index": eq["paragraph_index"], "type": eq["type"], "latex": eq["latex"], "context": eq["context"], } for eq in equations ], "count": len(equations), } except DocxMcpError as e: logger.warning(e.message, extra={"tool": "list_equations", "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 equations: {str(e)}") return {"status": "error", "error": str(e)}