XiaoHongShu (Little Red Book) logo

XiaoHongShu (Little Red Book)

Organization
algovate

用于小红书(xiaohongshu.com)的 Model Context Protocol(MCP)服务器与 CLI 工具,支持登录、发布、搜索、推荐等自动化能力

Publisheralgovate
Repositoryxhs-mcp
LanguageTypeScript
Forks
13
Stars
50
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    XiaoHongShu (Little Red Book) exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    50 stars and 13 forks from the linked repository.

xhs-mcp

简体中文 | English

xhs-mcp 提供统一的命令行入口 xhs-mcp,并内置 MCP 服务器子命令。用于小红书(xiaohongshu.com)的 Model Context Protocol(MCP)服务器与 CLI 工具,支持登录、发布、搜索、推荐等自动化能力(基于 Puppeteer)。

npm version npm downloads License: MIT

📦 NPM 信息

  • 包名: xhs-mcp
  • 运行 CLI(推荐): npx xhs-mcp <subcommand>
  • 启动 MCP:npx xhs-mcp mcp [--mode stdio|http] [--port 3000]

✨ 功能

  • 认证:登录、登出、状态检查
  • 发布:图文和视频发布
    • 图文发布:标题≤20字符(40显示单位)、内容≤1000、最多18图
    • 视频发布:支持 MP4、MOV、AVI、MKV、WebM、FLV、WMV 格式
    • 新功能: 支持图片 URL 自动下载(HTTP/HTTPS)
    • 新功能: 标题宽度精确验证(CJK字符2单位,ASCII字符1单位)
    • 支持本地图片路径
    • 支持 URL 和本地路径混合使用
    • 智能缓存机制,避免重复下载
  • 发现:推荐、搜索、详情、评论
  • 用户笔记:列表查看、删除管理
  • 自动化:Puppeteer 驱动、无头模式、Cookie 管理
  • 验证:发布功能验证脚本,支持 HTML 报告生成

