Skip to main content
Glama

get_document_metadata

Extract metadata from Office documents without full conversion. Retrieve properties like title, author, and creation date from Word, Excel, and PowerPoint files.

Instructions

Get metadata from an Office document without full conversion.

Extracts document properties like title, author, creation date, etc. Faster than full conversion when you only need metadata.

Supported formats: .docx, .doc, .xlsx, .xls, .pptx, .ppt

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesAbsolute path to the Office document. Supported: .docx, .doc, .xlsx, .xls, .pptx, .ppt

Implementation Reference

  • Handler implementation for get_document_metadata tool that parses the file_path argument, determines the Office document type, loads the document using appropriate library (docx, openpyxl, or pptx), extracts core properties/metadata, and returns it as JSON.
    elif name == "get_document_metadata":
        file_path = arguments.get("file_path")
        if not file_path:
            return [TextContent(
                type="text",
                text=f"{cache_notice}\n\n" + json.dumps({"error": "file_path is required"}, ensure_ascii=False)
            )]
    
        from .converter import get_file_type
    
        file_path_obj = Path(file_path)
        file_type = get_file_type(file_path_obj)
    
        metadata = {
            "file": file_path,
            "file_type": file_type,
            "cache_location": str(converter.cache_dir),
        }
    
        if file_type == "word":
            from docx import Document
            doc = Document(file_path)
            core_props = doc.core_properties
            metadata.update({
                "title": core_props.title or "",
                "author": core_props.author or "",
                "created": str(core_props.created) if core_props.created else "",
                "modified": str(core_props.modified) if core_props.modified else "",
                "last_modified_by": core_props.last_modified_by or "",
                "subject": core_props.subject or "",
                "keywords": core_props.keywords or "",
                "category": core_props.category or "",
                "comments": core_props.comments or "",
                "revision": core_props.revision,
            })
        elif file_type == "excel":
            from openpyxl import load_workbook
            wb = load_workbook(file_path, data_only=True)
            props = wb.properties
            metadata.update({
                "title": props.title or "",
                "creator": props.creator or "",
                "created": str(props.created) if props.created else "",
                "modified": str(props.modified) if props.modified else "",
                "sheet_count": len(wb.sheetnames),
                "sheet_names": wb.sheetnames,
            })
        elif file_type == "powerpoint":
            from pptx import Presentation
            prs = Presentation(file_path)
            core_props = prs.core_properties
            metadata.update({
                "title": core_props.title or "",
                "author": core_props.author or "",
                "created": str(core_props.created) if core_props.created else "",
                "modified": str(core_props.modified) if core_props.modified else "",
                "subject": core_props.subject or "",
                "slide_count": len(prs.slides),
            })
        else:
            return [TextContent(
                type="text",
                text=f"{cache_notice}\n\n" + json.dumps({
                    "error": f"Unsupported file format: {file_path_obj.suffix}",
                    "supported": get_supported_extensions()
                }, ensure_ascii=False)
            )]
    
        return [TextContent(
            type="text",
            text=f"{cache_notice}\n\n" + json.dumps(metadata, ensure_ascii=False, indent=2)
        )]
  • Registration of the get_document_metadata tool via server.list_tools() decorator, defining the tool name, description, and input schema requiring 'file_path'.
            Tool(
                name="get_document_metadata",
                description=f"""Get metadata from an Office document without full conversion.
    
    Extracts document properties like title, author, creation date, etc.
    Faster than full conversion when you only need metadata.
    
    Supported formats: {supported_exts}""",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "file_path": {
                            "type": "string",
                            "description": f"Absolute path to the Office document. Supported: {supported_exts}",
                        },
                    },
                    "required": ["file_path"],
                },
            ),
  • Input schema for get_document_metadata tool, defining the required 'file_path' parameter.
    inputSchema={
        "type": "object",
        "properties": {
            "file_path": {
                "type": "string",
                "description": f"Absolute path to the Office document. Supported: {supported_exts}",
            },
        },
        "required": ["file_path"],
    },
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it's a read operation (implied by 'Get', 'Extracts'), it's faster than full conversion, and it supports specific formats. However, it lacks details on error handling, performance limits, or what metadata fields are returned.

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 supporting details in three concise sentences. Each sentence adds value: the first states what it does and doesn't do, the second lists extracted properties, the third explains performance benefit, and the fourth specifies formats. No wasted words.

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 (single parameter, no output schema, no annotations), the description is largely complete: it covers purpose, usage, performance, and formats. However, it doesn't specify the exact metadata fields returned (e.g., 'title, author, creation date, etc.' is vague), which could be improved since there's no output schema.

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 schema description coverage is 100%, so the baseline is 3. The description adds value by reiterating supported formats in the parameter context, reinforcing constraints. However, it doesn't provide additional semantic details beyond what's in the schema (e.g., file path examples or format validation rules).

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 ('Get metadata', 'Extracts document properties') and resource ('Office document'), distinguishing it from siblings like convert_document (full conversion) and read_converted_markdown (content extraction). It explicitly mentions what it does not do ('without full conversion').

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool ('Faster than full conversion when you only need metadata') and when to use alternatives (implied: use convert_document for full conversion). It also lists supported formats, helping users avoid unsupported files.

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/Asunainlove/OfficeReader-MCP'

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