Skip to main content
Glama

list_images

Extract and display all images from a Microsoft Word document with metadata for easy reference and management.

Instructions

List all images in a document.

Args: filepath: Path to the document

Returns: Dictionary with list of images and metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes

Implementation Reference

  • The implementation of the `list_images` tool, which lists images in a docx document. It is registered via the `@app.tool()` decorator on line 980.
    def list_images(filepath: str) -> dict[str, Any]:
        """
        List all images in a document.
    
        Args:
            filepath: Path to the document
    
        Returns:
            Dictionary with list of images and metadata
        """
        logger.info("Listing images", extra={"tool": "list_images", "filepath": filepath})
    
        try:
            doc = safe_open_document(filepath)
            images = []
    
            # Count images in document relationships
            for rel in doc.part.rels.values():
                if "image" in rel.target_ref:
                    images.append({
                        "filename": rel.target_part.filename,
                        "content_type": rel.target_part.content_type,
                    })
    
            return {
                "status": "success",
                "filepath": filepath,
                "images": images,
                "count": len(images),
            }
        except DocxMcpError as e:
            logger.warning(e.message, extra={"tool": "list_images", "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 images: {str(e)}")
            return {"status": "error", "error": 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