📋 可用工具

  • xhs_auth_loginxhs_auth_logoutxhs_auth_status
  • xhs_discover_feedsxhs_search_notexhs_get_note_detail
  • xhs_comment_on_note
  • xhs_get_user_notesxhs_delete_note(用户笔记管理)
  • xhs_publish_content(统一发布接口:typetitlecontentmedia_pathstags
    • 图片发布:1-18个图片文件或URL
    • 视频发布:恰好1个视频文件
    • 混合使用:支持图片URL和本地路径混合

🚀 快速开始(MCP)

Stdio 模式(默认)

bash
npx xhs-mcp mcp

# 调试日志
XHS_ENABLE_LOGGING=true npx xhs-mcp mcp

首次运行提示:如果未安装 Puppeteer 浏览器,先执行

bash
npx xhs-mcp browser    # 自动检查并安装 Chromium,显示可执行路径
# 或
npx puppeteer browsers install chrome

输出示例:

json
{
  "success": true,
  "message": "Chromium is ready",
  "data": {
    "installed": true,
    "executablePath": "/path/to/chromium"
  }
}

验证 MCP 连接:

bash
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | npx xhs-mcp mcp

HTTP 模式

bash
# 启动 HTTP 服务器(默认端口 3000)
npx xhs-mcp mcp --mode http

# 指定端口
npx xhs-mcp mcp --mode http --port 8080

# 调试模式
XHS_ENABLE_LOGGING=true npx xhs-mcp mcp --mode http

HTTP 服务器支持:

  • Streamable HTTP (协议版本 2025-03-26) - 端点:/mcp
  • SSE (协议版本 2024-11-05) - 端点:/sse/messages
  • 健康检查 - 端点:/health

详细文档请参考:HTTP Transports

🧰 CLI 子命令

bash
# 认证
npx xhs-mcp login --timeout 120
npx xhs-mcp logout
npx xhs-mcp status

# 浏览器依赖
npx xhs-mcp browser [--with-deps]  # 检查并安装 Chromium,显示可执行路径

# 发现与检索
npx xhs-mcp feeds [-b /path/to/chromium]
npx xhs-mcp search -k 关键字 [-b /path/to/chromium]

# 当前用户笔记
npx xhs-mcp usernote list [-l 20] [--cursor <cursor>] [-b /path/to/chromium]

# 删除用户笔记
npx xhs-mcp usernote delete --note-id <id> [-b /path/to/chromium]
npx xhs-mcp usernote delete --last-published [-b /path/to/chromium]

# 互动
npx xhs-mcp comment --feed-id <id> --xsec-token <token> -n "Nice!" [-b /path/to/chromium]

# 发布
# 使用本地图片
npx xhs-mcp publish --type image --title 标题 --content 内容 -m path1.jpg,path2.png --tags a,b [-b /path/to/chromium]

# ⭐ 使用图片 URL(自动下载)
npx xhs-mcp publish --type image --title 标题 --content 内容 -m "https://example.com/img1.jpg,https://example.com/img2.png" --tags a,b

# 混合使用 URL 和本地路径
npx xhs-mcp publish --type image --title 标题 --content 内容 -m "https://example.com/img1.jpg,./local/img2.jpg" --tags a,b

# 发布视频
npx xhs-mcp publish --type video --title 视频标题 --content 视频描述 -m path/to/video.mp4 --tags a,b [-b /path/to/chromium]

# 查看可用工具
npx xhs-mcp tools [--detailed] [--json]

# 启动 MCP
npx xhs-mcp mcp [--mode stdio|http] [--port 3000]

🔧 客户端接入(Cursor)

Stdio 模式

.cursor/mcp.json

json
{
  "mcpServers": {
    "xhs-mcp": {
      "command": "npx",
      "args": ["xhs-mcp", "mcp"],
      "env": { "XHS_ENABLE_LOGGING": "true" }
    }
  }
}

HTTP 模式

.cursor/mcp.json

json
{
  "mcpServers": {
    "xhs-mcp-http": {
      "command": "npx",
      "args": ["xhs-mcp", "mcp", "--mode", "http", "--port", "3000"],
      "env": { "XHS_ENABLE_LOGGING": "true" }
    }
  }
}

或者使用 HTTP 客户端直接连接:

json
{
  "mcpServers": {
    "xhs-mcp-http": {
      "url": "http://localhost:3000/mcp"
    }
  }
}

⚠️ 注意事项

  • 图文发布:标题≤20、内容≤1000、图片≤18
  • 视频发布:支持多种格式,文件大小建议≤500MB
  • 避免同账号多端同时网页登录
  • 合理控制发帖频率
  • 图片 URL 自动下载到 ./temp_images/ 目录(自动缓存)
  • 图片 URL 支持格式:JPEG、PNG、GIF、WebP、BMP

📖 文档和示例

📚 文档

🎨 示例

🧪 测试

  • 运行测试 - 测试说明和用法
  • 运行所有测试:npm test
  • 验证脚本: npm run validate - 发布功能验证测试,生成 HTML 报告

🛠️ 构建说明

  • 统一使用单一生产构建配置:config/webpack.config.js
  • 已移除开发与优化变体;开发请直接运行:
    • npm run dev(直接运行 TypeScript CLI)
    • npm run build(打包到 dist/xhs-mcp.cjs

🙏 致谢

基于 xiaohongshu-mcp 重构与扩展(TypeScript、Puppeteer、MCP 优化、日志清理、NPM 发布)。

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "xhs-mcp": {
      "command": "npx",
      "args": [
        "xhs-mcp",
        "mcp"
      ],
      "env": {
        "XHS_ENABLE_LOGGING": "true"
      }
    }
  }
}

Use XiaoHongShu (Little Red Book) MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once XiaoHongShu (Little Red Book) is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add XiaoHongShu (Little Red Book) as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the XiaoHongShu (Little Red Book) MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "xiaohongshu-little-red-book": {
      "command": "npx",
      "args": [
        "-y",
        "xhs-mcp"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the XiaoHongShu (Little Red Book) MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the XiaoHongShu (Little Red Book) MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use XiaoHongShu (Little Red Book) to help me with this task?
XiaoHongShu (Little Red Book)
Sure. I read it.
Here is what I found using XiaoHongShu (Little Red Book).

Frequently asked questions

What is the XiaoHongShu (Little Red Book) MCP server used for?

XiaoHongShu (Little Red Book) is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use XiaoHongShu (Little Red Book) MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use XiaoHongShu (Little Red Book) with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use XiaoHongShu (Little Red Book) MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With XiaoHongShu (Little Red Book) connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect XiaoHongShu (Little Red Book) MCP to TypingMind?

XiaoHongShu (Little Red Book) runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does XiaoHongShu (Little Red Book) MCP provide in TypingMind?

XiaoHongShu (Little Red Book) exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use XiaoHongShu (Little Red Book) MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If XiaoHongShu (Little Red Book) requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