xhs-video-mcp
Allows parsing Xiaohongshu post links and creating 9:16 videos from the images, with optional background music, OCR keyword highlighting, and circle/underline animations.
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., "@xhs-video-mcpCreate a 9:16 video from these images with background music and highlight keywords"
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.
XHS2Video
将你有权使用的图片制作成 9:16 视频,可添加背景音乐、OCR 关键词高亮、画圈和下划线动画。
0.2.0a1 · 本地单人实验版。 发布仓库名称是 xhs2video,Python 包名为 xhs-video-mcp。
提供本地图片 CLI、MCP stdio 服务,以及实验性小红书链接解析和 OpenClaw 工作流模板。
不提供公共网络服务或多人 Telegram 机器人的安全隔离保证。
安装
需要 Python 3.10–3.12(CI 验证范围)、FFmpeg。OCR 标注另需 Tesseract 和中文语言包。
git clone https://github.com/sufferfml/xhs2video.git
cd xhs2video
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e .
# macOS
brew install ffmpeg tesseract tesseract-lang
# Ubuntu / Debian 可使用:
# sudo apt-get install ffmpeg tesseract-ocr tesseract-ocr-chi-sim只有链接解析功能需要 Chromium:
python -m playwright install chromium
# Linux 缺少浏览器系统库时:python -m playwright install --with-deps chromium开发及可复现验证使用已提交的 uv.lock:
uv sync --locked --extra dev
uv run --locked pytest依赖与许可证清单见 第三方说明。安装会从软件源下载依赖;不会打包分发 FFmpeg、Tesseract、Chromium 或第三方媒体素材。
Related MCP server: MathMind MCP Server
先跑通离线示例
python examples/make_demo.py --output-dir output/demo
xhs-local-video output/demo/image_000.png output/demo/image_001.png --duration 2 --output-dir output示例图片由脚本生成,不抓取帖子,不需要账号或背景音乐。命令返回一行 JSON,其中 video_path 是视频位置。
使用自己的图片时,只需替换图片路径;可选 --bgm /absolute/path/to/licensed-music.mp3 和 --style-prompt '把"HELLO"圈出来'。
MCP 客户端配置
将以下对象放到客户端的 MCP 配置中。把路径替换为你实际的虚拟环境解释器和数据目录;JSON 中不能依赖 ~ 或 shell 环境变量自动展开。
{
"mcpServers": {
"xhs-video": {
"command": "/absolute/path/to/project/.venv/bin/python",
"args": ["-m", "xhs_video_mcp.server"],
"env": {
"XHS_OUTPUT_DIR": "/absolute/path/to/private-data/output",
"XHS_BGM_DIR": "/absolute/path/to/private-data/bgm",
"XHS_TEMP_DIR": "/absolute/path/to/private-data/tmp"
}
}
}
}只支持本地 stdio。可用工具:create_video_from_xhs、list_bgm_files、get_video_config。
先调用 get_video_config 验证连接,再使用你有权处理的链接。CLI 诊断写 stderr,stdout 用于 JSON/MCP 协议。
实验性链接解析
这是非官方项目,与小红书无隶属或授权关系。代码许可证不授予帖子、图片、音乐或平台访问权限。 仅处理你有权使用的内容;使用前核对适用的平台协议。 登录限制、验证码或平台页面变化可能使解析失败;本项目不提供绕过登录、验证码或访问控制的功能。 不要用它批量搬运第三方内容,也不要把 Cookie、签名分享链接或抓取结果提交进仓库。
xhs-image-workflow --url 'https://www.xiaohongshu.com/explore/POST_ID'
# 保存 JSON 返回的 download_dir,下两步显式传递同一个目录
xhs-video-plan-workflow \
--download-dir /absolute/path/to/job \
--model-plan-json '{"selected_indices":[1,2],"render_plan":{"duration_per_image_list":[3,3],"bgm":"none","style_prompt":""}}'
xhs-video-render-workflow --download-dir /absolute/path/to/joblatest 已禁用,防止取到其他任务的素材。模型生成的 JSON 只作为数据验证,不作为 shell 命令执行。
CLI 自身不调用模型,也不需要模型 API Key;模型费用由你的 MCP/OpenClaw 客户端配置决定。
完整的一次性流程:
xhs-video-workflow --url 'https://www.xiaohongshu.com/explore/POST_ID' --bgm none --duration-per-image 3OpenClaw 模板 仅供本地单人工作流适配。它要求发送前验证可信会话路由,并保存该任务的具体目录;未验证 Telegram 线上发送。
配置、隐私和运行限制
默认数据存于用户可写目录:macOS 为 ~/Library/Application Support/xhs-video-mcp,Linux 为 ${XDG_DATA_HOME:-~/.local/share}/xhs-video-mcp,Windows 为 %LOCALAPPDATA%/xhs-video-mcp。
导入模块不创建目录,执行任务时才创建。升级后如需继续使用项目目录内的旧 BGM/output,请显式设置环境变量。
环境变量 | 用途 |
| 音乐、结果、临时目录 |
| 外部可执行程序路径 |
| 默认 |
| 首选 OCR 分割模式,默认 4 |
| 回退解析的尺寸过滤,默认 350000 / 700 |
|
|
每次最多 20 张图片,单图下载最多 20 MiB,总下载最多 200 MiB,单图最多 4000 万像素。 单图时长最多 12 秒,合计最多 240 秒;解析整体限时 120 秒,单个 FFmpeg 进程 180 秒,单次 OCR 30 秒。 动画可能启动多个有限时进程;这些限制不构成公共服务的资源隔离机制。
导出的图片、视频、计划和诊断留在本机,可能含敏感内容及本机路径;分享前自行检查。 网络下载的临时图片在流程结束时清理;强制退出可能留下临时文件。停止运行后,可自行删除所配置的 tmp 目录。 本项目没有遥测;浏览器解析会联系小红书/CDN,客户端自身的数据处理规则由客户端决定。
维护与验证
本机离线测试通过不代表实时抓取、Telegram 发送或所有操作系统已验证。
卸载:激活虚拟环境后运行
python -m pip uninstall xhs-video-mcp;如由 uv 管理则删除项目虚拟环境。数据目录不会自动删除。
许可证
Copyright (C) 2026 sufferfml and contributors. 本项目以 GNU GPL v3.0 only 发布。 解析器中的 CDN token 提取和图片地址构造参考/改编自 JoeanAmier 的 XHS-Downloader(GPLv3); 保留其署名和来源,修改范围见 THIRD_PARTY_NOTICES.md。本许可证不覆盖第三方素材或外部程序。
Available Tools
3 toolscreate_video_from_xhsA
Create a short video from a Xiaohongshu post.
Downloads images from the XHS post, adds background music, and generates a vertical (9:16) video suitable for TikTok/Reels.
Args: url: Xiaohongshu post URL (supports various formats including share links) bgm: BGM file name from bgm folder, or "random" to pick randomly. Set to "none" to create video without music. duration_per_image: How many seconds each image should be displayed (default: 3) style_prompt: Natural-language style instructions for image annotation. Example: 在第一张图里把"马云"蓝色高亮并红笔圈出来
Returns: A dict containing: - video_path: Full path to the generated video file - images_count: Number of images in the video - duration: Total video duration in seconds - bgm_used: Name of the BGM file used (or null if none) - title: Title of the original XHS post - style_report: Style parsing/OCR diagnostics (or null when not used)
| Name | Required | Description | Default |
|---|---|---|---|
| bgm | No | random | |
| url | Yes | ||
| style_prompt | No | ||
| duration_per_image | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It discloses that the tool downloads images, adds background music, and generates a video, and it describes the return dict fields including style_report diagnostics. It doesn't mention potential side effects like network access, file creation locations, or failure modes, but for a content-generation tool the described behavior is reasonably transparent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with a short summary, an Args section, and a Returns section. It is front-loaded with the core purpose. The only minor issue is that the Returns section is somewhat verbose, but it is useful for an agent to know what to expect. Overall, every sentence earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (4 params, no output schema, no annotations), the description covers the main aspects: what it does, how to use each parameter, and what it returns. It lacks explicit error-handling or edge-case guidance (e.g., what happens if the URL is invalid or images fail to download), but for a typical agent invocation it is sufficiently complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
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 does: it explains url formats, bgm options ('random', 'none', or a file name), duration_per_image default, and style_prompt with a concrete example. This adds substantial meaning beyond the bare schema. It could be slightly stronger by clarifying the exact format of style_prompt or the expected language, but the example helps.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('create'), a specific resource ('short video from a Xiaohongshu post'), and the output format (vertical 9:16 for TikTok/Reels). It clearly distinguishes this from sibling tools like list_bgm_files and get_video_config, which are about listing/configuring rather than generating.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explains the core workflow (downloads images, adds BGM, generates video) and gives practical parameter guidance (e.g., 'random' for BGM, 'none' for no music). It doesn't explicitly state when to use this tool versus siblings, but the purpose is so distinct that the usage context is clear. It could be improved by noting prerequisites like needing a valid XHS URL or BGM files existing.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_video_configA
Get current video generation configuration.
Returns: A dict with current settings for video resolution, fps, etc.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
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 indicates a read operation via 'Get' but does not disclose whether the config is cached, reflects live state, or requires specific permissions. It also doesn't mention any side effects, which is a minor gap for a getter.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences with no unnecessary detail. The purpose is front-loaded, and the return description is concise. It earns its place entirely.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple getter with no parameters and no output schema, the description gives examples of returned fields (resolution, fps) but not an exhaustive list. An agent might need more details to fully utilize the config, so it is adequate but not complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are no parameters, so schema coverage is effectively 100%. The description doesn't need to explain parameters, and the baseline of 4 applies. It does mention the return type (a dict), which is useful.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action 'Get' and the resource 'video generation configuration'. It is distinct from sibling tools like create_video_from_xhs and list_bgm_files, leaving no ambiguity about what it retrieves.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
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 that it might be needed before creating a video or that it is the only way to inspect current settings. No context or exclusions are given.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_bgm_filesA
List all available BGM files in the music folder.
Returns: A dict containing: - bgm_files: List of available BGM file names - bgm_dir: Path to the BGM directory
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It discloses the return structure (dict with bgm_files and bgm_dir) and implies a read-only operation, but does not explicitly state that it has no side effects or any permissions needed. It adds some transparency about output, but lacks explicit safety/behavioral affirmations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise: a single purpose sentence followed by a clear return-value listing. Every part earns its place, with no fluff or redundancy. The purpose is front-loaded and the return structure is organized.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple zero-parameter tool with no output schema, the description is complete. It states what the tool does and precisely what it returns (the dictionary keys and their meanings). No additional information is necessary for an agent to select and invoke it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so the schema is fully covered (100%) and there is nothing for the description to explain. According to the baseline rule for 0 parameters, the score is 4. The description correctly avoids adding irrelevant parameter details.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states a specific action ('List') and resource ('BGM files'), with a clear location ('music folder'). It is easily distinguishable from siblings like create_video_from_xhs and get_video_config, which are about video creation and configuration.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage: if you need available BGM files and their directory, use this tool. However, it does not explicitly mention when to use it versus alternatives, nor does it state any exclusions. Guidance is absent, leaving the agent to infer from the tool's name and description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v0.1.0- First observed
create_video_from_xhs - First observed
get_video_config - First observed
list_bgm_files
TDQS
Scored across 3 tools
Each tool targets a distinct concern: creating a video, listing BGM assets, and reading configuration. There is no overlap between these three operations, so an agent can clearly tell them apart.
All tool names follow a consistent verb_noun pattern with snake_case (create_video_from_xhs, list_bgm_files, get_video_config). The naming is predictable and uniform.
With 3 tools, the server is tightly scoped to its purpose of generating videos from Xiaohongshu posts. Each tool is necessary and there are no redundant or extraneous entries.
The core workflow is covered: create a video, list available BGM, and inspect configuration. A minor gap is the lack of a setter for video configuration, but this does not prevent the main use case from working.
Maintenance
Related MCP Connectors
Trim, watermark, extract audio, and convert video to 9:16 vertical via API or MCP server.
Build, run, schedule, and publish AI video pipelines to YouTube and TikTok from any MCP client.
Generate and manage AI UGC video ads through eleven typed MCP tools
AI image, video, voice and music generation over MCP, routed to Veo 3.1, Seedance 2.5 and more.
Related MCP Servers
AlicenseNot gradedqualityAmaintenancePhoto-to-reel MCP for solo founders and SMBs. Upload 1–10 photos and get a captioned vertical reel for Instagram, TikTok, YouTube Shorts, or Facebook — with motion, library-matched music, and optional AI voiceover.MIT- FlicenseAqualityDmaintenanceProvides a audio/video creation toolbox via MCP protocol, enabling natural language-based video editing tasks such as image-to-video, video merging, subtitle extraction, and more.93-
- AlicenseNot gradedqualityCmaintenanceOne-stop automated video generation MCP service integrating digital human cloning, voice cloning, video/audio creation, and web content aggregation for LLMs.1MIT
- AlicenseAqualityCmaintenanceEnables AI assistants to recognize images and videos, and generate images (text-to-image, infographics, image-to-image, batch) through MCP tools.61Apache 2.0