Content
# Xiaohongshu Content Auto-Generation and Publishing System
中文 | [English](README_EN.md)
An AI-powered intelligent Xiaohongshu content generation and automatic publishing web application that integrates multiple tool services through MCP (Model Context Protocol) to achieve a fully automated process from topic input to content publishing.
Simply put: Enter a topic and let AI handle everything for you, directly publishing to your Xiaohongshu account.
System main interface:




## ✨ Features
- 🎨 **Modern Web Interface** - Clean and beautiful left-right layout, responsive design
- ⚙️ **Configuration Management** - All configurations are entered through the web interface and automatically saved to the configuration file
- 🔌 **MCP Service Integration** - Integrates Jina search, Tavily search, and Xiaohongshu publishing three major MCP services
- 🤖 **Intelligent Content Generation** - Automatically retrieves information, analyzes and organizes, and writes articles based on user topics
- 📝 **Automatic Formatting** - Automatically adapts to Xiaohongshu publishing format (title, body, tags, images)
- 🚀 **One-Click Publishing** - Automatically publishes to the Xiaohongshu platform after generation
- 📊 **Real-Time Progress** - Displays execution progress and status information
- ✅ **Result Display** - Displays the final published title, content, tags, images, and other information
- 🔥 **Hot Topic Recommendation** - Automatically obtains today's hot news and intelligently extracts topics for selection
- 🎯 **Batch Generation and Publishing** - Supports batch selection of multiple topics, one-click batch generation and publishing
- 🌐 **URL Content Extraction** - Supports entering web links, automatically crawls and extracts topic content
- 🏷️ **Quick Field Filtering** - Provides quick filter buttons for fields such as AI, financing, papers, and robots
**Advertisement**
This is my own account, all articles are written by this project

[Personal Homepage](https://www.xiaohongshu.com/user/profile/60857eed0000000001008826) Welcome to view, click to follow, and take you to get first-hand AI resources
## 📋 Prerequisites
### 1. Start Xiaohongshu MCP Service
**You must first start the [xiaohongshu-mcp](https://github.com/xpzouying/xiaohongshu-mcp) service**
```bash
# 1. Clone the Xiaohongshu MCP project
git clone https://github.com/xpzouying/xiaohongshu-mcp.git
cd xiaohongshu-mcp
# 2. Start the service according to the instructions in the project README
# Default service address: http://localhost:18060/mcp
```
⚠️Note: You must first log in to your Xiaohongshu account (log in according to the method in this mcp service)
### 2. System Environment
- Python 3.8+
- Node.js 16+ (for MCP tools)
- npm/npx (for running MCP tools)
## 🚀 Quick Start
### 1. Install Dependencies
```bash
cd xhs_web_app
pip install -r requirements.txt
```
### 2. Start Application
```bash
python app.py
```
The application starts at `http://localhost:8080` by default.
### 3. Configure System
Visit `http://localhost:8080` and configure the following information in the left panel:
#### Required Configuration
| Configuration Item | Description | Example |
|--------|------|------|
| **LLM API Key** | OpenAI compatible API key | `sk-xxx...` |
| **OpenAI Base URL** | API base address | `https://api.openai.com/v1` or `https://usw.sealos.io/v1` |
| **Default Model** | LLM model used | `claude-sonnet-4-20250514` (recommended) |
| **Xiaohongshu MCP Service Address** | MCP service URL | `http://localhost:18060/mcp` |
#### Optional Configuration (must choose one)
| Configuration Item | Description | How to Obtain |
|--------|------|----------|
| **Jina API Key** | Jina search service key | [Jina Official Website](https://jina.ai/) |
| **Tavily API Key** | Tavily search service key | [Tavily Official Website](https://tavily.com/) |
It is recommended to use Tavily as a search tool, which can be used for 1000 free search requests per month
> 💡 **Tip**: Click the "Get Key" or "View Documentation" link next to the configuration item to directly jump to the corresponding service website.
### 4. Generate Content
The system adopts a brand-new immersive dual-view design:
#### Method 1: Creation Center (Home View)
This is the system's default view, focusing on in-depth creation of a single topic.
1. **Enter Topic**: In the input box below "What will you create today?" in the center of the screen, enter the topic you want to create.
2. **Start Generation**: Click the "✨ Generate" button on the right.
3. **Real-Time Status**:
- The "Current Task Status Card" will automatically pop up below the input box.
- You can see the steps that AI is performing (Retrieve Information -> Write Article -> Format Adaptation -> Automatic Publishing).
- The progress bar will be updated in real time to show the current execution percentage.
**Topic Example:**
- "Analysis of the Generative AI Priority Paradox"

#### Method 2: Hotspot Discovery (Trending View)
Click the "🔥 Hotspot" icon in the left sidebar to enter this view, which is suitable for finding inspiration and batch production.
##### 1. Get Hotspots by Field
At the top of the page, click the glass-morphic field tag to quickly get popular topics in that field:
- 🤖 **AI** - Cutting-edge trends in artificial intelligence and large models
- 💰 **Financing** - Latest financing news in the venture capital circle
- 📄 **Papers** - Latest research results in the academic community
- 🦾 **Robots** - Embodied intelligence and automation technology
##### 2. Extract from Web Links
If you have a specific article link:
1. Paste the URL in the "Or paste a web link to extract the topic..." input box.
2. Click the "Extract" button, and the system will intelligently analyze the web content and extract the core topic.
##### 3. Batch Generation and Publishing
After getting the topic card:
1. **Select Topic**: Click the topic card you are interested in (the card will be highlighted and a ✓ mark will appear).
2. **Select All Function**: Click the "✓ Select All" button above the list to select all current topics with one click.
3. **Batch Execution**:
- The "Batch Operation Bar" will automatically float at the bottom, showing the number of selected items.
- Click the "🚀 Batch Generate Selected Topics" button.
- The system will automatically create a task queue and process the generation and publishing of each topic in sequence.
#### Task History and Management
Click the "📝 History" icon in the left sidebar to open the history record modal box:
- **View Details**: Click the "View" button of any task to preview the complete Xiaohongshu copy (title, body, tags) and images generated.
- **Status Filtering**: Use the segmented controller at the top (All/Success/Failure) to quickly filter task statuses.
## 📂 Project Structure
```
xhs_web_app/
├── app.py # FastAPI main program
├── requirements.txt # Python dependencies
├── README.md # This document
│
├── config/ # Configuration module
│ ├── __init__.py
│ ├── config_manager.py # Configuration manager
│ ├── app_config.json # Application configuration (automatically generated)
│ ├── servers_config.json # MCP service configuration (automatically generated)
│ └── .env # Environment variables (automatically generated)
│
├── core/ # Core function module
│ ├── __init__.py
│ ├── content_generator.py # Content generator (based on MCP tool execution)
│ └── xhs_llm_client.py # MCP client and LLM interaction
│
├── cache/ # Cache module
│ ├── __init__.py
│ ├── cache_manager.py # Task history cache management
│ └── task_history.json # Task history record (automatically generated)
│
├── static/ # Static resources
│ ├── css/
│ │ └── style.css # Style file
│ └── js/
│ └── app.js # Front-end interaction logic
│
└── templates/ # HTML template
└── index.html # Main page
```
## 🔧 Configuration File Description
### 1. app_config.json
Stores the main configuration information of the application:
```json
{
"llm_api_key": "sk-xxx...",
"openai_base_url": "https://api.openai.com/v1",
"default_model": "claude-sonnet-4-20250514",
"jina_api_key": "jina_xxx...",
"tavily_api_key": "tvly_xxx...",
"xhs_mcp_url": "http://localhost:18060/mcp"
}
```
### 2. servers_config.json
MCP server configuration (automatically generated according to app_config.json):
```json
{
"mcpServers": {
"jina-mcp-tools": {
"command": "npx",
"args": ["jina-mcp-tools"],
"env": {
"JINA_API_KEY": "jina_xxx..."
}
},
"tavily-remote": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.tavily.com/mcp/?tavilyApiKey=tvly_xxx..."]
},
"xhs": {
"type": "streamable_http",
"url": "http://localhost:18060/mcp"
}
}
}
```
## 🎯 Content Generation Process
The system uses a 4-step process to automatically generate and publish content:
### Step 1: Information Retrieval
- Use Jina or Tavily search tools
- Retrieve relevant information from the latest 7-30 days
- Collect 5-8 high-quality materials
- Get 3-4 related pictures
### Step 2: Write Article
- Write a professional article based on the collected information
- The title is controlled within 20 characters
- The body is 800-1200 words
- Use a youthful and lively language style
- Add appropriate emojis to increase interest
### Step 3: Format Adaptation
- Adjust to Xiaohongshu special format
- Remove # tags and replace them with natural language
- Extract 5 accurate topic tags
- Verify the validity of image links
- Generate standard JSON format
### Step 4: Automatic Publishing
- Call Xiaohongshu MCP service
- Publish content to Xiaohongshu platform
- Return publishing results
- **Automatically stop iteration after detecting successful publishing**
## 🌐 API Endpoints
| Method | Path | Description |
|------|------|------|
| GET | `/` | Main page |
| GET | `/api/config` | Get configuration (hide sensitive information) |
| POST | `/api/config` | Save configuration |
| POST | `/api/validate-model` | Verify whether the LLM model is available |
| POST | `/api/test-login` | Test Xiaohongshu MCP connection |
| POST | `/api/generate-and-publish` | Generate and publish a single topic |
| POST | `/api/fetch-trending-topics` | Get today's hot topics (support field filtering) |
| POST | `/api/fetch-topics-from-url` | Crawl and extract topics from URL |
| POST | `/api/batch-generate-and-publish` | Batch generate and publish multiple topics |
| GET | `/api/history` | Get task history records |
| DELETE | `/api/history/{task_id}` | Delete the specified task record |
| GET | `/api/history/statistics` | Get task statistics |
## 🛠️ Technology Stack
### Backend
- **FastAPI** - Modern web framework
- **MCP (Model Context Protocol)** - Tool service integration
- **OpenAI SDK** - LLM API call
- **aiohttp** - Asynchronous HTTP client
### Frontend
- **Native HTML/CSS/JavaScript** - Lightweight, no build required
- **Element UI Style** - Simple and beautiful UI design
- **Responsive Layout** - Support desktop and mobile
### MCP Tool Service
- **Jina MCP Tools** - Web search and content crawling
- **Tavily Remote** - Deep web search
- **XHS MCP** - Xiaohongshu content publishing
## 📝 License
This project is for learning and research purposes only. When using this project, please abide by:
- OpenAI API Terms of Use
- Xiaohongshu Platform Rules
- Usage agreements of each MCP service provider
## 🔗 Related Links
- [Xiaohongshu MCP Service](https://github.com/xpzouying/xiaohongshu-mcp) - Required dependency service
- [Sealos API Platform](https://usw.sealos.io/) - Get LLM API key
- [Jina AI](https://jina.ai/) - Get Jina API key
- [Tavily](https://tavily.com/) - Get Tavily API key
## 📧 Support and Feedback
If you have any questions or suggestions, please feel free to:
- Submit Issue
- Initiate Pull Request
- Contact the project maintainer
## ⚠️ Write at the end
This project can be used as a learning case for agents, but it is not recommended to be directly used in a production environment.
The logic of the overall project is abstracting a more general agent architecture:
- Configurable mcp
- Different tools can be selected to complete complex tasks
- Agent's context retrieval and compression
- Agent's multi-turn dialogue and memory
- .....
---
** Welcome star Happy Creating! 🎉**
Connection Info
You Might Also Like
markitdown
Python tool for converting files and office documents to Markdown.
Fetch
Retrieve and process content from web pages by converting HTML into markdown format.
chatbox
User-friendly Desktop Client App for AI Models/LLMs (GPT, Claude, Gemini, Ollama...)
oh-my-opencode
Background agents · Curated agents like oracle, librarians, frontend...
continue
Continue is an open-source project for seamless server management.
semantic-kernel
Build and deploy intelligent AI agents with Semantic Kernel's orchestration...