Word Document Reader MCP Server

Word Document Reader MCP Server

Enables reading and analyzing Word documents with advanced features including table extraction, OCR image analysis, full-text search, and intelligent caching for optimized performance on large documents.

Category
Visit Server

README

Word Document Reader MCP Server

A powerful Word document reading MCP server with table extraction, image OCR analysis, large document optimization, and intelligent caching.

๐Ÿš€ Core Features

1. Document Content Extraction

  • โœ… Word document (.docx/.doc) text extraction
  • โœ… Support for mixed Chinese-English documents
  • โœ… Preserve original formatting and structure

2. Table Extraction

  • โœ… Automatically identify and extract tables from Word documents
  • โœ… Convert to structured data format
  • โœ… Preserve table row/column structure information
  • โœ… Support complex table parsing

3. Image OCR Analysis

  • โœ… Extract embedded images from Word documents
  • โœ… High-precision OCR recognition using Tesseract.js v5
  • โœ… Support mixed Chinese-English text recognition (95%+ accuracy)
  • โœ… Intelligent image preprocessing for better recognition
  • โœ… Support multiple image formats (JPG, PNG, GIF, BMP, WebP)

4. Large Document Optimization

  • โœ… Automatic detection of large documents (>10MB or >100 pages)
  • โœ… Worker thread parallel processing, utilizing multi-core CPUs
  • โœ… Chunked processing to avoid memory overflow
  • โœ… 60%+ speed improvement

5. Intelligent Caching System

  • โœ… File system persistent caching
  • โœ… Smart cache invalidation based on file modification time
  • โœ… Cache statistics and management support
  • โœ… 90%+ speed improvement for repeated document processing

6. Full-text Index Search

  • โœ… Millisecond-level search with inverted index
  • โœ… Intelligent Chinese-English word segmentation
  • โœ… Relevance scoring and sorting
  • โœ… Support document type filtering

๐Ÿ“ฆ Installation and Usage

1. Install Dependencies

npm install

2. Start Server

# Start full-featured version
npm start

# Or start basic version (without advanced features)
npm run start:basic

3. Run Tests

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Generate test coverage report
npm run test:coverage

read_word_document

Read and analyze Word documents

{
  "name": "read_word_document",
  "arguments": {
    "filePath": "path/to/document.docx",
    "memoryKey": "my-document",
    "documentType": "api-doc",
    "extractTables": true,
    "extractImages": true,
    "useCache": true,
    "outputDir": "./output"
  }
}

search_documents

Full-text index search

{
  "name": "search_documents",
  "arguments": {
    "query": "search keywords",
    "documentType": "api-doc",
    "limit": 10
  }
}

get_cache_stats

Get cache statistics

{
  "name": "get_cache_stats"
}

clear_cache

Clear cache

{
  "name": "clear_cache",
  "arguments": {
    "type": "all"  // "all", "document", "index"
  }
}

list_stored_documents

List stored documents

{
  "name": "list_stored_documents",
  "arguments": {
    "documentType": "api-doc"
  }
}

get_stored_document

Get specific document content

{
  "name": "get_stored_document",
  "arguments": {
    "memoryKey": "document-key"
  }
}

clear_memory

Clear memory content

{
  "name": "clear_memory",
  "arguments": {
    "memoryKey": "specific-key"  // Optional, clear all if not provided
  }
}

๐Ÿ“ Project Structure

word-doc-mcp/
โ”œโ”€โ”€ server.js              # Main server file (with all features)
โ”œโ”€โ”€ server-basic.js        # Basic server (compatibility)
โ”œโ”€โ”€ package.json           # Project configuration and dependencies
โ”œโ”€โ”€ config.json           # Server configuration file
โ”œโ”€โ”€ tests/                # Test directory
โ”‚   โ”œโ”€โ”€ setup.js          # Test environment setup
โ”‚   โ”œโ”€โ”€ unit/             # Unit tests
โ”‚   โ”‚   โ””โ”€โ”€ services/     # Service layer tests
โ”‚   โ”œโ”€โ”€ integration/      # Integration tests
โ”‚   โ”‚   โ”œโ”€โ”€ tools/        # Tool tests
โ”‚   โ”‚   โ””โ”€โ”€ cache/        # Cache tests
โ”‚   โ””โ”€โ”€ fixtures/         # Test data
โ”‚       โ”œโ”€โ”€ documents/    # Test documents
โ”‚       โ””โ”€โ”€ mock-data.js  # Mock data
โ”œโ”€โ”€ .cache/               # Cache directory (auto-created)
โ”œโ”€โ”€ output/               # Output directory (auto-created)
โ””โ”€โ”€ node_modules/         # Dependencies

