Xiaohongshu Search and Comment MCP server

Enables AI to search and analyze content from Xiaohongshu (Little Red Book) social media platform through web scraping, providing access to comments and search results for market research and trend analysis in the Chinese consumer market.
Back to servers
Setup instructions
Provider
Chen Ningling
Release date
Apr 22, 2025
Language
Python
Stats
16 stars

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.

Installation

Prerequisites

  • Python 3.8 or higher
  • Git (optional, for cloning the repository)

Step-by-Step Installation

  1. Clone or download the project to your local machine:
git clone https://github.com/username/RedBook-Search-Comment-MCP.git
cd RedBook-Search-Comment-MCP
  1. Create and activate a virtual environment:
# Create virtual environment
python3 -m venv venv

# Activate virtual environment
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
  1. Install the required dependencies:
pip install -r requirements.txt
pip install fastmcp
  1. Install the necessary browsers for Playwright:
playwright install

Configuration

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:

  • Use the full absolute path to the Python interpreter in your virtual environment
  • Example: /Users/username/Desktop/RedBook-Search-Comment-MCP/venv/bin/python3
  • Similarly, use the full absolute path to the xiaohongshu_mcp.py file

Usage

Starting the Server

You can start the server in two ways:

  1. Direct execution:
python3 xiaohongshu_mcp.py
  1. Through an MCP client: Configure your MCP client and follow its connection procedures.

Available Functions

1. Login to Xiaohongshu

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.

2. Search for Notes

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).

3. Get Note Content

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.

4. Get Note Comments

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.

5. Post Smart Comments

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 authority

Description: Posts an intelligent comment on a specified note, automatically generating appropriate content based on the note and the specified comment type.

Troubleshooting

Connection Problems

  • Ensure you're using the full absolute path to the Python interpreter in your virtual environment
  • Make sure the MCP server is running
  • Try restarting both the MCP server and client

Browser Session Issues

If you encounter Page.goto: Target page, context or browser has been closed error:

  • Restart the MCP server
  • Reconnect and log in again

Dependency Installation Issues

If you encounter ModuleNotFoundError:

  • Make sure all dependencies are installed in your virtual environment
  • Check that the fastmcp package is installed

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later