Content
# Tool List (MCP Server)
> This project is based on [JonaFly/RednoteMCP](https://github.com/JonaFly/RednoteMCP.git) and optimized and improved according to my own experience (by windsurf). Thanks to the original author!
This is an automated search and comment tool for Xiaohongshu developed based on Playwright, which can be used as an MCP Server and connected to an MCP Client (such as Claude for Desktop) through specific configurations. It helps users automatically complete tasks such as logging in to Xiaohongshu, searching for keywords, obtaining note content, and publishing intelligent comments.
### Note: [Redbook-Search-Comment-MCP2.0](https://github.com/chenningling/Redbook-Search-Comment-MCP2.0) has been released! You can directly click to use it!
**The main optimizations in version 2.0 are as follows:**
- Optimized the issue where the title is not displayed when searching for notes
- Added multiple methods to obtain note content to ensure complete content retrieval
- Refactored the comment function to utilize the AI capabilities of MCP clients (such as Claude) to generate more natural comments
- Modularized the functions into three independent modules: note analysis, comment generation, and comment publication
## 1. Features
- **Automatic Login**: Supports manual QR code scanning login. After the first successful login, the login status will be saved, and subsequent uses do not require repeated scanning.
- **Keyword Search**: Can search for Xiaohongshu notes based on user-input keywords and specify the number of returned results.
- **Note Content Retrieval**: Input the URL of a note to obtain its detailed content.
- **Note Comment Retrieval**: Obtain comment information for a note through its URL.
- **Intelligent Comment Publishing**: Supports multiple comment types, including traffic guidance (guiding users to follow or private chat), likes (simple interaction to gain favor), inquiries (increasing interaction in the form of questions), and professional (displaying professional knowledge to establish authority). The type of comment to be published can be selected according to needs.
## 2. Installation Steps
1. **Python Environment Preparation**: Ensure that the system has Python 3.8 or a higher version installed. If not installed, download and install it from the Python official website.
2. **Project Acquisition**: Clone or download this project to your local machine.
3. **Create a Virtual Environment**: Create and activate a virtual environment (recommended) in the project directory:
```bash
# Create a virtual environment
python3 -m venv venv
# Activate the virtual environment
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
```
4. **Install Dependencies**: Install the required dependencies in the activated virtual environment:
```bash
pip install -r requirements.txt
pip install fastmcp
```
5. **Install Browser**: Install the browser required by Playwright:
```bash
playwright install
```
## 3. MCP Server Configuration
Add the following content to the configuration file of the MCP Client (such as Claude for Desktop) to configure this tool as an MCP Server:
```json
{
"mcpServers": {
"xiaohongshu MCP": {
"command": "/absolute/path/to/venv/bin/python3",
"args": [
"/absolute/path/to/xiaohongshu_mcp.py",
"--stdio"
]
}
}
}
```
> **Important Reminder**:
> - Use the **full absolute path** of the Python interpreter in the virtual environment
> - For example: `/Users/username/Desktop/RedBook-Search-Comment-MCP/venv/bin/python3`
> - Similarly, `xiaohongshu_mcp.py` also requires a **full absolute path**
## 4. Usage
### (1) Start the Server
1. **Direct Operation**: Activate the virtual environment in the project directory and execute:
```bash
python3 xiaohongshu_mcp.py
```
2. **Start through MCP Client**: After configuring the MCP Client, follow the client's operation process to start and connect.
### (2) Main Function Operations
After connecting to the server in the MCP Client (such as Claude for Desktop), you can use the following functions:
### 1. Login to Xiaohongshu
**Tool Function**:
```
mcp0_login()
```
**Usage in MCP Client**:
Directly send the following text:
```
Help me log in to my Xiaohongshu account
```
or:
```
Please log in to Xiaohongshu
```
**Function Description**: The first use will open a browser window, waiting for the user to manually scan the QR code to log in. After successful login, the tool will save the login status.
### 2. Search for Notes
**Tool Function**:
```
mcp0_search_notes(keywords="keywords", limit=5)
```
**Usage in MCP Client**:
Send a search request containing keywords:
```
Help me search for Xiaohongshu notes with the keyword: food
```
Specify the number of returned results:
```
Help me search for Xiaohongshu notes with the keyword: travel, and return 10 results
```
**Function Description**: Search for Xiaohongshu notes based on keywords and return a specified number of results. By default, return 5 results.
### 3. Obtain Note Content
**Tool Function**:
```
mcp0_get_note_content(url="note URL")
```
**Usage in MCP Client**:
Send a request containing the note URL:
```
Help me get the content of this note: https://www.xiaohongshu.com/search_result/xxxx
```
or:
```
Please view the content of this Xiaohongshu note: https://www.xiaohongshu.com/search_result/xxxx
```
**Function Description**: Obtain the detailed content of a specified note URL, including title, author, publication time, and text content.
### 4. Obtain Note Comments
**Tool Function**:
```
mcp0_get_note_comments(url="note URL")
```
**Usage in MCP Client**:
Send a comment request containing the note URL:
```
Help me get the comments for this note: https://www.xiaohongshu.com/search_result/xxxx
```
or:
```
Please view the comment section of this Xiaohongshu note: https://www.xiaohongshu.com/search_result/xxxx
```
**Function Description**: Obtain comment information for a specified note URL, including commenter, comment content, and comment time.
### 5. Publish Intelligent Comments
**Tool Function**:
```
mcp0_post_smart_comment(url="note URL", comment_type="comment type")
```
**Usage in MCP Client**:
Send a request containing the note URL and comment type:
```
Help me publish a professional-type comment on this note: https://www.xiaohongshu.com/search_result/xxxx
```
or:
```
Please publish a traffic-guidance comment under this Xiaohongshu note: https://www.xiaohongshu.com/search_result/xxxx
```
**Optional Values for Comment Type Parameters**:
- `"traffic guidance"` (default): Guide users to follow or private chat
- `"likes"`: Simple interaction to gain favor
- `"inquiries"`: Increase interaction in the form of questions
- `"professional"`: Display professional knowledge to establish authority
**Function Description**: Publish intelligent comments under a specified note. The system will automatically generate suitable comment content based on the note content and the specified comment type.
## 5. Code Structure
- **xiaohongshu_mcp.py**: The core file implementing main functions, containing code logic for login, search, content and comment retrieval, and comment publication.
- **requirements.txt**: Records the dependency libraries required by the project.
## 6. Common Issues and Solutions
1. **Connection Failure**:
- Ensure that the **full absolute path** of the Python interpreter in the virtual environment is used
- Ensure that the MCP server is running
- Try restarting the MCP server and client
2. **Browser Session Issues**:
If encountering the error `Page.goto: Target page, context or browser has been closed`:
- Restart the MCP server
- Reconnect and log in
3. **Dependency Installation Issues**:
If encountering `ModuleNotFoundError`:
- Ensure that all dependencies are installed in the virtual environment
- Check if the fastmcp package is installed
## 7. Precautions
- **Browser Mode**: The tool uses Playwright's non-headless mode to run, and a real browser window will be opened during operation.
- **Login Method**: The first login requires manual QR code scanning. If the login status is valid for subsequent uses, there is no need to scan the QR code again.
- **Platform Rules**: Please strictly comply with Xiaohongshu platform regulations during use and avoid excessive operations to prevent account risks such as bans.
- **Function Compatibility**: As the Xiaohongshu platform may update and adjust, the availability of search results and comment functions may be affected. If abnormalities occur, please pay attention to project updates or contact the developer.
## 8. Disclaimer
This tool is only for learning and research purposes. Users should strictly comply with relevant laws and regulations and Xiaohongshu platform regulations. The project developers do not assume any responsibility for any issues caused by improper use.
Connection Info
You Might Also Like
awesome-mcp-servers
A collection of MCP servers.
git
A Model Context Protocol server for Git automation and interaction.
cc-switch
All-in-One Assistant for Claude Code, Codex & Gemini CLI across platforms.
TrendRadar
TrendRadar: Your hotspot assistant for real news in just 30 seconds.
oh-my-opencode
Background agents · Curated agents like oracle, librarians, frontend...
Appwrite
Build like a team of hundreds