โš™๏ธ Configuration

Edit the config.json file to customize server behavior:

{
  "processing": {
    "maxFileSize": 10485760,
    "maxPages": 100,
    "chunkSize": 1048576,
    "parallelProcessing": true
  },
  "cache": {
    "enabled": true,
    "defaultTTL": 3600,
    "cacheDirectory": "./.cache"
  },
  "ocr": {
    "enabled": true,
    "languages": ["chi_sim", "eng"]
  }
}

๐Ÿงช Testing

Test Framework

Using Node.js built-in test framework, following these standards:

  • Unit Tests: Test individual components and functions
  • Integration Tests: Test interactions between tools
  • End-to-End Tests: Test complete workflows

Running Tests

# Run all tests
npm test

# Run specific test file
node --test tests/unit/services/DocumentIndexer.test.js

# Run integration tests
node --test tests/integration/

# Generate coverage report
npm run test:coverage

Test Coverage

  • โœ… Functional tests for all MCP tools
  • โœ… Complete cache system tests
  • โœ… Error handling and edge cases
  • โœ… Performance and concurrency tests
  • โœ… End-to-end workflow tests

๐Ÿ“Š Performance Metrics

  • Large Document Processing: 60%+ speed improvement (parallel processing)
  • Repeated Document Processing: 90%+ speed improvement (caching)
  • OCR Recognition Accuracy: 95%+ (image preprocessing)
  • Memory Usage Optimization: 40% reduction (streaming processing)
  • Search Response Time: <100ms (full-text index)

๐Ÿ›ก๏ธ Security Considerations

  • Input file size limits
  • File type validation
  • Cache data isolation
  • Error handling and logging
  • Automatic temporary file cleanup

๐Ÿ”„ Version Compatibility

Backward Compatibility

  • โœ… Maintain full compatibility with original API
  • โœ… Existing tool functionality unchanged
  • โœ… Optional configuration with reasonable defaults
  • โœ… Provide basic version to ensure compatibility

System Requirements

Minimum Requirements:

  • Node.js 16+
  • 4GB RAM
  • 1GB disk space

Recommended Configuration:

  • Node.js 18+
  • 8GB+ RAM
  • Multi-core CPU
  • SSD storage

๐Ÿ› Troubleshooting

Common Issues

  1. Module Installation Failure

    npm cache clean --force
    npm install
    
  2. OCR Recognition Failure

    • Ensure sufficient memory (8GB+ recommended)
    • Check supported image formats
    • Review error logs
  3. Slow Large Document Processing

    • Enable parallel processing
    • Adjust chunkSize configuration
    • Use SSD storage
  4. Memory Insufficient

    node --max-old-space-size=4096 server.js
    

๐Ÿ“ Changelog

v2.0.0

  • โœ… Add table extraction functionality
  • โœ… Add image OCR analysis
  • โœ… Implement large document parallel processing
  • โœ… Add intelligent caching system
  • โœ… Implement full-text index search
  • โœ… Complete testing framework

v1.0.0

  • โœ… Basic Word document reading
  • โœ… Memory storage management
  • โœ… Simple search functionality

๐Ÿค Contributing

Issues and Pull Requests are welcome!

Development Guidelines

  1. Fork the project
  2. Create feature branch
  3. Write test cases
  4. Ensure all tests pass
  5. Submit Pull Request

๐Ÿ“„ License

MIT License


Quick Start: npm install && npm start

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured