Metadata-Version: 2.4
Name: erp-property-mcp
Version: 1.0.0
Summary: 鼎尖 ERP 房源 MCP：日同步 SQLite 缓存、图片查询、历史成交
License: Proprietary
Project-URL: Homepage, https://open.workbuddy.cn/docs/connector
Project-URL: Documentation, https://open.workbuddy.cn/docs/connector
Keywords: mcp,dingjian,erp,real-estate,stdio,uvx
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: mcp>=1.2.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.0
Requires-Dist: pydantic-settings>=2.0
Requires-Dist: python-dotenv>=1.0.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.24; extra == "dev"

# ERP 房源 MCP（Python / uvx）

鼎尖 ERP **第三方签名鉴权**，同步在售房源 + 近 3 年成交到本地 SQLite，并提供图片与成交查询。

## 安装与运行

### 开发

```bash
cd mcp/erp-property-mcp
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
cp -n .env.example .env
# 编辑 .env 填入 ERP_*
python -m erp_property_mcp
```

### 用户侧（推荐 uvx）

先发布到 PyPI，再：

```bash
uvx erp-property-mcp
```

## 发布到 PyPI

```bash
pip install -U build twine
python -m build
twine upload dist/*
```

包名：`erp-property-mcp`（与 `uvx erp-property-mcp` / console script 一致）。

## MCP Tools

| Tool | 说明 |
|------|------|
| `sync_erp_listings` | 全量同步在售房源 + 近3年成交；`force` 强制重拉 |
| `get_erp_listing_sync_status` | 当日/最近同步日志（含成交） |
| `search_erp_listings` | 查本地在售库（默认 auto_sync） |
| `get_erp_listing_status_counts` | 远程 listStatus 计数 |
| `get_erp_listing_images` | 按房源 ID/编号查图片（报告插图） |
| `search_erp_deals` | 按小区查本地历史成交（房号已脱敏） |

## 鉴权说明

环境变量：

| 变量 | 对应第三方参数 | 说明 |
|------|----------------|------|
| `ERP_BASE_URL` | - | 如 `https://p.dingjianyun.com/dingjian/` |
| `ERP_SECRET` | secret | 第三方 secret |
| `ERP_CU_ID` | thirdCuId | 控制单元 |
| `ERP_USER_ID` | thirdUserId | 用户 |
| `ERP_DC` | thirdDc | 数据中心 |

签名步骤：

1. 将 `secret, thirdtimestamp, thirdCuId, thirdUserId, thirdDc, apiPath` **字典序排序**后拼接
2. 做 **SHA1 hex**，写入请求头 `djthirdsign`
3. `apiPath` 不含 host 与 query（如 `broker/roomListing/listStatus`）
4. URL 仅带 `?djrqformat=pcjson`，**无需 Bearer Token**

## 测试

```bash
pytest
```
