UNPKG

enhanced-word-mcp-server

Version:

Enhanced Word MCP server with comprehensive document operations. Features 24 consolidated tools, regex positioning fixes, and complete Word document manipulation capabilities.

262 lines (200 loc) โ€ข 8.25 kB
# Enhanced Word MCP Server ๐Ÿš€ **Advanced Word document manipulation for academic research collaboration** An enhanced version of the Office-Word-MCP-Server with revolutionary features designed specifically for academic research workflows, thesis synthesis, and scientific writing collaboration. ## ๐ŸŒŸ Key Enhancements This enhanced server solves critical limitations in LLM-friendly document manipulation while adding powerful features for academic research: ### ๐ŸŽฏ **Tier 1 Features - Production Ready** #### 1. **Enhanced Search & Replace with Formatting** - โœ… **Solves LLM character positioning problem** - No more counting characters! - โœ… Semantic text targeting with regex support - โœ… Simultaneous text replacement and formatting - โœ… Batch word formatting for research terms - โœ… Academic research helpers (PCL terminology, statistical notation) #### 2. **Review Tools & Collaboration** - โœ… Extract and manage comments with author/timestamp - โœ… Read, accept, and reject track changes - โœ… Generate comprehensive review summaries - โœ… Author-specific change management - โœ… Add comments programmatically #### 3. **Section Management via Heading Styles** - โœ… Extract document structure by heading hierarchy - โœ… Extract specific section content - โœ… Generate/update table of contents automatically - โœ… Document structure statistics - โœ… Multi-document section merging for thesis synthesis ## ๐Ÿš€ Quick Start ### Installation ```bash # Install the enhanced server npm install -g @kosta/enhanced-word-mcp-server # Or using npx (no installation needed) npx @kosta/enhanced-word-mcp-server ``` ### Claude Desktop Configuration Add to your Claude Desktop configuration: ```json { "mcpServers": { "enhanced-word-server": { "command": "npx", "args": ["@kosta/enhanced-word-mcp-server"] } } } ``` ## ๐Ÿ“– Enhanced Features Documentation ### Enhanced Search & Replace The enhanced search and replace feature solves the fundamental problem of character positioning that makes the original format_text tool impractical for LLMs. ```python # Example: Format research terms with semantic targeting enhanced_search_and_replace( filename="research_paper.docx", find_text="polycaprolactone", replace_text="polycaprolactone", apply_formatting=True, bold=True, color="green" ) # Format multiple research terms at once await format_research_paper_terms("research_paper.docx") ``` **Key Benefits:** - No character counting required - Semantic text matching - Simultaneous replacement and formatting - Support for regex patterns and whole-word matching - Academic research terminology helpers ### Review Tools Perfect for academic collaboration and thesis advisor feedback: ```python # Extract all comments and track changes review_summary = await generate_review_summary("thesis_draft.docx") # Get changes by specific author author_changes = await get_author_specific_changes("thesis_draft.docx", "Dr. Smith") # Accept all track changes (create clean version) await accept_all_changes("thesis_draft.docx") ``` ### Section Management Ideal for organizing large academic documents and thesis synthesis: ```python # Extract document structure structure = await extract_sections_by_heading("thesis.docx") # Extract specific section for analysis methods_section = await extract_section_content("thesis.docx", "Methods") # Generate table of contents await generate_table_of_contents("thesis.docx", max_level=3) # Merge sections from multiple documents (thesis synthesis) await merge_sections_from_documents( target_filename="combined_research.docx", source_files=["paper1.docx", "paper2.docx", "paper3.docx"], section_mapping={ "paper1.docx": "Results", "paper2.docx": "Methods", "paper3.docx": "Discussion" } ) ``` ## ๐Ÿ”ฌ Academic Research Use Cases ### PCL Mesophase Research Example ```python # Format scientific terminology consistently await format_specific_words( filename="pcl_research.docx", word_list=["dolutegravir", "meloxicam", "dexamethasone", "DTG", "MLX", "DEX"], bold=True, color="blue" ) # Format statistical notation await format_specific_words( filename="pcl_research.docx", word_list=["p < 0.05", "rยฒ", "ยฑ"], bold=True, color="red" ) # Extract and combine results sections from multiple student theses await merge_sections_from_documents( target_filename="combined_pcl_results.docx", source_files=[ "mbaye_dolutegravir_thesis.docx", "shah_dexamethasone_thesis.docx", "sharan_meloxicam_thesis.docx" ], section_mapping={ "mbaye_dolutegravir_thesis.docx": "Results and Discussion", "shah_dexamethasone_thesis.docx": "Results and Discussion", "sharan_meloxicam_thesis.docx": "Results and Discussion" } ) ``` ### Thesis Review Workflow ```python # Generate comprehensive review summary for advisor review = await generate_review_summary("student_thesis_v3.docx") # Extract changes by specific reviewer advisor_feedback = await get_author_specific_changes("student_thesis_v3.docx", "Dr. Johnson") # After addressing feedback, accept all changes await accept_all_changes("student_thesis_final.docx") ``` ## ๐Ÿ› ๏ธ Available Tools ### Enhanced Content Tools - `enhanced_search_and_replace` - Semantic text targeting with formatting - `format_specific_words` - Batch formatting of terminology - `format_research_paper_terms` - Academic terminology formatting ### Review & Collaboration Tools - `extract_comments` - Get all document comments - `extract_track_changes` - Get all track changes - `generate_review_summary` - Comprehensive review report - `accept_all_changes` - Create clean document version - `reject_all_changes` - Revert to original - `add_comment` - Add comments programmatically - `get_author_specific_changes` - Filter by author ### Section Management Tools - `extract_sections_by_heading` - Document structure analysis - `extract_section_content` - Get specific section text - `generate_table_of_contents` - Auto-generate TOC - `reorganize_sections` - Reorder document sections - `merge_sections_from_documents` - Combine sections from multiple docs - `get_section_statistics` - Document metrics and analysis ### Original Features All original Office-Word-MCP-Server features are preserved: - Document creation and manipulation - Text formatting and styling - Table operations - Protection and security - Footnotes and endnotes - PDF conversion ## ๐Ÿ—๏ธ Architecture The enhanced server maintains the original modular architecture while adding three new tool categories: ``` word_document_server/ โ”œโ”€โ”€ tools/ โ”‚ โ”œโ”€โ”€ content_tools.py # Enhanced with new search/replace โ”‚ โ”œโ”€โ”€ review_tools.py # NEW: Collaboration features โ”‚ โ”œโ”€โ”€ section_tools.py # NEW: Document organization โ”‚ โ”œโ”€โ”€ document_tools.py # Original functionality โ”‚ โ”œโ”€โ”€ format_tools.py # Original formatting โ”‚ โ””โ”€โ”€ ... โ”œโ”€โ”€ core/ # Shared utilities โ””โ”€โ”€ utils/ # Helper functions ``` ## ๐Ÿงช Testing Run the comprehensive test suite: ```bash python test_enhanced_features.py ``` This creates a sample academic document and tests all enhanced features. ## ๐Ÿค Contributing This enhanced server builds upon the excellent foundation of [GongRzhe/Office-Word-MCP-Server](https://github.com/GongRzhe/Office-Word-MCP-Server). ### Enhancements by Kosta Vuฤkoviฤ‡ - Enhanced search/replace solving LLM character positioning - Academic collaboration review tools - Document section management for thesis synthesis - Academic research workflow optimization ## ๐Ÿ“„ License MIT License - See LICENSE file for details. ## ๐Ÿ™ Acknowledgments - Original Office-Word-MCP-Server by [GongRzhe](https://github.com/GongRzhe) - Enhanced for academic research collaboration at Brown University - Designed for PCL mesophase drug delivery research synthesis --- **Perfect for:** Academic researchers, thesis advisors, graduate students, scientific writing collaboration, multi-document synthesis, and any workflow requiring advanced Word document manipulation with LLM-friendly interfaces.