Skip to main content
Glama

get_document_text

Extract and retrieve all text content from a Microsoft Word document for processing, analysis, or integration with other workflows using the Office Word MCP Server.

Instructions

Extract all text from a Word document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes

Implementation Reference

  • MCP tool registration with @mcp.tool() decorator. This is the entrypoint for the 'get_document_text' tool in the FastMCP server, delegating to the underlying implementation.
    @mcp.tool()
    async def get_document_text(filename: str):
        """Extract all text from a Word document."""
        return await document_tools.get_document_text(filename)
  • Primary handler function implementing the tool logic: handles filename normalization and calls the text extraction utility.
    async def get_document_text(filename: str) -> str:
        """Extract all text from a Word document from local path or URL.
    
        Args:
            filename: Path or URL to the Word document
        """
        # Only add .docx extension for local paths, not URLs
        if not is_url(filename):
            filename = ensure_docx_extension(filename)
    
        return extract_document_text(filename)
  • Core helper function that loads the document (handling URLs and temp files) and extracts all text from paragraphs and tables.
    def extract_document_text(doc_path: str) -> str:
        """Extract all text from a Word document from local path or URL."""
        doc, error, is_temp, temp_path = load_document_from_path_or_url(doc_path)
    
        if error:
            return error
    
        try:
            text = []
    
            for paragraph in doc.paragraphs:
                text.append(paragraph.text)
    
            for table in doc.tables:
                for row in table.rows:
                    for cell in row.cells:
                        for paragraph in cell.paragraphs:
                            text.append(paragraph.text)
    
            return "\n".join(text)
        except Exception as e:
            return f"Failed to extract text: {str(e)}"
        finally:
            # Clean up temp file if needed
            if is_temp and temp_path:
                cleanup_temp_file(temp_path)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action 'extract all text' but does not cover critical aspects like permissions needed, file format support, error handling, or output format. This leaves significant gaps for a tool that performs document processing.

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 function without unnecessary words. It is front-loaded and appropriately sized, earning a perfect score for conciseness.

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

Completeness2/5

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

Given the complexity of document text extraction, no annotations, no output schema, and low schema coverage, the description is inadequate. It lacks details on behavioral traits, parameter usage, and output expectations, making it incomplete for effective tool selection and invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, with only one parameter 'filename' documented structurally. The description does not add any semantic details about the parameter, such as expected file paths or formats. Since schema coverage is low, the description fails to compensate, resulting in a baseline score of 3.

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 'extract' and the resource 'text from a Word document', making the purpose specific and understandable. However, it does not explicitly differentiate from sibling tools like 'get_paragraph_text_from_document' or 'find_text_in_document', which limits the score to 4 instead of 5.

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_paragraph_text_from_document' for partial extraction or 'find_text_in_document' for searching. It lacks explicit context, prerequisites, or exclusions, leaving usage unclear.

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