Skip to main content
Glama

XHS Image MCP

将文章/文本转换为小红书风格图片卡片的 MCP Server,支持 AI 生成封面图。

功能

  • 智能分页 - 使用浏览器实际测量自动分页,确保内容不溢出

  • 4种主题 - minimal / elegant / warm / dark

  • 3种比例 - 3:4 (推荐) / 1:1 / 4:3

  • AI 封面 - 使用 Gemini 根据文章内容生成艺术封面(设置 API Key 后自动启用)

  • Markdown 支持 - 直接读取 .md 文件并自动清理格式

  • MCP 协议 - 可与 Claude Desktop / Claude Code 集成

Related MCP server: Little Red Book Card MCP

v1.1.0 更新

  • 智能 AI 封面 - 设置 GEMINI_API_KEY 后自动生成 AI 封面,无需手动开启

  • 🔧 自动分页优化 - 使用浏览器实际测量替代字数估算,彻底解决内容溢出问题

  • 📐 AI 封面空间适配 - 第一页自动为 AI 封面横幅预留空间

小红书尺寸

比例

尺寸

说明

3:4

1080×1440px

推荐,占据最大屏幕空间

1:1

1080×1080px

方形,适合产品展示

4:3

1080×810px

横版,适合风景照

安装

npm install -g xhs-image-mcp
npx playwright install chromium

或从源码安装:

git clone https://github.com/dthinkr/xhs-image-mcp.git
cd xhs-image-mcp
npm install
npx playwright install chromium
npm run build

使用

MCP Server 配置

Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "xhs-image": {
      "command": "npx",
      "args": ["-y", "xhs-image-mcp"],
      "env": {
        "GEMINI_API_KEY": "your_api_key_here"
      }
    }
  }
}

Claude Code (~/.claude/settings.json):

{
  "mcpServers": {
    "xhs-image": {
      "command": "npx",
      "args": ["-y", "xhs-image-mcp"]
    }
  }
}

测试

npm test

MCP Tools

text_to_images

将文本转换为图片序列。

参数

类型

必填

说明

text

string

Yes

文本内容

title

string

标题(用于封面)

theme

string

minimal / elegant / warm / dark

ratio

string

3:4 / 1:1 / 4:3

fontSize

string

small / medium / large

showCover

boolean

是否生成封面页

generateAiCover

boolean

使用 AI 生成封面图(设置 API Key 后默认开启,传 false 可禁用)

outputDir

string

输出目录,图片保存为 PNG

file_to_images

将 Markdown/文本文件转换为图片。

参数

类型

必填

说明

filePath

string

Yes

文件路径 (.md/.txt)

title

string

覆盖自动提取的标题

theme

string

主题

generateAiCover

boolean

AI 封面(设置 API Key 后默认开启,传 false 可禁用)

outputDir

string

输出目录

estimate_pages

估算页数(不生成图片)。

list_themes

列出所有可用主题。

主题

主题

风格

适用场景

minimal

白底黑字,简约

知识干货、教程

elegant

米白衬线,书卷气

小说、散文、诗歌

warm

暖色渐变,卡片式

情感生活、分享

dark

深色护眼

夜间阅读、科技

环境变量

变量

说明

GEMINI_API_KEY

Google Gemini API Key,用于 AI 封面生成(设置后自动启用 AI 封面)

获取 API Key: https://aistudio.google.com/app/apikey

License

MIT

Available Tools

4 tools
estimate_pagesA

Estimate how many pages the text will be split into without generating images

ParametersJSON Schema
NameRequiredDescriptionDefault
textYesThe text content to estimate
ratioNo3:4
fontSizeNomedium
charsPerPageNoCustom characters per page

TDQS

A3.8/5.0
Behavior3/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 does disclose the key behavior that no images are generated, which is a significant trait distinguishing it from siblings. However, it does not mention any side effects, permissions, or what the function returns, leaving some behavioral aspects undisclosed.

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

Conciseness5/5

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

The description is a single, concise sentence front-loaded with the purpose: 'Estimate how many pages the text will be split into'. Every word earns its place, with no extraneous details or repetition of schema information.

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

Completeness4/5

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

