csvfix-mcp
README.md
# csvfix-mcp
English | [中文](README.zh-CN.md)
An MCP (Model Context Protocol) server that **profiles and cleans messy CSV/Excel files** — the kind you get from ERP exports, WeChat/Excel handoffs and government portals.
Built for the failure modes that actually break real spreadsheets:
| Problem | Handled |
|---|---|
| GBK / GB18030 / Big5 files that open as `锟斤拷` | ✅ auto-detected, re-encoded |
| Merged header cells (value only in the top-left cell) | ✅ unmerged |
| Title rows / blank rows above the real header | ✅ header row located by scoring |
| Header row repeated on every page of an export | ✅ removed |
| Numbers stored as text: `¥1,200.50`, `1 050`, full-width `120` | ✅ coerced to numbers |
| IDs with leading zeros (`001`, `00123`) | ✅ kept as text, zeros preserved |
| 16+ digit IDs that Excel silently rounds | ⚠️ flagged in the profile report |
| Duplicate column names, duplicate rows, empty rows/columns | ✅ fixed |
| Ragged CSV (unquoted comma inside a value) | ⚠️ detected and reported |
Read-only probing is separate from mutation: `profile_table` tells you what is wrong, `clean_table` fixes it, `merge_tables` combines files.
## Install
Requires Python 3.9+ and [uv](https://docs.astral.sh/uv/).
```bash
uvx --from git+https://github.com/DaoYewochengla/csvfix-mcp csvfix-mcp
```
First run downloads pandas + numpy (~22 MB). On a slow link to PyPI, point uv at a mirror first — measured on the same machine: **PyPI direct >14 min (stalled), Tsinghua mirror 3.3 s**:
```bash
# China mirror, then the same command
export UV_DEFAULT_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
uvx --from git+https://github.com/DaoYewochengla/csvfix-mcp csvfix-mcp
```
Or from a clone:
```bash
uv run --from . csvfix-mcp
```
## Try it before installing
[](https://glama.ai/mcp/servers/DaoYewochengla/csvfix-mcp)
The [Glama listing](https://glama.ai/mcp/servers/DaoYewochengla/csvfix-mcp) lets you browse the tools, check the server's quality score, and try it online with [MCP Inspector](https://glama.ai/mcp/inspector) before installing anything locally.
## Register in an MCP client
**Claude Desktop / Claude Code / Cline / any stdio client** (`claude_desktop_config.json` or `mcp.json`):
```json
{
"mcpServers": {
"csvfix": {
"command": "uvx",
"args": ["--from", "git+https://github.com/DaoYewochengla/csvfix-mcp", "csvfix-mcp"]
}
}
}
```
## Tools
### `profile_table`
Read-only diagnosis. Returns detected encoding, delimiter, the real header row, row/column counts, and per-column warnings (mojibake, numbers-as-text, leading zeros, 16+ digit IDs, mixed types, duplicate rows).
```json
{
"path": "D:/exports/订单_2026-01.csv"
}
```
```json
{
"encoding": "gb18030",
"delimiter": ",",
"rows": 5,
"columns": 4,
"file_issues": ["1 duplicate row(s)", "rows above the real header were dropped (title/notes rows)"],
"column_details": [
{"name": "编号", "detected_type": "text", "nulls": 0, "sample": ["001", "002"], "issues": []},
{"name": "金额", "detected_type": "number", "nulls": 0, "sample": ["1200.5", "980.0"], "issues": []}
]
}
```
### `clean_table`
Writes a tidy copy plus a `*.report.json` audit trail.
```json
{
"path": "D:/exports/订单_2026-01.csv",
"output": "D:/exports/订单_clean.csv",
"dedupe": true,
"format": "csv"
}
```
```json
{
"rows_in": 8,
"rows_out": 4,
"columns": 4,
"duplicates_removed": 1,
"encoding_in": "gb18030",
"output": "D:/exports/订单_clean.csv",
"report": "D:/exports/订单_clean.report.json"
}
```
`format: "csv"` writes UTF-8 **with BOM**, so double-clicking the file in Excel shows Chinese correctly instead of mojibake.
### `merge_tables`
Aligns columns by name across files with different encodings and column orders, then optionally de-duplicates on a key.
```json
{
"paths": ["D:/exports/一月.csv", "D:/exports/二月.xlsx"],
"output": "D:/exports/q1.xlsx",
"key": "编号"
}
```
## Deliberate limits
- **Local files only.** Paths are read from the machine running the server; nothing is uploaded anywhere.
- **No header guessing beyond row 25.** Past that, exports usually have a real problem rather than a long preamble.
- **Silent values are left silent.** The cleaner never invents values; it reports nulls instead of filling them.
- **Not a schema validator.** Use it to normalise shape, then validate semantics with your own rules.
## Bulk / custom work
Cleaning thousands of files, a fixed monthly pipeline, or a format this tool does not cover yet — open an issue on this repo describing the input and what "clean" means for you; you'll get a quote.
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues