This tool acts as a friendly digital assistant for Xiaohongshu, one of the world's most popular social media and e-commerce platforms. In simple terms, it allows an AI assistant to browse the platform just like a human would—searching for specific topics, reading through posts, and keeping up with the latest trends. Instead of a user having to manually click through dozens of pages, this tool gathers all the information and presents it in a clear, easy-to-read format. On a more technical level, the tool is built using Playwright for robust browser automation and Python for seamless integration. It handles complex tasks like manual QR code login with session persistence, meaning it stays logged in for future sessions without constant re-authentication. It offers deep data extraction capabilities, pulling not just the text of a note, but also metadata like author details, timestamps, and full comment sections. This allows for a comprehensive analysis of the platform's content and community sentiment. For developers and AI enthusiasts, this MCP server is a powerful bridge between Large Language Models and real-world social data. It enables an AI to perform "Smart Commenting," where the model analyzes a post's context and chooses from different interaction styles—such as professional, inquisitive, or engagement-focused—to post natural-sounding responses. Because the latest version modularizes note analysis and comment generation, developers can leverage an AI's reasoning to create sophisticated, automated community management workflows that feel personal and context-aware rather than robotic.
Category: Browser & Web Automation
Tags: automation, playwright, social-media, web scraping, xiaohongshu
Visit Xiaohongshu Search & Comment
bash # Create virtual environment python3 -m venv venv # Activate virtual environment # Windows venv\Scripts\activate # macOS/Linux source venv/bin/activate 4. Install Dependencies: bash pip install -r requirements.txt pip install fastmcp 5. Install Browser: bash playwright install ---claude_desktop_config.json). You must use absolute paths for the Python executable and the script file. json { "mcpServers": { "xiaohongshu MCP": { "command": "/ABSOLUTE_PATH/TO/venv/bin/python3", "args": [ "/ABSOLUTE_PATH/TO/xiaohongshu_mcp.py", "--stdio" ] } } } ---mcp0_login(): Opens a browser window for manual QR code login to Xiaohongshu. Saves login state for future sessions. * mcp0_search_notes(keywords, limit): Searches for notes using keywords. * keywords (string): Search terms. * limit (number): Number of results to return (default: 5). * mcp0_get_note_content(url): Retrieves detailed content including title, author, time, and text. * url (string): The Xiaohongshu note URL. * mcp0_get_note_comments(url): Retrieves the comment section for a specific note. * url (string): The Xiaohongshu note URL. * mcp0_post_smart_comment(url, comment_type): Posts an AI-generated comment to a note. * url (string): The Xiaohongshu note URL. * comment_type (string): Options include "引流" (Traffic/Lead gen), "点赞" (Simple like/interact), "咨询" (Inquiry/Question), or "专业" (Professional/Authoritative). ---mcp0_post_smart_comment tool with the "Professional" or "Inquiry" types, a creator can automate high-value engagement. The MCP reads the note content and uses the LLM to generate a relevant, insightful comment that establishes the creator as an expert in that field. Example: A fitness coach sets a workflow: "Search for 'weight loss tips' every morning, find the top 5 notes from the last 24 hours, and post a 'Professional' type comment sharing one additional scientific tip related to the note's content."Part of MCP Servers
To install Xiaohongshu Search & Comment, clone the repository and set up a Python virtual environment. Install the dependencies using pip install -r requirements.txt and pip install fastmcp, then execute playwright install to configure the necessary browser binaries. Finally, add the server command and python script path using absolute file paths to your MCP client configuration file.
The server allows LLM clients to automate Xiaohongshu interactions. It provides tools to search notes with custom keyword queries, retrieve note text and metadata, extract comment sections, and publish automated comments. Available comment styles include lead generation, basic interaction, inquiry questions, and professional domain insights.
Any client supporting the Model Context Protocol over standard input and output can use Xiaohongshu Search & Comment. Common compatible clients include Claude for Desktop, Cursor, and custom FastMCP client wrappers. You configure the client by supplying the absolute path to your Python interpreter and the server script.
Initial authentication requires calling the login tool, which opens a Playwright browser window. The user manually scans the displayed QR code with the Xiaohongshu mobile app. Once logged in, the browser context and session cookies are preserved locally, allowing future MCP tool invocations to run without scanning again.
Yes, Xiaohongshu Search & Comment is an open-source project hosted on GitHub. Anyone can inspect the Python and Playwright code, adjust scraping behavior, or extend the automated comment types. The public repository also provides access to newer version updates and instructions for community contributions.