Skip to main content
Glama

get_document_text

Extract all text from a Word document using a standardized MCP server tool. Input the filename to retrieve content efficiently for editing or analysis.

Instructions

Extract all text from a Word document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes

Implementation Reference

  • FastMCP tool registration for get_document_text, providing synchronous wrapper that delegates to the async implementation in document_tools.
    @mcp.tool() def get_document_text(filename: str): """Extract all text from a Word document.""" return document_tools.get_document_text(filename)
  • Core asynchronous handler implementation for get_document_text tool, which normalizes filename and calls the text extraction utility.
    async def get_document_text(filename: str) -> str: """Extract all text from a Word document. Args: filename: Path to the Word document """ filename = ensure_docx_extension(filename) return extract_document_text(filename)
  • Supporting utility that performs the actual text extraction from paragraphs and tables in the Word document.
    def extract_document_text(doc_path: str) -> str: """Extract all text from a Word document.""" import os if not os.path.exists(doc_path): return f"Document {doc_path} does not exist" try: doc = Document(doc_path) 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)}"

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/GongRzhe/Office-Word-MCP-Server'

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