Given the tool's simplicity, the description is largely complete for a single-purpose estimation tool. It clarifies the non-generation aspect and works with sibling names to frame its role. However, it lacks any mention of output format or edge cases, which would be more critical for a complex tool, but for this basic estimator it is sufficient.

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?

The input schema has 50% description coverage. The required 'text' parameter and 'charsPerPage' have descriptions, while 'ratio' and 'fontSize' lack descriptions but have enums and defaults that provide self-documenting semantics. The tool description itself adds no parameter-specific information, so it neither compensates nor detracts from the schema.

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

Purpose5/5

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

The description clearly states the tool's function: 'Estimate how many pages the text will be split into'. It specifies the verb (estimate) and resource (pages from text), and explicitly distinguishes from sibling tools by adding 'without generating images', which sets it apart from text_to_images and file_to_images.

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

Usage Guidelines3/5

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

The description implies usage context by stating 'without generating images', suggesting it is a non-rendering alternative to image generation tools. However, it does not explicitly state when to use it versus alternatives, nor does it provide exclusions or prerequisites. The guidance remains implicit rather than direct.

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

file_to_imagesA

Convert a local markdown or text file to a series of images. Supports .md, .txt, .text files. Automatically extracts title from the first # heading in markdown files. Cleans up markdown formatting for cleaner text display.

ParametersJSON Schema
NameRequiredDescriptionDefault
ratioNoImage aspect ratio3:4
themeNoVisual theme for the imagesminimal
titleNoOverride the auto-extracted title
filePathYesAbsolute path to the markdown or text file
fontSizeNoFont size for contentmedium
outputDirNoDirectory path to save generated images. If provided, images will be saved as PNG files.
showCoverNoWhether to generate a cover page (defaults to true for files)
charsPerPageNoCustom characters per page
generateAiCoverNoGenerate AI cover image using Gemini. Defaults to true if GEMINI_API_KEY is set. Set to false to disable.

TDQS

A3.9/5.0
Behavior3/5

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

With no annotations, the description carries the safety and behavior disclosure burden. It discloses input file types, markdown cleanup, and title extraction, but omits important runtime behavior such as what happens when outputDir is not provided (e.g., whether images are returned inline) and the potential side effect of writing PNG files. The mention of AI cover generation is absent, leaving a significant behavioral gap.

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

Conciseness5/5

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

The description is two sentences long, starts with the core purpose, and every sentence adds value. There is no redundancy or filler, making it highly scannable for an AI agent.

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?

The tool has 9 parameters, no output schema, and no annotations, so the description should clarify the output contract. It fails to explain whether the function returns image data, file paths, or requires outputDir for persistence. While the schema covers parameter semantics, the overall usage contract is incomplete for an agent to confidently invoke the tool.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3. The description adds meaningful context to parameters: 'Automatically extracts title from the first # heading in markdown files' clarifies the default behavior of the title parameter, and 'Cleans up markdown formatting for cleaner text display' explains the conversion process. This goes beyond pure schema descriptions and raises the score.

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

Purpose5/5

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

The description opens with a specific verb and resource ('Convert a local markdown or text file to a series of images') and clearly distinguishes this file-based tool from the sibling text_to_images by emphasizing local file input and supported extensions (.md, .txt, .text). This makes the tool's scope and differentiation immediately evident.

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

Usage Guidelines3/5

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

The description implies usage context (file input, markdown handling) but does not explicitly say when to choose this over alternatives like text_to_images or list_themes. It mentions auto-extraction of title from headings, which hints at markdown-centric usage, but offers no exclusions or when-not-to-use guidance.

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

list_themesA

List all available themes with descriptions

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations, the description carries the behavioral burden. It conveys that this is a read-only listing operation and that the result includes descriptions. It does not mention pagination, sorting, or potential volume, but for a simple list tool, this is sufficient transparency.

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

Conciseness5/5

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

The description is a single, concise sentence that is front-loaded with the action and object. Every word adds value; there is no fluff or repetition.

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

Completeness5/5

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

This is a zero-parameter, no-output-schema tool. The description fully explains what the tool does and what output to expect (themes with descriptions). Given its simplicity, no additional context is required.

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

Parameters4/5

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

The tool has zero parameters, so the baseline is 4. The description adds no parameter-level details, but none are needed since the schema already covers everything (100% schema description coverage, no parameters).

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

