✨ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more

UBOS Asset Marketplace: Xiaohongshu Automation with MCP Server

In today’s dynamic digital landscape, businesses are constantly seeking innovative methods to enhance their online presence and engage with target audiences effectively. The UBOS Asset Marketplace offers a robust solution in the form of an MCP (Model Context Protocol) Server designed for Xiaohongshu, a leading social media and e-commerce platform in China. This tool leverages the power of automation and AI to streamline marketing efforts, allowing users to efficiently search, analyze, and interact with content on Xiaohongshu.

What is an MCP Server?

Before diving into the specifics of the Xiaohongshu MCP Server, it’s essential to understand the core concept of MCP. Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to Large Language Models (LLMs). An MCP Server acts as a bridge, enabling AI models to access and interact with external data sources and tools. This interaction allows for more informed and contextually relevant AI-driven actions.

Introducing the Xiaohongshu MCP Server

The Xiaohongshu MCP Server is a powerful tool built on Playwright, a reliable framework for automating browser interactions. It is designed to connect with an MCP Client (such as Claude for Desktop) to automate tasks on Xiaohongshu, including:

  • Automated Login: Streamlines the login process, saving time and effort.
  • Keyword Search: Enables efficient searching for specific content based on keywords.
  • Content Extraction: Facilitates the extraction of detailed information from Xiaohongshu notes.
  • Intelligent Commenting: Supports the generation and posting of AI-driven comments to enhance engagement.

This server is specifically designed to optimize and improve upon existing tools like RednoteMCP, incorporating user feedback and practical experience to deliver a more refined and effective solution.

Use Cases

The Xiaohongshu MCP Server offers a versatile range of use cases for businesses and individuals looking to leverage the platform for marketing, research, and engagement:

  • Market Research: Automate the process of gathering data on trending topics, competitor activities, and customer sentiments. This allows businesses to stay ahead of the curve and make data-driven decisions.
  • Content Promotion: Enhance the visibility of your content by strategically engaging with relevant posts through intelligent commenting and interaction. This can drive traffic and increase brand awareness.
  • Customer Engagement: Foster meaningful interactions with potential customers by providing helpful information, answering questions, and addressing concerns through automated commenting.
  • Lead Generation: Identify and engage with potential leads by monitoring relevant discussions and offering tailored solutions or information.
  • Brand Building: Establish a strong brand presence on Xiaohongshu by consistently engaging with the community, sharing valuable insights, and participating in relevant conversations.

Key Features

The Xiaohongshu MCP Server boasts a comprehensive suite of features designed to maximize efficiency and effectiveness:

  • Automated Login:
    • Supports manual QR code login for initial setup.
    • Saves login status for subsequent sessions, eliminating the need for repeated logins.
  • Keyword Search:
    • Enables users to search for Xiaohongshu notes based on specific keywords.
    • Allows users to specify the number of results to be returned.
  • Note Content Extraction:
    • Extracts detailed content from Xiaohongshu notes using their URLs.
    • Provides information such as title, author, publication time, and content.
  • Note Comment Extraction:
    • Retrieves comments from Xiaohongshu notes using their URLs.
    • Provides information such as commenter, comment content, and comment time.
  • Intelligent Comment Posting:
    • Supports various comment types, including:
      • Lead Generation: Directing users to follow or message the account.
      • Positive Engagement: Expressing appreciation and building rapport.
      • Inquiry-Based Interaction: Posing questions to encourage engagement.
      • Expertise Demonstration: Showcasing knowledge and establishing authority.
    • Allows users to select the appropriate comment type based on their objectives.
  • Modular Design:
    • Features a modular architecture that separates note analysis, comment generation, and comment posting into independent modules.
    • This design enhances flexibility and allows for future enhancements and customizations.
  • AI-Powered Comment Generation:
    • Leverages the AI capabilities of MCP Clients (e.g., Claude) to generate natural and engaging comments.
    • Ensures that comments are contextually relevant and aligned with the tone of the conversation.

Installation and Configuration

Setting up the Xiaohongshu MCP Server involves a few straightforward steps:

  1. Python Environment Setup: Ensure that Python 3.8 or higher is installed on your system.

  2. Project Acquisition: Clone or download the project to your local machine.

  3. Virtual Environment Creation: Create and activate a virtual environment to isolate project dependencies. bash

    Create virtual environment

    python3 -m venv venv

    Activate virtual environment

    Windows

    venvScriptsactivate

    macOS/Linux

    source venv/bin/activate

  4. Dependency Installation: Install the required dependencies using pip: bash pip install -r requirements.txt pip install fastmcp

  5. Browser Installation: Install the necessary browsers for Playwright: bash playwright install

  6. MCP Server Configuration: Configure your MCP Client (e.g., Claude for Desktop) to recognize the Xiaohongshu MCP Server by adding the following to the client’s configuration file:

    { “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 and to the xiaohongshu_mcp.py file.

Usage

To start the server, you can either run the xiaohongshu_mcp.py file directly from the command line or launch it through your configured MCP Client.

Once the server is running, you can use the following functions via the MCP Client:

  1. Login to Xiaohongshu:
    • Function: mcp0_login()
    • Usage: Send “帮我登录小红书账号” or “请登录小红书” to the MCP Client.
    • Description: Opens a browser window for manual QR code login. Login status is saved for future sessions.
  2. Search for Notes:
    • Function: mcp0_search_notes(keywords="关键词", limit=5)
    • Usage: Send “帮我搜索小红书笔记,关键词为:美食” or “帮我搜索小红书笔记,关键词为旅游,返回10条结果” to the MCP Client.
    • Description: Searches for notes based on keywords and returns a specified number of results (default is 5).
  3. Get Note Content:
    • Function: mcp0_get_note_content(url="笔记URL")
    • Usage: Send “帮我获取这个笔记的内容:https://www.xiaohongshu.com/search_result/xxxx” or “请查看这个小红书笔记的内容:https://www.xiaohongshu.com/search_result/xxxx” to the MCP Client.
    • Description: Retrieves detailed content from a note using its URL.
  4. Get Note Comments:
    • Function: mcp0_get_note_comments(url="笔记URL")
    • Usage: Send “帮我获取这个笔记的评论:https://www.xiaohongshu.com/search_result/xxxx” or “请查看这个小红书笔记的评论区:https://www.xiaohongshu.com/search_result/xxxx” to the MCP Client.
    • Description: Retrieves comments from a note using its URL.
  5. Post Smart Comment:
    • Function: mcp0_post_smart_comment(url="笔记URL", comment_type="评论类型")
    • Usage: Send “帮我在这个笔记发布专业类型的评论:https://www.xiaohongshu.com/search_result/xxxx” or “请在这个小红书笔记下发布一条引流评论:https://www.xiaohongshu.com/search_result/xxxx” to the MCP Client.
    • Description: Posts an intelligent comment to a note based on the specified comment type. Comment types include “引流” (lead generation), “点赞” (positive engagement), “咨询” (inquiry-based interaction), and “专业” (expertise demonstration).

Code Structure

The project consists of the following key files:

  • xiaohongshu_mcp.py: The core file containing the code logic for login, search, content extraction, comment retrieval, and comment posting.
  • requirements.txt: A list of the project’s dependencies.

Common Issues and Solutions

  • Connection Failure:
    • Ensure that the correct Python interpreter path is used.
    • Verify that the MCP server is running.
    • Try restarting both the MCP server and client.
  • Browser Session Issues:
    • If you encounter a Page.goto: Target page, context or browser has been closed error, restart the MCP server and reconnect.
  • Dependency Installation Issues:
    • Ensure that all dependencies are installed in the virtual environment.
    • Check if the fastmcp package is installed.

Important Considerations

  • The tool runs in non-headless mode, meaning a real browser window will be opened during operation.
  • Initial login requires manual QR code scanning. Subsequent logins may not require scanning if the login state is valid.
  • Users must adhere to Xiaohongshu’s platform rules and avoid excessive or inappropriate actions.
  • Due to platform updates, the availability of search results and comment functionalities may vary. Stay updated with project updates.

UBOS Integration

The Xiaohongshu MCP Server seamlessly integrates with the UBOS platform, a full-stack AI Agent Development Platform. UBOS focuses on bringing AI Agents to every business department. Our platform helps you orchestrate AI Agents, connect them with your enterprise data, build custom AI Agents with your LLM model, and create Multi-Agent Systems. By leveraging UBOS, users can further enhance the capabilities of the Xiaohongshu MCP Server and create sophisticated AI-driven marketing strategies.

Disclaimer

This tool is intended for learning and research purposes only. Users are responsible for complying with all applicable laws and regulations, as well as Xiaohongshu’s platform rules. The developers of this project are not liable for any issues arising from improper use.

Conclusion

The Xiaohongshu MCP Server is a valuable asset for businesses and individuals looking to automate and enhance their presence on Xiaohongshu. With its comprehensive features, ease of use, and integration with the UBOS platform, it empowers users to streamline their marketing efforts, engage with their target audience effectively, and drive meaningful results.

Featured Templates

View More
AI Agents
AI Video Generator
252 2006 5.0
Data Analysis
Pharmacy Admin Panel
252 1957
Verified Icon
AI Assistants
Speech to Text
137 1881
AI Assistants
AI Chatbot Starter Kit v0.1
140 912

Start your free trial

Build your solution today. No credit card required.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.