Skip to main content
Glama
muhenan

Xiaohongshu MCP Server

by muhenan

小红书 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 --headless

2. 检查登录状态

uv run xiaohongshu-status

3. 发布内容

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-server

MCP 工具说明

服务器提供三个 MCP 工具:

  1. xiaohongshu_login - 登录小红书账号

    • headless: bool - 是否使用无头模式(默认:False)

    • chrome_path: str - Chrome 路径(可选)

  2. xiaohongshu_check_status - 检查登录状态

    • headless: bool - 是否使用无头模式(默认:True)

    • chrome_path: str - Chrome 路径(可选)

  3. 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 个字符

故障排除

常见问题

  1. 登录失败

    • 确保网络连接正常

    • 尝试清除 cookies 后重新登录

    • 检查 Chrome 浏览器是否正常安装

  2. 发布失败

    • 确认已登录状态

    • 检查图片文件路径和格式

    • 验证标题和内容长度

  3. MCP 服务器启动失败

    • 确保安装了 mcp[cli] 依赖

    • 检查日志文件查看详细错误信息

技术栈

  • Python 3.10+ - 主要开发语言

  • Playwright - 浏览器自动化

  • MCP Python SDK - Model Context Protocol 支持

  • Loguru - 日志管理

  • Pydantic - 数据验证

  • uv - 包管理器

许可证

本项目基于 MIT 许可证开源。

Available Tools

3 tools
xiaohongshu_check_statusC

检查小红书登录状态

Args: headless: 是否使用无头模式,默认True(状态检查可使用无头模式) chrome_path: Chrome浏览器可执行文件路径,可选

Returns: 登录状态信息

ParametersJSON Schema
NameRequiredDescriptionDefault
chrome_pathNo
headlessNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It implies a read-only operation (checking status) but doesn't disclose behavioral traits such as whether it requires prior login, potential rate limits, error handling, or what specific information is returned. The mention of headless mode adds some context but is insufficient for a mutation-sensitive tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the main purpose first, followed by parameter and return sections. It avoids unnecessary verbosity, though the structure could be slightly improved by integrating parameter notes more seamlessly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no annotations), the description is somewhat complete but has gaps. It covers the purpose and parameters but lacks usage guidelines and detailed behavioral context. The presence of an output schema reduces the need to explain return values, but more context on tool interaction is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning for both parameters: 'headless' is explained as whether to use headless mode with a default and usage note, and 'chrome_path' is noted as optional. However, it doesn't fully detail parameter constraints or examples, leaving gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as '检查小红书登录状态' (check Xiaohongshu login status), which is a specific verb+resource combination. However, it doesn't explicitly distinguish this from sibling tools like 'xiaohongshu_login' (which likely performs login) or 'xiaohongshu_publish' (which likely publishes content), though the function is reasonably distinct by name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'xiaohongshu_login' for logging in or 'xiaohongshu_publish' for publishing. It mentions that headless mode can be used for status checks, but this is more of a parameter hint than usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

xiaohongshu_loginC

登录小红书账号

Args: headless: 是否使用无头模式,默认False(建议使用有界面模式进行扫码) chrome_path: Chrome浏览器可执行文件路径,可选

Returns: 登录结果消息

ParametersJSON Schema
NameRequiredDescriptionDefault
chrome_pathNo
headlessNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions logging in and implies browser automation (via headless mode and Chrome path), but lacks critical details: what authentication method is used (e.g., QR code scanning as hinted, password input), whether it requires user interaction, potential side effects (e.g., session creation, cookies), error handling, or rate limits. This is a significant gap for a login tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the main purpose first, followed by parameter details. It uses minimal sentences that earn their place by explaining the tool and parameters. However, the structure could be slightly improved by integrating the parameter explanations more seamlessly, but it remains efficient with zero waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (login operation with browser automation), no annotations, and an output schema exists (implied by 'Returns: 登录结果消息'), the description is partially complete. It covers the basic purpose and parameters but lacks behavioral context (e.g., how login works, session management) and doesn't leverage the output schema to explain return values. For a tool with 2 parameters and no annotations, it should do more to be fully helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning for both parameters: 'headless' is explained as controlling headless mode with a default and suggestion, and 'chrome_path' as an optional Chrome executable path. However, it doesn't cover parameter interactions (e.g., if headless=true affects chrome_path usage) or provide examples, leaving some ambiguity. With 2 parameters partially documented, this meets the baseline for low coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as '登录小红书账号' (login to Xiaohongshu account), which is a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'xiaohongshu_check_status' (which likely checks login status) or 'xiaohongshu_publish' (which likely posts content), though the login function is reasonably distinct by nature.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., whether an account is needed), when to use it relative to siblings (e.g., login before publishing), or any exclusions. The only contextual note is a suggestion for headless mode, which is parameter-specific, not usage guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

xiaohongshu_publishC

发布小红书内容

Args: title: 标题(必填,不超过40个字符) content: 正文内容(必填) image_paths: 图片路径列表(必填,支持jpg/jpeg/png/gif/webp格式) headless: 是否使用无头模式,默认False(建议使用有界面模式观察发布过程) chrome_path: Chrome浏览器可执行文件路径,可选

Returns: 发布结果消息

ParametersJSON Schema
NameRequiredDescriptionDefault
chrome_pathNo
contentYes
headlessNo
image_pathsYes
titleYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool publishes content and suggests using interface mode for observation, but lacks critical behavioral details: authentication requirements, error handling, rate limits, whether it's idempotent, or what happens on failure. The description doesn't contradict annotations (none exist), but provides minimal behavioral context for a publishing operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections for Args and Returns, and each sentence adds value. The Chinese text is concise and to the point. However, the single-line purpose statement could be slightly more descriptive, and the parameter explanations could be more efficiently integrated rather than listed separately.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a content publishing tool with 5 parameters, 0% schema coverage, no annotations, but with an output schema, the description provides basic operational context but lacks important details. The output schema handles return values, but the description doesn't cover authentication requirements, error conditions, or how this tool relates to its siblings. It's minimally adequate but has clear gaps for a publishing operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description adds meaningful parameter context: it clarifies that 'title' is required and has a 40-character limit, 'content' and 'image_paths' are required, image formats supported, and provides guidance on 'headless' mode. However, it doesn't fully compensate for the schema gap - 'chrome_path' gets minimal explanation, and there's no detail on parameter interactions or validation rules beyond basic requirements.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as '发布小红书内容' (publish Xiaohongshu content), which is a specific verb+resource combination. It distinguishes itself from sibling tools like 'xiaohongshu_check_status' and 'xiaohongshu_login' by focusing on content publishing rather than status checking or authentication. However, it doesn't explicitly mention how it differs from those siblings beyond the basic function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus its siblings. While it mentions '建议使用有界面模式观察发布过程' (suggest using interface mode to observe the publishing process), this is a technical implementation detail rather than usage context. There's no mention of prerequisites (e.g., whether login is required first) or alternatives for different publishing scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

B3.1/5.0
Disambiguation5/5

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.

Naming Consistency5/5

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.

Tool Count2/5

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.

Completeness2/5

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

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    F
    maintenance
    Enables interaction with Xiaohongshu (Little Red Book) platform through automated browser operations. Supports authentication, content publishing, search, discovery, and commenting using Puppeteer-based automation.
    380
    54
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables 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.
    4
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables automated interaction with Xiaohongshu (Little Red Book) platform including searching posts, retrieving content and comments, and posting AI-generated comments with persistent login support.
    448
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables automated interaction with Xiaohongshu (Little Red Book) to search for notes, retrieve content or comments, and post targeted smart comments. It utilizes Playwright to manage browser-based tasks such as secure login and automated engagement.
    123

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/muhenan/xiaohongshu-mcp-python'

If you have feedback or need assistance with the MCP directory API, please join our Discord server