mcp_server_excel

yupcoding1/mcp_server_excel

3.1

If you are the rightful owner of mcp_server_excel and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A Python-based Model Context Protocol (MCP) server for advanced Excel file manipulation.

MCP Excel Server

A Python-based Model Context Protocol (MCP) server for advanced Excel file manipulation. This project exposes Excel file operations (create, read, write, format, etc.) as MCP resources and tools, making it easy to automate and integrate Excel workflows.

Table of Contents


Project Structure

.
ā”œā”€ā”€ advanced_server.py        # Advanced MCP server with async support
ā”œā”€ā”€ main.py                   # Main MCP server (FastMCP)
ā”œā”€ā”€ excel_fucntion.py         # All Excel file manipulation functions
ā”œā”€ā”€ requirements.txt          # Python dependencies
ā”œā”€ā”€ Dockerfile                # Docker build for advanced_server.py
ā”œā”€ā”€ Docker_advanced.txt       # Alternate Dockerfile for advanced_server.py
ā”œā”€ā”€ run_local.bat             # Windows batch script to run the server
ā”œā”€ā”€ run_local.sh              # Bash script to run the server
ā”œā”€ā”€ .env                      # Environment variables (e.g., EXCEL_FILES_DIR)
ā”œā”€ā”€ excel_files/              # Directory for Excel files (auto-created)
└── __pycache__/              # Python bytecode cache

Features

  • List, create, rename, and delete Excel files and sheets
  • Read/write cell values, rows, columns, and ranges
  • Merge/unmerge cells, set borders, auto-fit columns
  • Write formulas, save as new file
  • All operations exposed as MCP tools/resources
  • Async server (advanced_server.py) and FastMCP server (main.py)
  • Docker support for easy deployment

Requirements

Install dependencies:

pip install -r requirements.txt

Setup

  1. Clone the repository and navigate to the project directory.
  2. Ensure you have Python 3.11+ installed.
  3. (Optional) Edit .env to set EXCEL_FILES_DIR (default: ./excel_files).
  4. Install dependencies:
    pip install -r requirements.txt
    

Running the Server

On Windows (PowerShell or CMD):

run_local.bat

On Linux/macOS:

./run_local.sh

This will start the MCP Excel server using main.py and create the excel_files/ directory if it does not exist.

To run the advanced async server:

python advanced_server.py

Usage

  • The server exposes Excel file operations as MCP resources and tools.
  • Integrate with any MCP-compatible client or use the CLI for testing.
  • See main.py and advanced_server.py for all available tools and their parameters.

Docker Usage

Build and run with the provided Dockerfile:

docker build -t mcp-excel-server .
docker run -it --rm -v $(pwd)/excel_files:/app/excel_files mcp-excel-server
  • The default entrypoint runs advanced_server.py.
  • To use main.py, edit the CMD in the Dockerfile.
  • The Excel files directory is mounted for persistence.

Environment Variables

  • EXCEL_FILES_DIR: Directory for storing Excel files (default: ./excel_files).
    • Set in .env, or via environment when running Docker or scripts.

Directory Details

  • excel_files/: All Excel files created/modified by the server are stored here.
  • __pycache__/: Python bytecode cache (can be ignored).

Development Notes

  • All Excel logic is in excel_fucntion.py.
  • Add new tools/resources by editing main.py or advanced_server.py.
  • For custom environments, update .env or pass variables directly.
  • For MCP protocol details, see modelcontext/model-context-protocol.

References


Author: Mohammed Abbasi

License: Use as you want.