get_comments_by_author
Extract comments from a Word document by a specific author to review feedback or track contributions.
Instructions
Extract comments from a specific author in a Word document.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | ||
| author | Yes |
Implementation Reference
- word_document_server/main.py:408-411 (handler)Handler and registration for the get_comments_by_author tool using @mcp.tool() decorator. Delegates execution to comment_tools module.@mcp.tool() def get_comments_by_author(filename: str, author: str): """Extract comments from a specific author in a Word document.""" return comment_tools.get_comments_by_author(filename, author)
- Core implementation logic for extracting and filtering comments by author from a Word document, using helpers from core.comments module.async def get_comments_by_author(filename: str, author: str) -> str: """ Extract comments from a specific author in a Word document. Args: filename: Path to the Word document author: Name of the comment author to filter by Returns: JSON string containing filtered comments """ filename = ensure_docx_extension(filename) if not os.path.exists(filename): return json.dumps({ 'success': False, 'error': f'Document {filename} does not exist' }, indent=2) if not author or not author.strip(): return json.dumps({ 'success': False, 'error': 'Author name cannot be empty' }, indent=2) try: # Load the document doc = Document(filename) # Extract all comments all_comments = extract_all_comments(doc) # Filter by author author_comments = filter_comments_by_author(all_comments, author) # Return results return json.dumps({ 'success': True, 'author': author, 'comments': author_comments, 'total_comments': len(author_comments) }, indent=2) except Exception as e: return json.dumps({ 'success': False, 'error': f'Failed to extract comments: {str(e)}' }, indent=2)