This MCP server for Xiaohongshu (Little Red Book) allows you to automate searching for content and posting comments through a Model Context Protocol interface. It can be connected to MCP clients like Claude for Desktop to perform actions such as logging in, searching for notes, retrieving content, and posting intelligent comments.
git clone https://github.com/username/RedBook-Search-Comment-MCP.git
cd RedBook-Search-Comment-MCP
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
pip install -r requirements.txt
pip install fastmcp
playwright install
To set up the MCP server with an MCP client (like Claude for Desktop), add the following configuration to your MCP client:
{
"mcpServers": {
"xiaohongshu MCP": {
"command": "/absolute/path/to/venv/bin/python3",
"args": [
"/absolute/path/to/xiaohongshu_mcp.py",
"--stdio"
]
}
}
}
Important:
/Users/username/Desktop/RedBook-Search-Comment-MCP/venv/bin/python3
xiaohongshu_mcp.py
fileYou can start the server in two ways:
python3 xiaohongshu_mcp.py
Function:
mcp0_login()
Usage in MCP client:
帮我登录小红书账号
or
请登录小红书
Description: Opens a browser window for the first login, requiring you to scan the QR code. The login status is saved for future sessions.
Function:
mcp0_search_notes(keywords="keyword", limit=5)
Usage in MCP client:
帮我搜索小红书笔记,关键词为:美食
or with specified result count:
帮我搜索小红书笔记,关键词为旅游,返回10条结果
Description: Searches for Xiaohongshu notes based on keywords and returns a specified number of results (default is 5).
Function:
mcp0_get_note_content(url="note_url")
Usage in MCP client:
帮我获取这个笔记的内容:https://www.xiaohongshu.com/search_result/xxxx
or
请查看这个小红书笔记的内容:https://www.xiaohongshu.com/search_result/xxxx
Description: Retrieves detailed content of a specified note, including title, author, publication time, and text.
Function:
mcp0_get_note_comments(url="note_url")
Usage in MCP client:
帮我获取这个笔记的评论:https://www.xiaohongshu.com/search_result/xxxx
or
请查看这个小红书笔记的评论区:https://www.xiaohongshu.com/search_result/xxxx
Description: Retrieves comments from a specified note, including commenter information, content, and time.
Function:
mcp0_post_smart_comment(url="note_url", comment_type="comment_type")
Usage in MCP client:
帮我在这个笔记发布专业类型的评论:https://www.xiaohongshu.com/search_result/xxxx
or
请在这个小红书笔记下发布一条引流评论:https://www.xiaohongshu.com/search_result/xxxx
Available comment types:
"引流"
(default): Guides users to follow or privately message"点赞"
: Simple interaction to gain goodwill"咨询"
: Uses questions to increase interaction"专业"
: Shows professional knowledge to establish authorityDescription: Posts an intelligent comment on a specified note, automatically generating appropriate content based on the note and the specified comment type.
If you encounter Page.goto: Target page, context or browser has been closed
error:
If you encounter ModuleNotFoundError
:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "xiaohongshu-MCP" '{"command":"/\u7edd\u5bf9\u8def\u5f84/\u5230/venv/bin/python3","args":["/\u7edd\u5bf9\u8def\u5f84/\u5230/xiaohongshu_mcp.py","--stdio"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"xiaohongshu MCP": {
"command": "/\u7edd\u5bf9\u8def\u5f84/\u5230/venv/bin/python3",
"args": [
"/\u7edd\u5bf9\u8def\u5f84/\u5230/xiaohongshu_mcp.py",
"--stdio"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"xiaohongshu MCP": {
"command": "/\u7edd\u5bf9\u8def\u5f84/\u5230/venv/bin/python3",
"args": [
"/\u7edd\u5bf9\u8def\u5f84/\u5230/xiaohongshu_mcp.py",
"--stdio"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect