Xiaohongshu MCP Server

repository·main·Indexed 12 days ago

https://github.com/xpzouying/xiaohongshu-mcp

An MCP (Model Context Protocol) server that enables AI assistants to interact with Xiaohongshu (小红书). It provides capabilities for automated content searching, posting images and videos, retrieving user profiles, and social interactions such as commenting, liking, and favoriting. Supports deployment via Docker, macOS launchd, and integration with AI clients like AnythingLLM and Cherry Studio.

Tokens
21.4K
Snippets
74
Records
119
Agent score
97%

What's inside Xiaohongshu MCP

  1. Overview of the Xiaohongshu MCP HTTP API

    main

    The Xiaohongshu MCP service provides both the Model Context Protocol (MCP) and a standard HTTP REST API. Developers can interact with the service using the HTTP API for automation and integration tasks.

    Base URL: http://localhost:18060

  2. Choose a deployment method for xiaohongshu-mcp

    main

    Depending on your technical expertise and requirements, you can choose between two primary ways to integrate Xiaohongshu data with your AI assistant:

    1. Deep Openclaw Integration (Recommended for Developers): Use this if you want to deploy the MCP server yourself. You can use either xiaohongshu-mcp-skills (if you have already deployed this project) or xiaohongshu-skills (for out-of-the-box usage).
    2. x-mcp Browser Extension (Recommended for Non-Technical Users): This is the simplest setup. It is a zero-configuration browser extension (Chrome/Edge) that runs on your local network. It avoids Docker, proxy, and environment setup, and eliminates server IP risks.
  3. Model Context Protocol (MCP) support

    main

    In addition to standard HTTP APIs, this service supports the Model Context Protocol (MCP). You can interact with the service using MCP clients via the following endpoints:

    • MCP Endpoints: /mcp and /mcp/*path
    • Protocol Type: Supports JSON response format via Streamable HTTP.
  4. Publish video content to Xiaohongshu

    main

    You can publish videos to Xiaohongshu with a title, description, and tags.

    Requirements and Constraints:

    • Input Type: Only supports local video file absolute paths. HTTP links are not supported.
    • File Size: It is recommended to keep video files under 1GB.
    • Process: The system automatically handles format conversion and waits for processing to complete before publishing.

    Example input format:

    "/Users/username/Videos/video.mp4"
    "/Users/username/Videos/video.mp4"
  5. Configure storage and persistence in Docker

    main

    When running in Docker, pay attention to these two storage requirements:

    1. Image Publishing: The service generates an images/ directory for published images. This directory is mounted into the container. If you want to publish local images, copy them to the ./images/ directory on your host and instruct the MCP to use the path /app/images during publishing.
    2. Data Persistence: The Docker image includes a built-in browser and pre-downloads data during the build stage. To persist cookies and runtime data, you must mount the host directory to the container using ./data:/app/data.
  6. Publish image-text posts to Xiaohongshu

    main

    You can publish posts containing both text and images. The post must follow Xiaohongshu's constraints:

    • Title: Maximum 20 characters.
    • Content: Maximum 1000 characters.

    Images can be provided in two ways:

    1. HTTP/HTTPS links: e.g., ["https://example.com/image1.jpg"].
    2. Local absolute paths (Recommended): e.g., ["/Users/username/Pictures/image1.jpg"]. Using local paths is more stable, faster, and supports more formats.

    Supported features include adding appropriate Tags to increase traffic.

    ["/Users/username/Pictures/image1.jpg", "/home/user/images/image2.png"]
  7. Understand Xiaohongshu (XHS) posting modes

    main

    The post-to-xhs skill supports two distinct posting modes based on the type of content you want to share:

    1. Upload Image/Text (Default): Best for daily sharing. It combines images with short text.
    2. Write Long Article: Best for deep, long-form content. It uses a long article format combined with layout templates. Use this mode by explicitly saying "发长文" (Post long article).

    Input can be provided as Full Content (Title + Body + Images/URLs) or via URL Extraction (providing a webpage URL which the system will attempt to fetch and summarize).

  8. Understand the Xiaohongshu MCP API response formats

    main

    All API responses follow a unified JSON structure. Depending on the outcome, you will receive either a success or an error object.

    ### Success Response
    ```json
    {
      "success": true,
      "data": {},
      "message": "操作成功消息"
    }

    Error Response

    {
      "error": "错误消息",
      "code": "ERROR_CODE",
      "details": "详细错误信息"
    }
  9. RedNote operational best practices and risks

    main

    Operational Limits

    • Daily Limit: It is recommended to stay under 50 posts per day.
    • Content Quality: Avoid banned words and do not perform traffic diversion or pure content scraping/reposting.

    Critical Warnings

    • Single Session: RedNote does not allow the same account to be logged in on multiple web platforms simultaneously. Logging into another web platform will "kick out" the MCP session.
    • Real-name Verification: New accounts or unverified accounts may trigger a real-name verification prompt. This is a platform requirement and not an account ban; completing verification allows normal operation.
    • Account Safety: This project is for learning purposes. Use responsibly to avoid platform crackdowns.
  10. Install the Kimi-cc compatibility layer

    main

    To use Kimi-k2 with Claude Code, you must install the kimi-cc project. During the installation process, the script will pause and prompt you to enter your Kimi API Key. The input will be hidden for security. After installation, you must restart your shell environment or reload your environment variables as instructed by the installer logs to ensure the configuration takes effect.

    bash -c "$(curl -fsSL https://raw.githubusercontent.com/LLM-Red-Team/kimi-cc/refs/heads/main/install.sh)"
  11. Publish content using Write Long Article mode

    main

    Long article publishing follows a multi-step workflow using cdp_publish.py to handle templates and layout.

    Step 1: Fill content and apply layout

    Run the command to prepare the article. This will output a list of available templates in a TEMPLATES: [...] JSON array.

    python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" long-article --title-file title.txt --content-file content.txt

    Note: You can optionally add images using --images img1.jpg img2.jpg.

    Step 2: Select a template

    Choose a template name from the list provided in Step 1:

    python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" select-template --name "Template Name"

    Step 3: Fill the final description

    After selecting a template, fill the final description field. If the content exceeds 1000 words, it should be compressed to approximately 800 words.

    python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" click-next-step --content-file content.txt

    Step 4: Click Publish

    Once you have previewed the content in the browser, execute the final publish command:

    python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" click-publish
    python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" long-article --title-file title.txt --content-file content.txt
  12. Start the xiaohongshu-mcp service

    main

    To use the MCP tools, you must first run the service locally. The service provides an HTTP endpoint at http://localhost:18060/mcp.

    • Headless mode (default): Runs without a UI.
    • Interface mode: Runs with a user interface.

    Ensure you have Go installed to run the service from source.

    # Start service (default headless mode)
    go run .
    
    # Or with interface mode
    go run . -headless=false