CSV Editor 是一款高性能的MCP服务器,它能让Claude、ChatGPT等AI助手通过简单命令实现强大的数据操作能力,彻底改变AI助手处理CSV数据的方式。
# 现在你的AI助手可以这样操作:
"加载销售数据并去除重复项"
"筛选2024年第四季度交易额超过10000美元的交易记录"
"计算价格和数量之间的相关性"
"用中位数填充缺失值"
"将分析结果导出为Excel文件"
# 所有操作都具备自动历史记录跟踪和撤销功能!
要通过 Smithery 为Claude Desktop自动安装 csv-editor,请执行以下命令:
npx -y @smithery/cli install @santoshray02/csv-editor --client claude
# 若需要,安装uv(一次性设置)
curl -LsSf https://astral.sh/uv/install.sh | sh
# 克隆并运行
git clone https://github.com/santoshray02/csv-editor.git
cd csv-editor
uv sync
uv run csv-editor
在macOS系统中,将以下内容添加到 ~/Library/Application Support/Claude/claude_desktop_config.json 文件中:
{
"mcpServers": {
"csv-editor": {
"command": "uv",
"args": ["tool", "run", "csv-editor"],
"env": {
"CSV_MAX_FILE_SIZE": "1073741824"
}
}
}
}
详细配置请参考 MCP_CONFIG.md。
AI助手在处理复杂数据操作时面临困难,它们虽然可以读取文件,但缺乏有效过滤、转换、分析和验证CSV数据的工具。
CSV Editor弥补了这一差距,它为AI助手提供了40多种专门用于CSV操作的工具,使其成为强大的数据分析师,能够:
| 特性 | CSV Editor | 传统工具 |
|---|---|---|
| AI集成 | 原生MCP协议 | 手动操作 |
| 自动保存 | 具备多种策略的自动保存 | 需要手动保存 |
| 历史记录跟踪 | 带快照的完整撤销/重做功能 | 有限或无此功能 |
| 会话管理 | 多用户隔离会话 | 单用户 |
| 数据验证 | 内置质量评分 | 需要单独的工具 |
| 性能 | 通过分块处理GB级以上的文件 | 存在内存限制 |
# 你的AI助手现在可以这样做:
"Load the sales data and remove duplicates"
"Filter for Q4 2024 transactions over $10,000"
"Calculate correlation between price and quantity"
"Fill missing values with the median"
"Export as Excel with the analysis"
# 所有操作都具备自动历史记录跟踪和撤销功能!
# 早上:加载昨天的数据
session = load_csv("daily_sales.csv")
# 清理:去除重复项并修正数据类型
remove_duplicates(session_id)
change_column_type("date", "datetime")
fill_missing_values(strategy="median", columns=["revenue"])
# 分析:获取洞察
get_statistics(columns=["revenue", "quantity"])
detect_outliers(method="iqr", threshold=1.5)
get_correlation_matrix(min_correlation=0.5)
# 报告:导出清理后的数据
export_csv(format="excel", file_path="clean_sales.xlsx")
# 从多个来源提取数据
load_csv_from_url("https://api.example.com/data.csv")
# 进行复杂的转换操作
filter_rows(conditions=[
{"column": "status", "operator": "==", "value": "active"},
{"column": "amount", "operator": ">", "value": 1000}
])
add_column(name="quarter", formula="Q{(month-1)//3 + 1}")
group_by_aggregate(group_by=["quarter"], aggregations={
"amount": ["sum", "mean"],
"customer_id": "count"
})
# 加载到不同的格式
export_csv(format="parquet") # 用于数据仓库
export_csv(format="json") # 用于API
# 验证传入的数据
validate_schema(schema={
"customer_id": {"type": "integer", "required": True},
"email": {"type": "string", "pattern": r"^[^@]+@[^@]+\.[^@]+$"},
"age": {"type": "integer", "min": 0, "max": 120}
})
# 质量评分
quality_report = check_data_quality()
# 返回:总体评分、缺失数据百分比、重复项、异常值
# 异常检测
anomalies = find_anomalies(methods=["statistical", "pattern"])
load_csv - 从文件加载load_csv_from_url - 从URL加载load_csv_from_content - 从字符串加载export_csv - 导出到各种格式get_session_info - 获取会话详情list_sessions - 列出活动会话close_session - 清理会话filter_rows - 复杂过滤sort_data - 多列排序select_columns - 列选择rename_columns - 重命名列add_column - 添加计算列remove_columns - 删除列update_column - 更新值change_column_type - 类型转换fill_missing_values - 处理空值remove_duplicates - 去重get_statistics - 统计摘要get_column_statistics - 列统计信息get_correlation_matrix - 相关性矩阵group_by_aggregate - 分组操作get_value_counts - 频率计数detect_outliers - 查找异常值profile_data - 数据剖析validate_schema - 模式验证check_data_quality - 质量指标find_anomalies - 异常检测configure_auto_save - 设置自动保存get_auto_save_status - 检查状态undo / redo - 导航历史记录get_history - 查看操作记录restore_to_operation - 时光回溯| 变量 | 默认值 | 描述 |
|---|---|---|
CSV_MAX_FILE_SIZE |
1GB | 最大文件大小 |
CSV_SESSION_TIMEOUT |
3600s | 会话超时时间 |
CSV_CHUNK_SIZE |
10000 | 处理块大小 |
CSV_AUTO_SAVE |
true | 启用自动保存 |
CSV Editor可以通过可配置的策略自动保存你的工作:
# 配置自动保存
configure_auto_save(
strategy="backup",
backup_dir="/backups",
max_backups=10
)
git clone https://github.com/santoshray02/csv-editor.git
cd csv-editor
pip install -e .
pipx install git+https://github.com/santoshray02/csv-editor.git
# 安装最新版本
pip install git+https://github.com/santoshray02/csv-editor.git
# 或者使用uv
uv pip install git+https://github.com/santoshray02/csv-editor.git
# 安装特定版本
pip install git+https://github.com/santoshray02/csv-editor.git@v1.0.1
uv run test # 运行测试
uv run test-cov # 带覆盖率
uv run all-checks # 格式化、检查代码风格、类型检查和测试
csv-editor/
├── src/csv_editor/ # 核心实现
│ ├── tools/ # MCP工具实现
│ ├── models/ # 数据模型
│ └── server.py # MCP服务器
├── tests/ # 测试套件
├── examples/ # 使用示例
└── docs/ # 文档
我们欢迎贡献!请参考 CONTRIBUTING.md 获取贡献指南。
uv run all-checks本项目采用MIT许可证,请参阅 LICENSE 文件获取详细信息。
本项目基于以下工具构建:
准备好提升你的AI数据处理能力了吗? 两分钟内开始使用 →