Skip to main content
Glama

get_document_xml

Extract the raw XML structure from a Microsoft Word document for analysis, integration, or manipulation using the Office Word MCP Server interface.

Instructions

Get the raw XML structure of a Word document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes

Implementation Reference

  • The async handler function for the 'get_document_xml' tool. It delegates to the get_document_xml utility function from document_utils.
    async def get_document_xml_tool(filename: str) -> str:
        """Get the raw XML structure of a Word document."""
        return get_document_xml(filename)
  • Registration of the MCP tool named 'get_document_xml' using FastMCP's @mcp.tool() decorator. This defines the tool interface and calls the handler.
    async def get_document_xml(filename: str):
        """Get the raw XML structure of a Word document."""
        return await document_tools.get_document_xml_tool(filename)
  • Core utility function that implements the XML extraction logic by opening the DOCX as a zipfile and reading 'word/document.xml'.
    def get_document_xml(doc_path: str) -> str:
        """Extract and return the raw XML structure of the Word document (word/document.xml) from local path or URL."""
        import zipfile
    
        success, message, resolved_path, is_temp = resolve_file_path(doc_path)
    
        if not success:
            return message
    
        try:
            with zipfile.ZipFile(resolved_path) as docx_zip:
                with docx_zip.open('word/document.xml') as xml_file:
                    return xml_file.read().decode('utf-8')
        except Exception as e:
            return f"Failed to extract XML: {str(e)}"
        finally:
            # Clean up temp file if needed
            if is_temp and resolved_path:
                cleanup_temp_file(resolved_path)
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 of behavioral disclosure. It states the tool retrieves raw XML, implying a read-only operation, but does not specify permissions, rate limits, or potential side effects. This leaves gaps in understanding the tool's behavior and constraints.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and appropriately sized, making it easy to parse and understand quickly.

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 complexity (simple retrieval), lack of annotations, and no output schema, the description is minimally adequate but incomplete. It covers the basic action but misses details on behavior, output format, and usage context, which are important for effective tool invocation.

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 input schema has one parameter ('filename') with 0% description coverage, so the description must compensate. It implies the parameter is used to identify the document for XML retrieval, adding semantic meaning beyond the schema's basic type. However, it does not detail format or constraints, such as file extensions or path requirements.

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

Purpose4/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 ('raw XML structure of a Word document'), making the tool's purpose understandable. However, it does not explicitly differentiate from sibling tools like 'get_document_info' or 'get_document_text', which might retrieve different aspects of a document, leaving some ambiguity in sibling differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives, such as 'get_document_text' for plain text or 'get_document_info' for metadata. It lacks explicit context, prerequisites, or exclusions, offering minimal usage direction beyond the basic purpose.

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

Related 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/franlealp1/mcp-word'

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