Excel MCP Server

Excel MCP Server

Enables AI assistants to read, write, and manipulate Excel files through comprehensive spreadsheet operations. Supports file management, data querying, worksheet operations, formula calculations, and includes security features like path validation and automatic backups.

Category
Visit Server

README

Excel MCP Server

🚀 基于Model Context Protocol (MCP)的Excel处理服务器,使AI助手能够读取、写入和操作Excel文件。

Python MCP License

✨ 功能特性

  • 📊 Excel文件操作: 支持读取、写入和创建Excel文件 (.xlsx, .xls, .csv)
  • 🔍 数据查询: 高级数据查询和筛选功能
  • ✏️ 单元格操作: 数据修改和格式设置
  • 📋 工作表管理: 创建、删除、重命名工作表
  • 🧮 公式计算: 支持Excel公式的应用和计算
  • 📈 基础图表: 图表创建和操作
  • 🛡️ 安全机制: 路径验证、文件大小限制、自动备份
  • 🎨 数据格式化: 丰富的单元格格式设置选项

🏗️ 系统架构

graph TB
    subgraph "AI客户端"
        A[Claude Desktop/Code]
        B[MCP客户端]
    end
    
    subgraph "Excel MCP服务器"
        C[FastMCP服务器]
        D[Excel工具处理器]
        E[文件管理器]
        F[数据处理器]
        G[安全验证器]
    end
    
    subgraph "本地文件系统"
        H[Excel文件]
        I[临时文件]
        J[日志文件]
    end
    
    A --> B
    B <--> C
    C --> D
    D --> E
    D --> F
    D --> G
    E <--> H
    F <--> I
    G --> J

🚀 快速开始

1. 环境要求

  • Python 3.10 或更高版本
  • pip 包管理器

2. 安装依赖

git clone https://github.com/YOUR_USERNAME/excel-mcp.git
cd excel-mcp
pip install -r requirements.txt

3. 启动服务器

python server.py

4. 配置Claude Desktop

在Claude Desktop的配置文件中添加以下配置:

{
  "mcpServers": {
    "excel-mcp": {
      "command": "python",
      "args": ["/path/to/excel-mcp/server.py"],
      "env": {
        "EXCEL_MCP_CONFIG": "/path/to/excel-mcp/config.json"
      }
    }
  }
}

🛠️ 支持的操作

📁 文件操作

  • read_excel_file - 读取Excel文件内容
  • write_excel_file - 写入数据到Excel文件
  • create_excel_file - 创建新的Excel文件
  • get_excel_info - 获取Excel文件信息

📊 数据操作

  • query_excel_data - 查询Excel数据
  • get_range_info - 获取单元格范围信息
  • apply_formula - 应用Excel公式

📋 工作表操作

  • list_worksheets - 列出所有工作表
  • create_worksheet - 创建新工作表
  • delete_worksheet - 删除工作表
  • rename_worksheet - 重命名工作表

💡 使用示例

读取Excel文件

请帮我读取文件 data/sales_data.xlsx 的内容

创建新文件

创建一个新的Excel文件 report.xlsx,包含两个工作表:Sales 和 Summary

数据查询

在 sales_data.xlsx 的 Sheet1 中查找所有销售额大于1000的记录

应用公式

在 report.xlsx 的 Sales 工作表的D2单元格中应用公式 =B2*C2

🔧 配置选项

服务器配置通过 config.json 文件管理:

{
  "server": {
    "name": "excel-mcp",
    "version": "1.0.0"
  },
  "excel": {
    "max_file_size": "100MB",
    "supported_formats": [".xlsx", ".xls", ".csv"],
    "backup_enabled": true
  },
  "security": {
    "allowed_paths": ["./data", "~/Documents", "~/Desktop"],
    "max_memory_usage": "512MB"
  }
}

🧪 测试

运行测试套件:

# 基础功能测试
python tests/test_excel_mcp.py

# 快速功能测试
python test_quick.py

📁 项目结构

excel-mcp/
├── src/excel_mcp/          # 核心源码
│   ├── server.py           # MCP服务器主程序
│   ├── file_manager.py     # 文件管理模块
│   ├── data_processor.py   # 数据处理模块
│   ├── sheet_operations.py # 工作表操作模块
│   ├── security.py         # 安全验证模块
│   └── config.py           # 配置管理模块
├── tests/                  # 测试文件
├── data/                   # 示例数据
├── docs/                   # 文档
└── config.json             # 配置文件

🛡️ 安全特性

  • 路径验证: 防止目录遍历攻击
  • 文件类型检查: 仅允许指定的Excel格式
  • 文件大小限制: 防止内存耗尽
  • 访问权限控制: 限制可访问的目录
  • 自动备份: 修改文件前自动创建备份
  • 详细日志: 完整的操作和错误日志

🤝 贡献指南

我们欢迎所有形式的贡献!请查看 贡献指南 了解详情。

开发环境设置

  1. Fork 这个仓库
  2. 创建你的特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交你的更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 打开一个 Pull Request

📄 许可证

这个项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。

🙏 致谢

📞 支持

如果你遇到任何问题或有疑问,请:

  1. 查看 FAQ
  2. 搜索现有的 Issues
  3. 创建新的 Issue

⭐ 如果这个项目对你有帮助,请给它一个星标!

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured