--- title: MCP Docx Tools emoji: ๐Ÿ  colorFrom: purple colorTo: red sdk: gradio sdk_version: 6.0.0 app_file: app.py pinned: false short_description: From LLMs read and create docx via MCP tags: - building-mcp-track-enterprise - building-mcp-track-consumer - building-mcp-track-creative - mcp - word - document - reader - writer - mcp-1st-birthday - hackathon --- # ๐Ÿ“„ MCP Word Toolkit โ€“ Gradio Server (Reader/Writer) ![Project Character Mascot](character.png) ### ๐ŸŽˆ MCP 1st Birthday Hackathon Demonstrating how *Model Context Protocol* connects LLMs with local and remote productivity tools. ## ๐ŸŽฅ Project Presentation ## ๐Ÿ”— LinkedIn Showcase Project demo post: https://www.linkedin.com/posts/oscar-felipe-gonz%C3%A1lez-gonz%C3%A1lez-019971387_mcp-artificialintelligence-hackathon-activity-7400155174138245121-DKiX ## โœจ Features - ๐Ÿ“– **read_word**: Reads and extracts content from `.docx` files preserving paragraph breaks. - โœ๏ธ **create_word**: Creates a new Word document with the specified content (overwrites if it exists). - ๐ŸŒ **Gradio + MCP**: Fast interface that also exposes tools as an MCP server for other clients. - ๐Ÿ”Œ **MCP Integration**: Automatic tool discovery in compatible copilots (`mcp_server=True`). - ๐Ÿ›ก๏ธ **Configurable Security**: Limits system scope with `allowed_directories`. - ๐Ÿ’ป **Local / Remote**: Works fully local (edge) or as a remote HF Space endpoint. ## ๐Ÿš€ Quick Start (Local) ```powershell git clone cd pip install -r requirements.txt python app.py ``` ## ๐ŸŒ Remote MCP Endpoint ## ๐Ÿ“ก Gradio MCP Server URL ``` https://mcp-1st-birthday-mcp-docx-tools.hf.space/gradio_api/mcp/ ``` ## โš™๏ธ Configuration for Claude Desktop / MCPHost It is important to define `allowed_directories` to prevent unwanted access. Add only working folders, never the entire disk. #### Option 1: JSON (for `claude_desktop_config.json`) (I haven't managed to make it work in Claude_server) ```json { "mcpServers": { "word-docx-server": { "type": "remote", "url": "https://mcp-1st-birthday-mcp-docx-tools.hf.space/gradio_api/mcp/", "options": { "allowed_directories": [] } } } } ``` #### Option 2: YAML for ```yaml mcpServers: word-docx-server: type: "remote" url: "https://mcp-1st-birthday-mcp-docx-tools.hf.space/gradio_api/mcp/" options: allowed_directories: [] ```` #### Example Prompts > "Read the file C:\\Docs\\report.docx, summarize in 5 bullet points and create C:\\Docs\\summary.docx with that content using the available tools." > "Translate the content of C:\\Docs\\notes.txt to Spanish and save it as C:\\Docs\\notes_es.docx." > "Create a document at C:\\Docs\\plan.docx with a 5-day travel itinerary to Tokyo." ## ๐Ÿ”ง MCP Tools Exposed - `read_word` โ€“ Extract content from a Word file. - `create_word` โ€“ Create a new Word document. ### Chaining Example ``` Use read_word on C:\Reports\2025_Q1.docx, summarize to 5 bullet points, then create_word to C:\Reports\2025_Q1_summary.docx with that summary. ``` ## ๐Ÿ›ก๏ธ Security - Limit `allowed_directories` to specific folders. - Avoid documents with personal data if using remote services. - Verify paths before generating content (overwrites without asking). ## ๐Ÿงช Troubleshooting | Issue | Cause | Fix | |-------|-------|-----| | File not found | Incorrect path | Check separators and permissions | | Empty output | Document with empty paragraphs | Normal if text is not specified | | Corrupt docx | Damaged file | Open in Word and save again | ## ๐Ÿ› ๏ธ Tech Stack - Python 3.9+ - Gradio (`mcp_server=True` capability) - python-docx - Model Context Protocol ## ๐Ÿ™ Acknowledgments Special thanks to: - **Hugging Face** for hosting and platform support. - **Google** for video generation tools(Veo 3.1) and Antigravity with gemini 3 Pro (Preview). - **Anthropic** for Claude Server.
Hugging Face Google Anthropic
## โš ๏ธ Disclaimer A large part of the content of this project has been created with AI tools. ## ๐Ÿ“ License Apache License 2.0 --- Made with โค๏ธ for the MCP-1st-Birthday Hackathon. Contributions & issues welcome.