Metadata-Version: 2.4
Name: excel-diff2-mcp
Version: 1.2.0
Summary: MCP server for comparing Excel files with hierarchical module matching (stacked output)
Author-email: excel-diff2-mcp <excel-diff2-mcp@example.com>
License: MIT
Keywords: comparison,diff,excel,mcp,model-context-protocol
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial :: Spreadsheet
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27.0
Requires-Dist: mcp[cli]>=1.0.0
Requires-Dist: openpyxl>=3.1.0
Requires-Dist: xlrd>=2.0.0
Description-Content-Type: text/markdown

# excel-diff2-mcp

MCP (Model Context Protocol) server for comparing Excel files with hierarchical module matching.

## Features

- **Hierarchical Module Matching**: Match Excel data by multiple levels of functional modules
- **Stacked Output**: Output two tables stacked in a single result
- **Dual Output Formats**: Support both CSV and Markdown output
- **Flexible Input**: Accept HTTP(S) URLs or Base64-encoded file content
- **Auto Header Detection**: Automatically detect header rows
- **Merged Cell Handling**: Fill merged cells downward for accurate comparison

## Installation

```bash
pip install excel-diff2-mcp
```

## Usage

### Command Line

```bash
excel-diff2-mcp
```

### As MCP Tool

```python
from mcp.client.session import Session

async with Session() as session:
    result = await session.call(
        "compare_excel",
        file1="https://example.com/file1.xlsx",
        file2="https://example.com/file2.xlsx",
        compare_columns=["一级功能模块", "二级功能模块"],
        output_format="markdown",  # optional: "csv" (default) or "markdown"
    )
```

### compare_excel Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `file1` | str | Yes | First Excel file (URL or Base64 content) |
| `file2` | str | Yes | Second Excel file (URL or Base64 content) |
| `compare_columns` | list | Yes | Columns for hierarchical matching |
| `table_name1` | str | No | Display name for table 1 |
| `table_name2` | str | No | Display name for table 2 |
| `output_format` | str | No | Output format: `"csv"` (default) or `"markdown"` |

### compare_columns Formats

**Single array** (same columns for both tables):
```python
["一级功能模块", "二级功能模块"]
```

**Dual array** (different columns per table):
```python
[["一级功能模块", "二级功能模块"], ["一级功能点", "二级功能点"]]
```

## Output

### CSV Format

```csv
表1名称,,,,
一级功能模块,二级功能模块,描述,比对结果
模块A,子模块1,描述内容,一级、二级功能模块均在【表2】找到
模块B,子模块2,描述内容,一级功能模块在【表2】找到

表2名称,,,,
一级功能模块,二级功能模块,描述,比对结果
模块A,子模块1,描述内容,一级、二级功能模块均在【表1】找到
模块C,子模块3,描述内容,未在【表1】找到
```

### Markdown Format

```markdown
## 表1名称

| 一级功能模块 | 二级功能模块 | 描述 | 比对结果 |
| --- | --- | --- | --- |
| 模块A | 子模块1 | 描述内容 | 一级、二级功能模块均在【表2】找到 |
| 模块B | 子模块2 | 描述内容 | 一级功能模块在【表2】找到 |

## 表2名称

| 一级功能模块 | 二级功能模块 | 描述 | 比对结果 |
| --- | --- | --- | --- |
| 模块A | 子模块1 | 描述内容 | 一级、二级功能模块均在【表1】找到 |
| 模块C | 子模块3 | 描述内容 | 未在【表1】找到 |
```

## Supported File Formats

- `.xlsx` - Excel 2007+ format
- `.xls` - Excel 97-2003 format
- `.csv` - Comma-separated values
- `.xlsm` - Excel macro-enabled format
- `.xlsb` - Excel binary format

## License

MIT