Purpose5/5

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

The description uses the specific verb 'List' with the resource 'themes' and specifies the content ('with descriptions'), clearly distinguishing it from sibling tools that deal with pages or images. It unambiguously states the tool's purpose and scope.

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

Usage Guidelines3/5

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

No explicit guidance is given about when to use this tool versus alternatives. The usage is implied: an agent would call it to discover available themes. However, there are no exclusions or alternative tool mentions, so it lacks clear usage direction.

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

text_to_imagesB

Convert text content to a series of images with Xiaohongshu (小红书) style themes.

Supported themes:

  • minimal: Clean white background, good for knowledge/tips content

  • elegant: Warm beige with serif font, good for novels/essays

  • warm: Warm gradient with card style, good for lifestyle/emotional content

  • dark: Dark mode, eye-friendly for night reading

Image ratios:

  • 3:4 (1080x1440): Best for Xiaohongshu feed, takes most screen space

  • 1:1 (1080x1080): Square format

  • 4:3 (1080x810): Landscape format

ParametersJSON Schema
NameRequiredDescriptionDefault
textYesThe text content to convert to images
ratioNoImage aspect ratio3:4
themeNoVisual theme for the imagesminimal
titleNoOptional title for cover page
fontSizeNoFont size for contentmedium
outputDirNoDirectory path to save generated images. If provided, images will be saved as PNG files.
showCoverNoWhether to generate a cover page
charsPerPageNoCustom characters per page (overrides automatic calculation)
generateAiCoverNoGenerate AI cover image using Gemini. Defaults to true if GEMINI_API_KEY is set. Set to false to disable.

TDQS

B3/5.0
Behavior2/5

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

No annotations are present, so the description must disclose behavioral traits. It only enumerates themes and ratios, but fails to mention return format, side effects (e.g., file creation via outputDir), authentication needs (e.g., Gemini API key for generateAiCover), or output structure. The description adds no behavioral context beyond the schema's parameter descriptions.

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 concise and well-structured: a one-sentence purpose immediately followed by clean bullet lists for themes and ratios. Every item earns its place by explaining the options. However, it omits important behavioral details, but that is a completeness issue, not a conciseness one. It is front-loaded and easy to scan.

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

Completeness2/5

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

With 9 parameters, no annotations, and no output schema, the description bears significant responsibility. It covers only two parameters (theme and ratio) and ignores the rest, including outputDir behavior, AI cover generation, font size, and the relationship between text length and pagination. Missing usage guidance and return format makes it incomplete for a tool of this complexity.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3. The description enriches the enum parameters 'theme' and 'ratio' with human-readable explanations and usage recommendations (e.g., 'minimal: Clean white background, good for knowledge/tips content'), which adds semantic value beyond the bare schema. Other parameters like outputDir and generateAiCover are not mentioned, but their schema descriptions are sufficient.

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: 'Convert text content to a series of images with Xiaohongshu style themes.' It uses a specific verb+resource construction that distinguishes it from typical image tools. However, it does not explicitly differentiate from sibling tools like file_to_images or estimate_pages, so it stops short of a 5.

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?

There is no guidance on when to use this tool versus the sibling tools (e.g., file_to_images, estimate_pages). The description provides context for theme/ratio selection but lacks any 'when to use' or 'when not to use' direction, leaving the agent to infer usage from the tool name alone.

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

TDQS

A3.9/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: estimating page count, listing themes, converting text to images, and converting files to images. There is no overlap in functionality, making selection unambiguous.

Naming Consistency4/5

Most tool names follow a descriptive pattern with underscores, but there is a mix of verb_noun (estimate_pages, list_themes) and noun_to_noun (text_to_images, file_to_images). This is a minor deviation from a fully consistent naming convention.

Tool Count5/5

With just 4 tools, the set is well-scoped for its purpose. Each tool is essential and contributes to the workflow without redundancy or bloat.

Completeness5/5

The tool set covers the full conversion lifecycle: estimating output size, selecting themes, and converting from two input methods (text and file). No critical operations are missing for the stated purpose.

Maintenance

ActivityInactive
ResponsivenessSyncing

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

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/dthinkr/xhs-image-mcp'

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