Excel MCP Server
A robust Model Context Protocol (MCP) server for Excel file manipulation.
Features
- Safe File Operations: File locking prevents concurrent access issues
- Security Hardened: Path validation, formula injection prevention, input sanitization
- Resource Management: Proper context managers ensure no file handle leaks
- Type Safety: Full Pydantic validation on all inputs
Installation```bash
pip install excel-mcp-server
## Usage
### As MCP Server```bash
excel-mcp-server
Configure allowed directories```python
from excel_mcp_server import add_allowed_directory
add_allowed_directory("/path/to/excel/files")
```
Tools
Workbook Operations
create_workbook- Create a new Excel workbookget_workbook_info- Get metadata about a workbooklist_sheets- List all sheets in a workbook
Sheet Operations
create_sheet- Create a new sheetdelete_sheet- Delete a sheetrename_sheet- Rename a sheet
Cell Operations
read_cell- Read a cell valuewrite_cell- Write a cell valueread_range- Read a range of cellswrite_range- Write data to a rangewrite_formula- Write a formula
Formatting Operations
format_font- Apply font formattingformat_fill- Apply background colorformat_number- Apply number format
Security Features
- Path Validation: Prevents path traversal attacks
- Directory Whitelist: Restrict file access to allowed directories
- Formula Injection Prevention: Blocks dangerous Excel formulas
- File Size Limits: Prevents resource exhaustion
- File Locking: Prevents concurrent write corruption
License
MIT
