基于MCP(Model Context Protocol)的Office文档处理助手,支持在MCP Client中创建和编辑Word、Excel、Powerpoint文档。
An MCP (Model Context Protocol) server for Office document processing, enabling creation and editing of Word, Excel, and PowerPoint documents within MCP Clients without leaving the AI assistant environment.
Office-Editor-MCP implements the Model Context Protocol standard to expose Office document operations as tools and resources. It serves as a bridge between AI assistants and Microsoft Office documents, allowing you to create, edit, format, and analyze various Office documents through AI assistants.
# Clone the repository
git clone https://github.com/theWDY/office-editor-mcp.git
cd office-editor-mcp
# Install dependencies
pip install -r requirements.txt
Office Assistant
(modify as preferred)stdio
python /path/to/office_server.py
Note: Replace with your actual file path.cursor
folder in the project directory (if it doesn't exist)mcp.json
file in that folder with the following content:{
"mcpServers": {
"office-assistant": {
"command": "python",
"args": ["/path/to/office_server.py"],
"env": {}
}
}
}
Edit the Claude configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
Add the following configuration:
{
"mcpServers": {
"office-document-server": {
"command": "python",
"args": [
"/path/to/office_server.py"
]
}
}
}
After configuration, you can issue commands to your AI assistant like:
# Document Creation and Properties
create_document(filename, title=None, author=None)
get_document_info(filename)
get_document_text(filename)
get_document_outline(filename)
list_available_documents(directory=".")
copy_document(source_filename, destination_filename=None)
# Content Addition
add_heading(filename, text, level=1)
add_paragraph(filename, text, style=None)
add_table(filename, rows, cols, data=None)
add_picture(filename, image_path, width=None)
add_page_break(filename)
# Text Formatting
format_text(filename, paragraph_index, start_pos, end_pos, bold=None,
italic=None, underline=None, color=None, font_size=None, font_name=None)
search_and_replace(filename, find_text, replace_text)
delete_paragraph(filename, paragraph_index)
create_custom_style(filename, style_name, bold=None, italic=None,
font_size=None, font_name=None, color=None, base_style=None)
# Workbook Operations
create_workbook(filename)
open_workbook(filename)
save_workbook(filename, new_filename=None)
add_worksheet(filename, sheet_name=None)
list_worksheets(filename)
# Cell Operations
read_cell(filename, sheet_name, cell_reference)
write_cell(filename, sheet_name, cell_reference, value)
format_cell(filename, sheet_name, cell_reference, **format_args)
# Presentation Operations
create_presentation(filename)
open_presentation(filename)
save_presentation(filename, new_filename=None)
add_slide(filename, layout=None)
Missing Styles
Permission Issues
copy_document
function to create editable copies of locked documentsImage Insertion Problems
Enable detailed logging by setting the environment variable:
export MCP_DEBUG=1 # Linux/macOS
set MCP_DEBUG=1 # Windows
Contributions are welcome! Feel free to submit a Pull Request.
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.
Note: This server interacts with document files on your system. Always verify that requested operations are appropriate before confirming them in AI assistants or other MCP clients.
{ "mcpServers": { "office-editor-mcp": { "command": "python", "args": [ "/path/to/office_server.py" ] } } }
Related projects feature coming soon
Will recommend related projects based on sub-categories