Powerful MCP server for programmatic Excel (.xlsx) manipulation and automation
- Key Features
- Installation
- Deployment Modes
- Configuration
- Available Tools
- Project Structure
- Testing
- Development
- Contributing
- License
- Comprehensive Excel Operations: Create, read, modify workbooks and worksheets with full data manipulation support
- Advanced Formatting: Apply styles, fonts, colors, borders, and cell formatting with precision
- Data Visualization: Generate charts and pivot tables programmatically
- Formula Support: Apply and validate Excel formulas with error handling
- Security First: File path validation, access control, and robust error handling
- Multiple Deployment Modes: DXT package, traditional MCP server, or standalone CLI
- AI-Ready: Optimized for AI assistant integration via Model Context Protocol
- Python 3.11+: Modern Python with type hints support
- UV Package Manager: Install UV (recommended)
- Git: For cloning the repository
- Desktop Extensions (DXT): For creating .dxt packages for Claude Desktop Install DXT
git clone https://github.com/LuiccianDev/mcp_excel_office.git
cd mcp_excel_office# Install production dependencies
uv sync
# Install with development dependencies
uv sync --dev
# Install all dependency groups (dev + test)
uv sync --all-groups# Install the package
pip install .
# Development installation (editable)
pip install -e ".[dev,test]"# Build distributable package
uv build
# Install from built package
uv pip install dist/mcp_excel-*.whlThe MCP Excel Office Server supports three deployment modes:
Best for: Integrated DXT ecosystem users who want seamless configuration management.
-
Package the project:
dxt pack
-
Configuration: The DXT package automatically handles dependencies and provides user-friendly configuration through the manifest.json:
directory: Base directory for file operations
-
Usage: Once packaged, the tool integrates directly with DXT-compatible clients with automatic user configuration variable substitution.
-
Server Configuration: This project includes manifest.json for building .dxt packages.
For more details see DXT Package Documentation.
Best for: Standard MCP server deployments with existing MCP infrastructure.
Add to your MCP configuration file (e.g., Claude Desktop's mcp_config.json):
{
"mcpServers": {
"mcp_excel": {
"command": "uv",
"args": ["run", "mcp_excel"],
"env": {
"DIRECTORY": "/path/to/your/files"
}
}
}
}Alternative with CLI arguments:
{
"mcpServers": {
"mcp_excel": {
"command": "uv",
"args": [
"run", "-m", "mcp_excel",
"--directory", "/path/to/files"
]
}
}
}Best for: Direct command-line usage, scripting, and automation without MCP protocol overhead.
# Run with environment variables
export DIRECTORY="/path/to/your/files"
python -m mcp_excel
# Or run with command-line arguments
python -m mcp_excel --directory "/path/to/files"
# Using UV
uv run mcp_excel --helpYou can install and run the MCP Excel Office Server using Docker for an isolated and reproducible environment.
See Docker.md for details and advanced configuration options.
| Variable | Description | Required |
|---|---|---|
DIRECTORY |
Base directory for file operations | Yes |
LOG_LEVEL |
Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) | No (default: INFO) |
The server validates all configuration on startup and provides clear error messages for:
- Missing required environment variables
- Invalid directory paths
- File access permissions
Configuration is loaded with the following precedence (highest to lowest):
- Command-line arguments
- Environment variables
- User config variables (
${user_config.*}) - Default values
The MCP Excel Office Server provides 19 tools organized into 5 categories:
read_data_from_excel- Read data from Excel worksheetswrite_data_to_excel- Write data to Excel worksheets
create_excel_workbook- Create new Excel workbookscreate_excel_worksheet- Add worksheets to workbookslist_excel_documents- List Excel files in directorycopy_worksheet- Copy worksheets within workbooksdelete_worksheet- Delete worksheets from workbooksrename_worksheet- Rename worksheetsget_workbook_metadata- Get workbook information
format_range_excel- Apply comprehensive cell formattingmerge_cells- Merge cell rangesunmerge_cells- Unmerge cell rangescopy_range- Copy cell rangesdelete_range- Delete cell rangesvalidate_excel_range- Validate range references
apply_formula_excel- Apply Excel formulasvalidate_formula_syntax- Validate formula syntax
create_chart- Create chartscreate_pivot_table- Create pivot tables
For detailed documentation of all tools, see TOOLS.md.
mcp_excel_office/
├── src/mcp_excel/ # Main package
│ ├── __init__.py # Package initialization
│ ├── __main__.py # CLI entry point
│ ├── server.py # MCP server implementation
│ ├── config.py # Configuration management
│ ├── tools/ # MCP tool implementations
│ │ ├── excel_tools.py # Workbook/worksheet operations (7 tools)
│ │ ├── content_tools.py # Data read/write operations (2 tools)
│ │ ├── format_tools.py # Cell formatting (6 tools)
│ │ ├── formulas_excel_tools.py # Formula operations (2 tools)
│ │ ├── graphics_tools.py # Charts/pivot tables (2 tools)
│ │ └── register_tools.py # Tool registration
│ ├── core/ # Core functionality
│ │ ├── workbook.py # Workbook operations
│ │ ├── formatting.py # Cell formatting logic
│ │ ├── data.py # Data read/write logic
│ │ ├── calculations.py # Formula calculations
│ │ ├── chart.py # Chart creation
│ │ └── pivot.py # Pivot table creation
│ ├── utils/ # Utility functions
│ │ ├── file_utils.py # File validation and operations
│ │ ├── sheet_utils.py # Sheet operations
│ │ ├── cell_utils.py # Cell utilities
│ │ └── validation_utils.py # Validation utilities
│ └── exceptions/ # Custom exceptions
│ ├── exception_core.py # Core exceptions
│ └── exception_tools.py # Tool-specific exceptions
├── tests/ # Test suite
│ ├── conftest.py # Pytest configuration and fixtures
│ ├── test_excel_tools.py # Excel tools tests
│ ├── test_content_tools.py # Content tools tests
│ ├── test_format_tools.py # Format tools tests
│ ├── test_formulas_excel_tools.py # Formula tools tests
│ ├── test_graphics_tools.py # Graphics tools tests
│ ├── test_workbook.py # Workbook core tests
│ ├── test_data.py # Data core tests
│ ├── test_file_utils.py # File utilities tests
│ ├── test_file_security.py # Security tests
│ └── ... # Additional test files
├── pyproject.toml # Project configuration
├── manifest.json # DXT package configuration
├── ruff.toml # Ruff configuration
├── mypy.ini # MyPy configuration
├── pytest.ini # Pytest configuration
├── .pre-commit-config.yaml # Pre-commit hooks
├── TOOLS.md # Detailed tool documentation
├── README.md # This file
├── AGENTS.md # Development guidelines for AI agents
└── Docker.md # Docker deployment guide
uv run pytestuv run pytest tests/test_excel_tools.pyuv run pytest -k "test_name"uv run pytest --couv run pytest -v --tb=shortThe test suite includes coverage reporting. Coverage reports are generated in:
htmlcov/- HTML coverage reportcoverage.xml- XML coverage report
# Install development dependencies
uv sync --dev
# Install pre-commit hooks
uv run pre-commit install
# Run quality checks
uv run pre-commit run --all-files# Format code with Ruff
uv run ruff format
# Check code style
uv run ruff check
# Auto-fix issues
uv run ruff check --fix
# Type checking with MyPy
uv run mypy src/
# Run all quality checks
uv run pre-commit run --all-files| Command | Description |
|---|---|
uv sync --dev |
Install development dependencies |
uv run ruff check |
Code style and quality checks |
uv run ruff format |
Format code |
uv run mypy src/ |
Type checking (strict) |
uv run pytest |
Run test suite with coverage |
uv build |
Build distributable package |
dxt pack |
Create DXT package |
- Python Version: 3.11+
- Type Hints: Strict (mypy with
disallow_untyped_defs) - Line Length: 88 characters
- Formatting: Ruff/Black-compatible
- Imports: Organized with Ruff's isort
- Documentation: Google-style docstrings
See AGENTS.md for detailed development guidelines.
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Install development dependencies with
uv sync --dev - Run code quality checks:
uv run ruff check && uv run mypy src/ - Ensure tests pass:
uv run pytest - Submit a pull request
- Bug Reports: Open an issue with detailed reproduction steps
- Feature Requests: Describe your use case and proposed solution
- Questions: Check existing issues or start a discussion
This project is licensed under the MIT License. See the LICENSE file for details.
MCP Excel Office Server
Empowering AI assistants with comprehensive Excel manipulation capabilities
GitHub | MCP Protocol | Tool Documentation
Created by LuiccianDev