📊 XLSX读卡器MCP
一个强大的模型上下文协议(MCP)服务器,用于读取和分析具有高级功能的Excel文档。
  
✨ 特性
- 📖 读取Excel文件:支持
.xlsx,.xls,以及.xlsm格式 - 🎯 灵活的数据访问:阅读整个表格、特定范围或目标单元格
- 📊 多种输出格式:JSON、CSV和格式化表输出
- 🔍 高级分析:详细的文件结构、数据类型分析和统计
- 📋 表单管理:使用多张纸并获得全面的概述
- 🎨 漂亮的格式:具有正确表格格式的干净、可读的输出
- ⚡ 高性能:高效处理大型Excel文件
- 🚫 智能过滤:自动跳过空行以获得更清晰的输出
- 📏 可配置限制:控制最大行数和预览大小以获得最佳性能
🚀 快速开始
安装
# Clone the repository
git clone https://github.com/guangxiangdebizi/xlsx-reader-mcp.git
cd xlsx-reader-mcp
# Install dependencies
npm install
# Build the project
npm run build使用Claude Desktop
方法1:标准模式(建议开发)
添加到您的Claude Desktop配置中:
{
"mcpServers": {
"xlsx-reader": {
"command": "node",
"args": ["path/to/xlsx-reader-mcp/build/index.js"]
}
}
}方法2:SSE模式(推荐用于生产)
# Start the SSE server
npm run sse然后添加到Claude Desktop配置:
{
"mcpServers": {
"xlsx-reader": {
"type": "sse",
"url": "http://localhost:3100/sse",
"timeout": 600
}
}
}🛠️ 可用工具
1. read_xlsx -Excel文件阅读器
使用灵活的格式选项和搜索功能从Excel文件中读取和提取数据。
参数:
filePath(必填):Excel文件的路径sheetName(可选):要阅读的特定表格range(可选):单元格范围(例如“A1:C10”)format(可选):输出格式-“json”、“csv”或“table”(默认)includeHeaders(可选):在输出中包含标题(默认值:true)maxRows(可选):返回的最大行数(默认值:100,最大值:1000)searchColumn(可选):要搜索的列(列名、索引或Excel字母)searchValue(可选):要搜索的值searchType(可选):搜索类型-“精确”、“包含”、“起始位置”、“结束位置”(默认值:“精确”)
注: 空行会自动过滤掉,以提供更清晰的输出。
示例用法:
Read the Excel file "data.xlsx" and show the first sheet as a table2. analyze_xlsx -Excel文件分析器
对Excel文件进行全面分析,包括结构、数据类型和统计数据。
参数:
filePath(必填):Excel文件的路径includePreview(可选):包括数据预览(默认值:true)previewRows(可选):预览行数(默认值:5,最大值:20)analyzeDataTypes(可选):分析列数据类型(默认值:true)
示例用法:
Analyze the structure and content of "report.xlsx"📖 例子
基本文件读取
Read the Excel file "sales_data.xlsx"阅读特定表格和范围
Read cells A1:E10 from the "Summary" sheet in "quarterly_report.xlsx" and format as JSON行限制阅读
Read "large_dataset.xlsx" but limit to first 50 rows搜索数据
Search for "ADSL" in column A of "data.xlsx" with exact matchFind all rows containing "John" in the "Name" column of "employees.xlsx"Search for values starting with "ABC" in column 3 of "products.xlsx"综合文件分析
Analyze "customer_database.xlsx" and show detailed information about all sheets🏗️ 项目结构
src/
├── index.ts # MCP server entry point
└── tools/
├── xlsx-reader.ts # Excel file reading tool
└── xlsx-analyzer.ts # Excel file analysis tool🔧 发展
脚本
npm run build-构建TypeScript项目npm run dev-开发观看模式npm start-启动MCP服务器npm run sse-在端口3100上启动SSE服务器
依赖项
- @模型上下文协议/sdk:用于服务器实现的MCP SDK
- XLSX:Excel文件处理库
📄 许可证
此项目根据Apache许可证2.0获得许可-请参阅 许可证 文件以获取详细信息。
👨💻 作者
陈兴宇
- 📧 电子邮件: guangxiangdebizi@gmail.com
- 🐙 github: @广相德彪子
- 💼 领英: 陈兴宇
- 📦 NPM: @邢玉晨
🤝 贡献
欢迎投稿!请随时提交拉取请求。
🙏 致谢
______________________________________________________________________
*由以下材料制成❤️ 对于MCP社区*
