实现通知自动化闭环:SQLite任务状态、定时同步、未处理查询与回复状态回写;下线MCP对外未读通知工具

This commit is contained in:
2026-03-03 11:49:25 +08:00
parent d2d96de857
commit 237b528f08
10 changed files with 703 additions and 40 deletions
+10 -3
View File
@@ -6,10 +6,11 @@ Multi-platform social media automation service that exposes browser-based action
## Features
- **17 MCP tools** for Xiaohongshu (login, browsing, publishing, interactions, notifications)
- **17 MCP tools** for Xiaohongshu (login, browsing, publishing, interactions, notifications, automation)
- **REST API** with Bearer token authentication and per-route rate limiting
- **Browser automation** via `rebrowser-playwright` with per-platform serial queueing
- **Cookie persistence** with file-based storage (`0600`, atomic writes)
- **Notification task state** in SQLite (`$COOKIE_DIR/xiaohongshu/automation.db`) for idempotent auto-reply workflows
- **Web dashboard** (React + Vite) for login, feed exploration, publishing, and API testing
- **Security controls**: timing-safe token comparison, bind-address safety gate, error sanitization, log redaction
- **Docker deployment** support with hardened runtime defaults
@@ -102,7 +103,7 @@ Add this in `claude_desktop_config.json`:
| `xhs_reply_comment` | Reply to a comment |
| `xhs_like` | Toggle like state on a note |
| `xhs_favorite` | Toggle favorite state on a note |
| `xhs_get_comment_notifications` | Get unread comment/@ notifications |
| `xhs_get_unprocessed_notifications` | Get unprocessed notification tasks from local SQLite state |
| `xhs_reply_notification` | Reply to a specific notification |
## REST API
@@ -150,6 +151,7 @@ Read endpoints are limited to **60/min** per IP. Write endpoints are limited to
| `POST` | `/api/xhs/like` | Toggle like | 10/min |
| `POST` | `/api/xhs/favorite` | Toggle favorite | 10/min |
| `GET` | `/api/xhs/notifications/comments` | Get comment notifications | 60/min |
| `GET` | `/api/xhs/notifications/unprocessed` | Get unprocessed notification tasks from SQLite | 60/min |
| `POST` | `/api/xhs/notifications/reply` | Reply to notification | 10/min |
### Response Format
@@ -228,6 +230,9 @@ Note: Docker defaults expose port `3000` because container env sets `PORT=3000`.
| `COOKIE_DIR` | `~/.social-mcp` | Cookie/token storage directory |
| `MAX_QUEUE_DEPTH` | `10` | Max pending operations per platform queue |
| `ALLOW_REMOTE` | (unset) | Must be `yes-i-understand-the-risk` to allow public bind |
| `XHS_NOTIFICATION_POLL_ENABLED` | `true` | Enable periodic notification sync into SQLite |
| `XHS_NOTIFICATION_POLL_INTERVAL_SEC` | `60` | Notification sync interval (seconds, min 15) |
| `XHS_NOTIFICATION_POLL_MAX_COUNT` | `20` | Max notifications fetched per sync |
## Project Structure
@@ -264,7 +269,9 @@ social-mcp/
│ ├── publish-video.ts
│ ├── comment.ts
│ ├── interaction.ts
── notification.ts
── notification.ts
│ ├── notification-state.ts
│ └── notification-sync.ts
└── web/
└── src/
```