Skip to main content
Glama

Excel MCP Server

by xuhongxin
INSTALL.md4.53 kB
# Excel MCP Server 安装和配置指南 ## 1. 安装依赖 首先,确保你已经安装了Python 3.10或更高版本。然后安装项目依赖: ```bash cd /Users/xuhongxin8477/code/excel-mcp pip install -r requirements.txt ``` ## 2. 配置Claude Desktop ### 2.1 找到Claude Desktop配置文件 Claude Desktop的配置文件位置(根据操作系统): - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json` - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json` - **Linux**: `~/.config/Claude/claude_desktop_config.json` ### 2.2 添加Excel MCP配置 在Claude Desktop配置文件中添加以下配置: ```json { "mcpServers": { "excel-mcp": { "command": "python", "args": ["/Users/xuhongxin8477/code/excel-mcp/server.py"], "env": { "EXCEL_MCP_CONFIG": "/Users/xuhongxin8477/code/excel-mcp/config.json" } } } } ``` **注意**: 请将路径 `/Users/xuhongxin8477/code/excel-mcp/server.py` 替换为你的实际项目路径。 ### 2.3 配置文件示例 如果你的Claude Desktop配置文件已经有其他MCP服务器,配置应该类似这样: ```json { "mcpServers": { "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/files"] }, "excel-mcp": { "command": "python", "args": ["/Users/xuhongxin8477/code/excel-mcp/server.py"], "env": { "EXCEL_MCP_CONFIG": "/Users/xuhongxin8477/code/excel-mcp/config.json" } } } } ``` ## 3. 测试配置 ### 3.1 测试服务器启动 在终端中运行以下命令测试服务器是否能正常启动: ```bash cd /Users/xuhongxin8477/code/excel-mcp python server.py ``` 如果一切正常,你应该看到服务器等待输入的状态。按 `Ctrl+C` 退出。 ### 3.2 重启Claude Desktop 配置完成后,重启Claude Desktop应用程序以加载新的MCP服务器配置。 ### 3.3 验证连接 在Claude Desktop中,尝试使用Excel相关的命令,例如: - "帮我读取这个Excel文件的内容" - "创建一个新的Excel文件" - "查询Excel中的数据" ## 4. 权限配置 ### 4.1 文件访问权限 默认情况下,Excel MCP服务器只能访问以下目录: - `./data` (项目数据目录) - `~/Documents` (用户文档目录) - `~/Desktop` (用户桌面目录) ### 4.2 修改访问权限 如需修改允许访问的目录,编辑 `config.json` 文件中的 `security.allowed_paths` 配置: ```json { "security": { "allowed_paths": [ "./data", "~/Documents", "~/Desktop", "~/Downloads", "/path/to/your/excel/files" ] } } ``` ## 5. 支持的操作 Excel MCP服务器支持以下操作: ### 5.1 文件操作 - `read_excel_file` - 读取Excel文件内容 - `write_excel_file` - 写入数据到Excel文件 - `create_excel_file` - 创建新的Excel文件 - `get_excel_info` - 获取Excel文件信息 ### 5.2 数据操作 - `query_excel_data` - 查询Excel数据 - `get_range_info` - 获取单元格范围信息 - `apply_formula` - 应用Excel公式 ### 5.3 工作表操作 - `list_worksheets` - 列出所有工作表 - `create_worksheet` - 创建新工作表 - `delete_worksheet` - 删除工作表 - `rename_worksheet` - 重命名工作表 ## 6. 使用示例 ### 6.1 读取Excel文件 ``` 请帮我读取文件 ~/Documents/sales_data.xlsx 的内容 ``` ### 6.2 创建Excel文件 ``` 创建一个新的Excel文件 ~/Documents/report.xlsx,包含两个工作表:Summary 和 Details ``` ### 6.3 查询数据 ``` 在文件 ~/Documents/sales_data.xlsx 的 Sheet1 中查找所有销售额大于1000的记录 ``` ## 7. 故障排除 ### 7.1 服务器无法启动 检查: 1. Python版本是否为3.10+ 2. 是否正确安装了所有依赖包 3. 配置文件路径是否正确 ### 7.2 文件访问被拒绝 检查: 1. 文件路径是否在允许的目录列表中 2. 文件是否存在且有读写权限 3. 文件格式是否被支持(.xlsx, .xls, .csv) ### 7.3 Claude Desktop中看不到Excel功能 检查: 1. Claude Desktop配置文件是否正确 2. 是否重启了Claude Desktop 3. 服务器路径是否正确 ## 8. 日志和调试 日志文件位置:`./logs/excel_mcp.log` 查看日志帮助诊断问题: ```bash tail -f logs/excel_mcp.log ``` ## 9. 安全注意事项 1. 确保只授权访问必要的目录 2. 定期检查和清理临时文件 3. 不要将敏感文件放在允许访问的目录中 4. 定期更新依赖包以获取安全补丁

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xuhongxin/excel-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server