Wardrobe/MCP.md
jif2.zhang 38b5e3190a init: Wardrobe 衣物管理系统 - 项目首页、OTA 升级、Android CI/CD
- 响应式项目首页 (Landing, 含 R2 APK 下载) + 路由 /home 调整
- OTA 升级: tauri-plugin-hotswap (lib.rs/main.rs 拆分, 客户端热替换)
- OTA 服务端 (check/bundle/manifest-web) + build-ota/genkey/upload 脚本
- 密钥/凭据统一存配置中心 (signing + ota + cloudflare 分组)
- Android CI (android-* 分支) + OTA CI (手动触发), 产物上传 R2
- 修复 tsc/构建阻塞问题
2026-09-11 15:46:42 +08:00

128 lines
3.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Wardrobe MCP 服务说明
MCP (Model Context Protocol) 服务提供衣物管理平台数据管理接口,供 AI 助手、外部系统进行数据 CRUD 操作。
## 架构
```
┌─────────────┐ IPC (Tauri invoke) ┌──────────────┐
│ Web 前端 │ ───────────────────────▶ │ Rc MCP Service│
└─────────────┘ └──────┬───────┘
┌───────▼───────┐
│ DuckDB │
│ wardrobe.duckdb│
└───────────────┘
```
MCP 服务通过 Tauri 的 `mcp_list_tools` / `mcp_call_tool` 命令暴露,前端或其他 Tauri 插件可通过 `invoke` 调用。
## 可用工具列表
### 衣物管理
| 工具 | 描述 | 必需参数 |
|------|------|----------|
| `list_clothing` | 获取用户衣橱衣物列表 | `user_id`, 可选 `category` |
| `get_clothing` | 获取单品详情 | `id` |
| `add_clothing` | 添加衣物 | `user_id`, `name`, `category`, `color` |
| `update_clothing` | 更新衣物 | `id`, 可选 `name`/`category`/`color` |
| `delete_clothing` | 删除衣物 | `id` |
### 搭配管理
| 工具 | 描述 | 必需参数 |
|------|------|----------|
| `list_outfits` | 获取搭配列表 | `user_id` |
| `add_outfit` | 创建搭配方案 | `user_id`, `name`, `item_ids[]` |
### 穿搭记录
| 工具 | 描述 | 必需参数 |
|------|------|----------|
| `record_daily_outfit` | 记录每日穿搭 | `user_id`, `date` (YYYY-MM-DD) |
| `list_daily_records` | 获取穿搭日历 | `user_id`, 可选 `limit` |
### 统计
| 工具 | 描述 | 必需参数 |
|------|------|----------|
| `get_wardrobe_stats` | 衣橱统计数据 | `user_id` |
## 调用示例
### 列出用户衣物
```json
{
"tool_name": "list_clothing",
"args": { "user_id": "uuid-xxx", "category": "top" }
}
```
### 添加衣物
```json
{
"tool_name": "add_clothing",
"args": {
"user_id": "uuid-xxx",
"name": "白色衬衫",
"category": "top",
"color": "#FFFFFF",
"brand": "优衣库",
"seasons": ["春", "夏"],
"occasions": ["通勤"]
}
}
```
### 获取统计
```json
{
"tool_name": "get_wardrobe_stats",
"args": { "user_id": "uuid-xxx" }
}
```
返回:
```json
{
"total_items": 42,
"total_outfits": 15,
"utilization_rate": 73.0,
"category_counts": { "top": 12, "bottom": 8, "outer": 6, "dress": 5, "shoes": 6, "accessory": 5 },
"favorite_count": 3,
"unworn_30d": 2,
"needs_cleaning": 2
}
```
## 整合到 AI 客户端配置
在 AI 客户端 (如 Claude, Cursor) 的 MCP 配置中添加:
```json
{
"mcpServers": {
"wardrobe": {
"command": "npx",
"args": ["-y", "@wardrobe/mcp-server"],
"env": { "WARDROBE_DB_PATH": "path/to/wardrobe.duckdb" }
}
}
}
```
> 注: 当前版本 MCP 通过 Tauri IPC 暴露AI 客户端集成需将 `McpService` 包装为标准 MCP stdio server。`src-tauri/src/mcp.rs` 中 `list_tools` / `call_tool` 已实现会话无关的纯逻辑接口,可直接复用。
## 认证
验证码暂统一为 `1111`。注册/登录流程:
1. `send_code(target)` - 发送验证码 (target 为邮箱或手机号)
2. `register(email|null, phone|null, code, nickname)` - 注册
3. `login(email|null, phone|null, code)` - 登录
验证码有效期 5 分钟,成功后自动失效。