Content
# Tomato Novel MCP
The MCP service for Tomato Novel writer backend: **Multi-novel management · Reading data analysis · Chapter publishing/scheduled publishing**.
Directly calls the real HTTP interface of Tomato writer backend (Cookie authentication, no browser, no wind control signature reverse), which is more stable and reliable compared to the early Puppeteer solution.
## Tool List
| Tool | Function |
|------|----------|
| `list_novels` | List all novels under the account (book_id, book name, word count, reading count, serialization status) |
| `switch_novel` | Switch to the current novel (used for multiple novels) |
| `get_current_novel` | View the currently selected novel |
| `get_novel_stats` | Reading data: book-level overview + chapter read completion rate/tracking rate/word count |
| `list_chapters` | List chapters of each volume (including scheduled to be published / published status) |
| `publish_chapter` | Publish/schedule to publish a chapter (directly transmit content, or extract from Markdown draft by chapter number) |
## Configuration
Copy `.env.example` to `.env`, and fill in the authentication information for Tomato writer backend:
```
TOMATO_COOKIE=... # Complete Cookie header for any /api/author request after login
TOMATO_CSRF_TOKEN=... # X-Secsdk-Csrf-Token in the same request header (session-level fixed)
```
Acquisition method: Log in to <https://fanqienovel.com> writer backend → F12 → Network → Choose any `/api/author/...` request → Copy its `Cookie` and `X-Secsdk-Csrf-Token`. Cookie has an expiration period (about one or two months), and can be updated after expiration.
## Build and Access
```bash
pnpm install
pnpm build
```
Add the following configuration to the MCP configuration in the client that supports MCP (Claude Code / Claude Desktop / Cursor, etc.):
```json
{
"mcpServers": {
"tomato-writer-mcp": {
"command": "node",
"args": ["/absolute/path/tomato-writer-mcp/dist/index.js"],
"env": {
"TOMATO_COOKIE": "...",
"TOMATO_CSRF_TOKEN": "..."
}
}
}
}
```
(If `.env` is already configured, the `env` field can be omitted.)
## Usage Examples
- “List my novels” → `list_novels`
- “Switch to 《Rebirth: From Plundering the Son of Destiny》” → `switch_novel`
- “Check the reading data of this book” → `get_novel_stats`
- “Schedule chapter 19 of `/path/正文_第11-20章.md` to be published on 2026-06-20 15:00” → `publish_chapter`
## Project Structure
```
src/
├── index.ts # MCP entry, register tools
├── tomato/
│ ├── client.ts # HTTP client (Cookie + CSRF, unified GET/POST, code≠0 error)
│ ├── config.ts # Authentication loading + current novel state (data/state.json)
│ ├── content.ts # Convert text to <p> HTML / extract specified chapter from Markdown
│ └── service.ts # Business encapsulation (novel list / data / draft creation / publishing)
└── tools/
├── novels.ts # list_novels / switch_novel / get_current_novel
├── stats.ts # get_novel_stats / list_chapters
└── publishing.ts # publish_chapter
```
## Instructions
- Scheduled publishing: If `publish_time` is set to a future time, the chapter will be automatically published by Tomato server at that time, and no local resident is required; successful scheduling does not guarantee passing the review, and Tomato will still conduct content review during formal publishing.
- Please comply with Tomato platform rules and content compliance requirements.
## License
MIT