- Home
- MCP servers
- Xiaohongshu
Xiaohongshu
- python
37
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"chenningling-redbook-search-comment-mcp": {
"command": "/绝对路径/到/venv/bin/python3",
"args": [
"/绝对路径/到/xiaohongshu_mcp.py",
"--stdio"
]
}
}
}You have a Server that automates Xiaohongshu search, note extraction, and smart comments using MCP Client workflows. It logs you in, searches notes by keyword, fetches note content and comments, and publishes AI-generated comments tailored to your goal. This guide shows you how to use it, install it, and configure it for your MCP Client setup.
How to use
Connect the Xiaohongshu MCP Server to your MCP Client (for example Claude for Desktop). Once connected, you can log in, search for notes by keyword, retrieve detailed note content, read and gather comments, and post smart comments that are generated based on the chosen type (Engagement, professional insights, or targeted prompts to encourage following or direct messaging). Use the client to send simple requests and let the server perform the underlying actions.
How to install
Prerequisites you need before installation: a system with Python 3.8 or newer, and internet access to install dependencies.
# 1) Ensure Python 3.8+
# 2) Clone or download the project to a local directory
# 3) Create and activate a virtual environment
python3 -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
# 4) Install dependencies
pip install -r requirements.txt
pip install fastmcp
# 5) Install Playwright browsers
playwright install
MCP Server configuration
Configure your MCP Client to connect to this server by adding the following MCP configuration. It uses a local Python runtime from your virtual environment and runs the Xiaohongshu MCP script with stdio mode.
{
"mcpServers": {
"xiaohongshu_mcp": {
"command": "/绝对路径/到/venv/bin/python3",
"args": [
"/绝对路径/到/xiaohongshu_mcp.py",
"--stdio"
]
}
}
}
Notes on usage and security
-
The server uses Playwright to launch a real browser window. During the first login, you will need to manually scan a QR code to authorize the session. After successful login, the session state is saved for subsequent uses.
-
Respect Xiaohongshu platform rules and avoid excessive actions that could risk account restrictions. If a change to the site prevents features from working, update the server accordingly.
Troubleshooting
-
If you encounter connection failures, ensure the virtual environment Python path is correct, the MCP server is running, and try restarting both the server and client.
-
If you see browser session issues such as Page.goto: Target page, context or browser has been closed, restart the MCP server and re-authenticate.
-
If dependencies fail to install, confirm you are in the virtual environment and that all required packages are installed (including fastmcp).
Supported actions and how to call them
-
Log in to Xiaohongshu with mcp0_login() (use in your MCP Client as: “请登录 Xiaohongshu” or “帮我登录 Xiaohongshu账号”). The initial login opens a browser for manual QR login, after which the state is saved.
-
Search notes with mcp0_search_notes(keywords, limit). Use your MCP Client to ask for searches, e.g.: “帮我搜索小红书笔记,关键词为:美食” or “...,返回10条结果”.
-
Get note content with mcp0_get_note_content(url). Call it by providing the note URL, e.g.: “帮我获取这个笔记的内容:https://www.xiaohongshu.com/search\_result/xxxx”.
-
Get note comments with mcp0_get_note_comments(url). Call it with the note URL to fetch comments.
-
Post smart comments with mcp0_post_smart_comment(url, comment_type). Choose the type: 引流 (default), 点赞, 咨询, 专业. Example: “帮我在这个笔记发布专业类型的评论:https://www.xiaohongshu.com/search\_result/xxxx”.
Code structure and tools
The server core is implemented in xiaohongshu_mcp.py, which encapsulates login, search, content retrieval, comments, and smart comment posting logic. The project includes a requirements.txt listing needed dependencies.
What you will need from this guide
-
A working Python environment with venv support and the ability to install packages.
-
Access to a MCP Client to issue the commands and receive results.
Available tools
mcp0_login
Logs into Xiaohongshu by opening a browser window for manual QR login on first use; stores session state for subsequent uses.
mcp0_search_notes
Search Xiaohongshu notes by keywords and return a configurable number of results.
mcp0_get_note_content
Fetches the full content of a specified note URL, including title, author, time, and body.
mcp0_get_note_comments
Retrieves comments for a specified note URL, including commenter, content, and timestamp.
mcp0_post_smart_comment
Generates and posts an intelligent comment on a note based on the selected type (引流, 点赞, 咨询, 专业).