Xiaohongshu MCP Server
Provides tools for automating Xiaohongshu (Little Red Book) operations including account login via QR code scanning, login status checking, and publishing image-text content to the platform.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Xiaohongshu MCP Server post a photo of my new coffee setup with the caption 'Morning brew perfection ☕️'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
小红书 MCP Python 项目
这是一个基于 Model Context Protocol (MCP) 的小红书自动化工具,提供登录、状态检查和内容发布功能。
功能特性
登录功能 - 支持扫码登录小红书账号
状态检查 - 快速检查当前登录状态
内容发布 - 自动发布图文内容到小红书
MCP 集成 - 完整的 MCP 服务器实现,可与 AI 客户端(例如 Cursor、Claude Code、Codex)集成
Related MCP server: XiaoHongShu MCP
安装要求
Python >= 3.10
已安装 Chrome 浏览器
uv 包管理器(推荐)
快速开始
安装依赖
# 使用 uv 安装(推荐)
uv sync
# 或使用 pip
pip install -e .安装 Playwright 浏览器
uv run playwright install chromium最简单启动(开发模式)
uv run mcp dev src/xiaohongshu_mcp/server.py等价的生产脚本启动方式:
uv run xiaohongshu-mcp-server使用方式
方式一:独立命令行工具
1. 登录小红书
# 使用有界面模式登录(推荐)
uv run xiaohongshu-login
# 使用无头模式登录
uv run xiaohongshu-login --headless2. 检查登录状态
uv run xiaohongshu-status3. 发布内容
uv run xiaohongshu-publish \
--title "我的标题" \
--content "这是正文内容" \
--images "image1.jpg" "image2.png"方式二:MCP 服务器
启动 MCP 服务器,可与支持 MCP 协议的 AI 客户端(例如 Cursor、Claude Code、Codex)集成:
# 启动开发模式 MCP 服务器
uv run mcp dev src/xiaohongshu_mcp/server.py
# 或使用脚本启动
uv run xiaohongshu-mcp-serverMCP 工具说明
服务器提供三个 MCP 工具:
xiaohongshu_login - 登录小红书账号
headless: bool - 是否使用无头模式(默认:False)
chrome_path: str - Chrome 路径(可选)
xiaohongshu_check_status - 检查登录状态
headless: bool - 是否使用无头模式(默认:True)
chrome_path: str - Chrome 路径(可选)
xiaohongshu_publish - 发布内容
title: str - 标题(必填,<=40字符)
content: str - 正文内容(必填)
image_paths: List[str] - 图片路径列表(必填)
headless: bool - 是否使用无头模式(默认:False)
chrome_path: str - Chrome 路径(可选)
配置说明
登录状态保存
登录状态通过 cookies 保存在:
~/.xiaohongshu_mcp/cookies.json日志配置
MCP 服务器日志保存在:
logs/mcp_server.log支持的图片格式
JPG/JPEG
PNG
GIF
WebP
项目结构
src/xiaohongshu_mcp/
├── browser/ # 浏览器管理模块
│ ├── cookies.py # Cookie 管理
│ └── driver.py # 浏览器驱动
├── xiaohongshu/ # 小红书功能模块
│ ├── login.py # 登录功能
│ └── publish.py # 发布功能
├── server.py # MCP 服务器
├── login.py # 登录命令行工具
├── check_status.py # 状态检查工具
└── publish.py # 发布命令行工具注意事项
发布功能建议使用有界面模式,便于观察发布过程
首次使用需要扫码登录
图片文件必须存在且格式正确
标题长度不能超过 40 个字符
故障排除
常见问题
登录失败
确保网络连接正常
尝试清除 cookies 后重新登录
检查 Chrome 浏览器是否正常安装
发布失败
确认已登录状态
检查图片文件路径和格式
验证标题和内容长度
MCP 服务器启动失败
确保安装了 mcp[cli] 依赖
检查日志文件查看详细错误信息
技术栈
Python 3.10+ - 主要开发语言
Playwright - 浏览器自动化
MCP Python SDK - Model Context Protocol 支持
Loguru - 日志管理
Pydantic - 数据验证
uv - 包管理器
许可证
本项目基于 MIT 许可证开源。
Available Tools
3 toolsxiaohongshu_check_statusC
检查小红书登录状态
Args: headless: 是否使用无头模式,默认True(状态检查可使用无头模式) chrome_path: Chrome浏览器可执行文件路径,可选
Returns: 登录状态信息
Inputs: chrome_path, headless. Returns: result
xiaohongshu_loginC
登录小红书账号
Args: headless: 是否使用无头模式,默认False(建议使用有界面模式进行扫码) chrome_path: Chrome浏览器可执行文件路径,可选
Returns: 登录结果消息
Inputs: chrome_path, headless. Returns: result
xiaohongshu_publishC
发布小红书内容
Args: title: 标题(必填,不超过40个字符) content: 正文内容(必填) image_paths: 图片路径列表(必填,支持jpg/jpeg/png/gif/webp格式) headless: 是否使用无头模式,默认False(建议使用有界面模式观察发布过程) chrome_path: Chrome浏览器可执行文件路径,可选
Returns: 发布结果消息
Inputs: content (required), image_paths (required), title (required), chrome_path, +1 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: check_status verifies login state, login performs authentication, and publish creates content. There is no overlap in functionality, and the descriptions clearly differentiate their roles in the Xiaohongshu workflow.
All tools follow a consistent 'xiaohongshu_verb' pattern with snake_case naming: xiaohongshu_check_status, xiaohongshu_login, and xiaohongshu_publish. This uniformity makes the tool set predictable and easy to understand.
With only 3 tools, the server feels thin for a social media platform like Xiaohongshu. It covers basic login and posting but lacks essential operations such as reading, updating, deleting content, or interacting with other users, limiting its utility for comprehensive agent workflows.
The tool set is severely incomplete for the Xiaohongshu domain. It only supports login and publishing, missing core CRUD operations like retrieving posts, editing content, deleting posts, browsing feeds, or managing interactions (e.g., likes, comments). This will cause significant agent failures in typical social media tasks.
Maintenance
Related MCP Connectors
搜索笔记、浏览首页推荐、查看笔记内容与评论,并发表你的评论。直接在工作流中与小红书内容互动,高效跟进话题。
RedNote (Xiaohongshu, 小红书) note search, full notes, comment threads and creator profiles.
XHS search/details, PGY, comments/replies, users/ID resolution/posts, transcript
Public data from 20+ platforms, including Douyin, Xiaohongshu, Weibo and TikTok, as structured JSON
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Xiaohongshu (Little Red Book) platform through automated browser operations. Supports authentication, content publishing, search, discovery, and commenting using Puppeteer-based automation.546 npm58MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to publish content to XiaoHongShu (Little Red Book) social platform, including checking login status and posting with titles, content, images, and hashtags through browser automation.4ISC
- FlicenseNot gradedqualityDmaintenanceEnables automated interaction with Xiaohongshu (Little Red Book) platform including searching posts, retrieving content and comments, and posting AI-generated comments with persistent login support.460-
- AlicenseNot gradedqualityDmaintenanceEnables automated interaction and data scraping for Xiaohongshu (RedNote), including posting, liking, commenting, following, and retrieving user and note data.5MIT