Content
# Xiaohongshu MCP Server
An automated Xiaohongshu server based on the Model Context Protocol (MCP), implemented through Selenium web automation technology to interact with the Xiaohongshu platform. This server provides functions such as searching for articles, viewing content, reading comments, and posting comments. You can use it to complete some functions such as Xiaohongshu traffic generation, popular article analysis, and comment sentiment analysis. If you like it, you can give this project a Star or submit a PR to add new features.
## Features
- 🔐 **Automatic Login Management**: Persistent session storage, saving login status
- 🔍 **Article Search**: Search for relevant articles based on keywords
- 📖 **Content View**: Read article content and comments
- 💬 **Comment Interaction**: Post comments under articles
- 🗂️ **Session Persistence**: Automatically save and load login status
- 🌐 **Web Automation**: Browser automation based on Selenium
## Future Development Plan
- Implement sending notes function
- Implement note collection and like function
- Implement follow function
## Environment Requirements
- Python 3.8+
- Chrome Browser
- ChromeDriver Driver
## Installation Steps
1. **Clone the project**:
```bash
git clone git@github.com:cjpnice/xiaohongshu_mcp.git
```
2. **Download and extract ChromeDriver**:
- Download the ChromeDriver corresponding to your local Chrome version from the [official website](https://chromedriver.chromium.org/)
- Extract it to the project root directory
3. **Install Python environment**:
- Create a virtual environment, it is recommended to use uv for management, and install dependencies
```bash
cd xiaohongshu_mcp
uv python pin 3.12
uv init --bare
uv venv
.venv\Scripts\activate # windows activation method
source .venv/bin/activate # MaxOS/Linux activation method
uv pip install -r requirements.txt
```
## Instructions for Use
### MCP Server Configuration
Set CHROME_DRIVER_PATH to the location of the ChromeDriver executable file
```json
{
"mcpServers": {
"xiaohongshu_mcp": {
"command": "uv",
"args": [
"--directory",
"/PATH/TO/PARENT/FOLDER/xiaohongshu_mcp",
"run",
"mcp_server.py"
],
"env": {
"CHROME_DRIVER_PATH": "/PATH/TO/PARENT/FOLDER/chromedriver/chromedriver.exe"
}
}
}
}
```
The server runs using the stdio transport protocol by default.
### Available Tools
#### 1. **login()**
Start the Xiaohongshu manual login process. Opens the browser and waits for the user to complete the login.
**Return Value:**
- `success`: Boolean value indicating whether the login was successful
- `message`: Status message
#### 2. **search_articles(keyword: str)**
Search for articles based on keywords.
**Parameters:**
- `keyword`: Search keyword
**Return Value:**
- `success`: Boolean value indicating whether the operation was successful
- `keyword`: The search keyword used
- `articles`: List of article objects, including:
- `title`: Article title
- `author`: Author's name
- `link`: Article link
- `like`: Number of likes
- `count`: Number of articles found
#### 3. **get_current_page_articles()**
Get the list of articles on the current page. Can be used in conjunction with the page scrolling function.
**Return Value:**
- Same format as `search_articles`
#### 4. **get_article_content(article_url: str)**
Get the content of the specified article.
**Parameters:**
- `article_url`: Article link
**Return Value:**
- `success`: Boolean value indicating whether the operation was successful
- `content`: Article text content
#### 5. **view_article_comments(article_url: str, limit: int = 20)**
Get the list of comments for the article.
**Parameters:**
- `article_url`: Article link
- `limit`: Maximum number of comments to retrieve (default: 20)
**Return Value:**
- `success`: Boolean value indicating whether the operation was successful
- `article_url`: Article link
- `comments`: List of comment objects, including:
- `username`: Commenter's username
- `content`: Comment content
- `count`: Number of comments retrieved
#### 6. **post_comment(article_url: str, comment_text: str)**
Post a comment under the article.
**Parameters:**
- `article_url`: Article link
- `comment_text`: Comment content
**Return Value:**
- `success`: Boolean value indicating whether the operation was successful
- `message`: Status message
- `comment`: The content of the posted comment
#### 7. **scroll()**
Scroll the current page to load more content.
**Return Value:**
- `success`: Boolean value indicating whether the operation was successful
- `message`: Status message
#### 8. **close_browser()**
Close the browser instance.
**Return Value:**
- `success`: Boolean value indicating whether the operation was successful
- `message`: Status message
## Important Reminders
1. **Manual Login Required**: When running the server for the first time, you need to manually complete the login process in the opened browser window.
2. **Note Frequency Limits**: Please pay attention to Xiaohongshu's frequency limits. The server includes reasonable delays between operations.
3. **Session Persistence**: The login session is saved locally and will be automatically restored in subsequent runs.
## Technical Support
If you encounter any problems, please:
1. Check the troubleshooting section
2. Check the environment configuration
3. Submit an Issue on GitHub
---
**Note: Please use this tool responsibly and comply with platform rules and relevant laws and regulations.**
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.
Claude-Code-AI-Design
Claude Design Anthropic Tool Download April 2026 Figma to Code AI Agent...
mcp-cli
save fork/exec overhead of AI code agent
numasec
AI agent for penetration testing. Like Claude Code, but for security. Open...