Get the FREE Ultimate OpenClaw Setup Guide →

xhs

小红书MCP服务 x-s x-t js逆向

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio jobsonlook-xhs-mcp uvx --from jobson-xhs-mcp xhs-mcp \
  --env XHS_COOKIE="<your_xhs_cookie_here>"

How to use

This MCP server provides access to Xiaohongshu (XHS) data through a Model Context Protocol interface. It exposes tools to search notes, retrieve note content, fetch and post comments, and check cookie validity. The recommended workflow uses uvx to run the server in MCP client configurations: you supply your XHS cookie via the XHS_COOKIE environment variable so the server can authenticate with Xiaohongshu endpoints. Typical usage includes checking cookie validity, performing a home feed search, and retrieving or commenting on notes by URL. The server aims to avoid heavy browser automation by leveraging direct HTTP requests, enabling faster, lighter-weight interactions with the Xiaohongshu API.

How to install

Prerequisites:

  • Python 3.12 or newer
  • uv Python package (pip install uv)
  • An XHS cookie obtained from an authenticated Xiaohongshu session

Option A: Using uvx (recommended)

  1. Ensure Python and uv are installed: pip install uv
  2. Create a MCP client configuration (example): { "mcpServers": { "xhs-mcp": { "command": "uvx", "args": [ "--from", "jobson-xhs-mcp", "xhs-mcp" ], "env": { "XHS_COOKIE": "<你的小红书cookie>" } } } }
  3. Save the config and run the MCP client using uvx with the provided config, ensuring XHS_COOKIE is set in the environment if not embedded in the config.

Option B: From source (manual setup)

  1. Install prerequisites: Node.js (for completeness in some workflows) and Python 3.12+, and uv: pip install uv
  2. Clone the repository and install dependencies if required by the project structure: git clone https://github.com/jobsonlook/xhs-mcp.git cd xhs-mcp
  3. Run the server using uv in directory mode (examples shown in the README): uv sync uv run xhs_mcp/main.py
  4. Configure MCP client as in Option A, replacing the command and arguments with the appropriate run command from your environment and ensuring XHS_COOKIE is set.

Prerequisites recap:

  • Python 3.12+
  • uv (pip install uv)
  • Xiaohongshu cookie (XHS_COOKIE)

Additional notes

Tips and notes:

  • The server relies on a valid XHS_COOKIE; cookies expire and must be refreshed by re-logging into Xiaohongshu and updating the environment variable or config.
  • If uvx is not found, install it with: pip install uv, and ensure your PATH includes the uv executable.
  • The exposed tools include: check_cookie(), home_feed(), search_notes(keywords), get_note_content(url), get_note_comments(url), and post_comment(comment, note_id).
  • When passing URLs to get_note_content or get_note_comments, use the complete URL that includes any necessary xsec_token parameters.
  • Keep your MCP client configuration secure since it contains cookie values and access controls.
  • This MCP server avoids heavy headless browser usage by using direct HTTP-based interactions with Xiaohongshu endpoints.

Related MCP Servers

Sponsor this space

Reach thousands of developers