Skip to main content
Glama
README.md
# 🍅 Tomato Writer MCP (番茄小说作家后台 Model Context Protocol 服务)

[![MCP Version](https://img.shields.io/badge/MCP-1.0.0-red.svg)](https://modelcontextprotocol.io/)
[![Node Version](https://img.shields.io/badge/Node-%3E%3D18.0.0-green.svg)](https://nodejs.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

专门面向 AI 编程与 Agent 辅助创作的 **Model Context Protocol (MCP)** 服务,为各大 AI 客户端(Claude Desktop、Cursor、Cline、Antigravity、Trae 等)提供与**番茄免费小说作家后台**的无缝交互能力,实现小说作品查询、签约书架状态诊断、章节目录拉取与合规发布。

---

## 🌟 核心功能特性

* 📚 **作品书架管理 (`list_novels`)**:实时拉取当前账号名下签约与连载中的所有番茄作品基本信息、作品 ID、总字数与更新状态。
* 📖 **章节列表与字数统计 (`list_chapters`)**:支持分卷与分章节拉取,自动统计全书总章节数、草稿箱数量与在线发布状态。
* 🎯 **当前激活作品切换 (`switch_novel` / `get_current_novel`)**:在多部连载作品间无缝切换上下文焦点。
* 📊 **作品签约与连载数据看板 (`get_novel_stats`)**:获取作品最新日更字数、审稿状态与各项指标。
* 🚀 **章节合规发布与草稿暂存 (`publish_chapter`)**:支持将 AI 撰写的正文一键存入番茄草稿箱或提交正式发布,内置字数合规校验(≥1,000字 签约门槛校验)。

---

## 🛠️ 工具清单 (Tools Reference)

| MCP 工具名称 | 功能描述 | 核心输入参数 |
| :--- | :--- | :--- |
| `list_novels` | 获取当前作者名下的全部小说列表 | 无 |
| `switch_novel` | 切换当前 AI 操作的目标小说 | `book_id` (string) |
| `get_current_novel` | 获取当前正在操作的小说信息 | 无 |
| `get_novel_stats` | 获取当前小说的详细统计数据 | `book_id` (可选 string) |
| `list_chapters` | 获取目标小说的全部章节目录与状态 | `book_id` (可选 string), `need_content` (boolean) |
| `publish_chapter` | 向番茄后台提交章节(存草稿或发布) | `title`, `content`, `publish_type` ('draft' \| 'publish'), `book_id` |
| `get_login_qrcode` | 获取官方实时扫码登录二维码数据源 (Base64) | 无 |

---

## 🚀 快速安装与配置

### 1. 克隆与安装依赖

```bash
git clone https://github.com/ChaEunwooy/tomato-writer-mcp.git
cd tomato-writer-mcp
npm install
npm run build
```

### 2. 环境变量配置 (`.env`)

复制环境配置模板:
```bash
cp .env.example .env
```

在 `.env` 中填入您的番茄作家后台凭据:
```env
# 1) 登录 https://fanqienovel.com 作家后台
# 2) 按 F12 打开网络 (Network) 控制台,任选一个 /api/author/... 请求
# 3) 复制 Request Headers 中的 Cookie
TOMATO_COOKIE="sessionid=xxxxxx; passport_csrf_token=xxxxxx; ..."

# 4) 复制 Request Headers 中的 X-Secsdk-Csrf-Token
TOMATO_CSRF_TOKEN="0xxxxxxxxxxxxxxxxxxxx"

# 可选:默认操作的作品 ID
TOMATO_DEFAULT_BOOK_ID="7xxxxxxxxxxxxxxxx"
```

---

## 🔌 在各大 AI 工具中接入 MCP

### 1. Claude Desktop 配置 (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "tomato-writer": {
      "command": "node",
      "args": ["E:/tomato-writer-mcp/dist/index.js"],
      "env": {
        "TOMATO_COOKIE": "your_cookie_here",
        "TOMATO_CSRF_TOKEN": "your_csrf_token_here"
      }
    }
  }
}
```

### 2. Cursor / Cline / Antigravity 配置

在 MCP 配置文件中添加 stdio 启动指令:
```json
{
  "name": "tomato-writer",
  "command": "node",
  "args": ["E:/tomato-writer-mcp/dist/index.js"]
}
```

---

## ⚠️ 重要注意事项与安全规范

1. **🔒 隐私与凭证安全**:
   * 严禁将包含真实 `TOMATO_COOKIE` 的 `.env` 文件提交至任何公开 Git 仓库;
   * `.gitignore` 默认已排除 `.env` 及所有临时文件。
2. **🛡️ 平台发布合规**:
   * 番茄官方要求单章字数不得低于 **1,000 字**,否则平台将拦截签约作品更新;
   * 单日新建作品有严格频次配额,请合理安排连载发布节奏。
3. **⏳ Cookie 有效期维护**:
   * 字节跳动 SSO 登录态具备一定有效期,若工具提示 `未授权或Cookie已过期`,只需重新在网页端登录并更新 `.env` 中的 `TOMATO_COOKIE` 即可。

---

## 📄 开源许可证

本项目基于 [MIT License](LICENSE) 开源。

**作者:ChaEunwooy**

TDQS

A4.1/5.0

Scored across 7 tools

Disambiguation4/5

Most tools target distinct actions, but get_current_novel overlaps somewhat with list_novels, and get_novel_stats overlaps with list_chapters on chapter-level data. Descriptions are clear enough to resolve most ambiguity.

Naming Consistency5/5

All tool names follow a consistent snake_case verb_noun pattern: list_*, get_*, switch_*, publish_*. No mixed conventions or vague verbs.

Tool Count5/5

Seven tools is well-scoped for a novel publishing and stats workflow. Each tool covers a necessary step from authentication through novel selection, chapter listing, publishing, and data retrieval.

Completeness4/5

The core workflow is complete: login, choose novel, list chapters, publish, and fetch stats. Minor gaps exist for chapter detail/edit/delete operations and novel creation, but they are not essential to the stated publish-and-monitor purpose.

Maintenance

ActivityMaintained
ResponsivenessNo issues