
这是一个使用Satori从React组件生成美丽图像的MCP(模型上下文协议)服务器。通过AI助手如Claude可以直接创建社交卡片、博客标题、引语和自定义图像。
<div> <a href="https://jellypod.ai"><img alt="jellypod logo" src="https://img.shields.io/badge/MADE%20BY%20jellypod.ai-000000.svg?style=for-the-badge&labelColor=000"></a> <a href="https://github.com/Jellypod-Inc/satori-mcp-server/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/LICENSE-MPL--2.0-blue?style=for-the-badge&labelColor=000000"></a> </div>git clone https://github.com/Jellypod-Inc/satori-mcp-server.git
cd satori-mcp-server
pnpm install
要使用托管版本的MCP服务器,请将其添加到您的Claude Desktop配置中:
{
"mcpServers": {
"satori": {
"type": "http",
"url": "https://satori.jellypod.ai/mcp"
}
}
}
# 启动带有热重载的开发服务器
pnpm dev
# 运行测试
pnpm test
# 运行特定测试
pnpm test:generate-image
pnpm test:generate-image-from-template
# 构建生产环境
pnpm build
# 启动生产服务器
pnpm start
要测试MCP服务器,请使用模型上下文协议(MCP)检查器:https://modelcontextprotocol.io/legacy/tools/inspector
您可以运行它:
pnpm dlx @modelcontextprotocol/inspector
然后启动本地MCP服务器,并在检查器中连接到localhost。
您需要配置Vercel Blob存储以保存生成的图像文件。 从您的Vercel仪表板获取此信息:https://vercel.com/docs/storage/vercel-blob
export const BLOB_READ_WRITE_TOKEN = process.env.BLOB_READ_WRITE_TOKEN;
generate_image从自定义JSX内容生成图像。
参数:
jsx (字符串,必需):作为字符串的JSX内容width (数字,默认值:600):图像宽度(像素)height (数字,默认值:400):图像高度(像素)outputPath (字符串,必需):保存图像的位置googleFonts (数组,可选):要加载的Google字体示例:
{
jsx: '<div style={{background: "linear-gradient(to right, #667eea, #764ba2)", width: "100%", height: "100%", display: "flex", alignItems: "center", justifyContent: "center"}}><h1 style={{color: "white", fontSize: "60px"}}>Hello World</h1></div>',
width: 1200,
height: 630,
outputPath: "output/hello.png",
googleFonts: [
{ name: "Inter", weight: 700, style: "normal" }
]
}
generate_from_template使用预构建模板生成图像。
参数:
template (字符串,必需):模板名称("social-card", "blog-header", "quote")params (对象,必需):特定于模板的参数outputPath (字符串,必需):保存图像的位置width (数字,可选):覆盖模板宽度height (数字,可选):覆盖模板高度示例:
{
template: "social-card",
params: {
title: "宣布Satori MCP服务器",
description: "使用AI生成美丽的图像",
backgroundColor: "#2563eb"
},
outputPath: "output/announcement.png"
}
list_templates列出所有可用模板及其描述。
无需参数
返回一个包含模板名称和描述的列表。
适合社交媒体分享卡片。
参数:
title (字符串,必需):主标题description (字符串,可选):辅助文本backgroundColor (字符串,可选):背景颜色(默认值:#1a1a1a)适用于博客文章标题。
参数:
title (字符串,必需):博客文章标题author (字符串,必需):作者姓名date (字符串,必需):发布日期category (字符串,可选):文章类别正方形格式用于励志引语。
参数:
quote (字符串,必需):引语文本author (字符串,可选):引语作者backgroundColor (字符串,可选):背景颜色在src/templates/中添加新模板:
import React from "react";
import type { Template } from "./index";
export const myTemplate: Template = {
name: "my-template",
description: "我的自定义模板",
defaultSize: { width: 1200, height: 630 },
googleFonts: [
{ name: "Inter", weight: 700, style: "normal" }
],
generate: (params: { title: string }) => {
return (
<div style={{
width: "100%",
height: "100%",
display: "flex",
alignItems: "center",
justifyContent: "center",
backgroundColor: "#000",
color: "#fff",
fontFamily: "Inter"
}}>
<h1>{params.title}</h1>
</div>
);
},
};
然后在src/templates/index.ts中注册它:
import { myTemplate } from "./my-template";
export const templates: Record<string, Template> = {
// ... 已有模板
"my-template": myTemplate,
};
项目包括对所有工具和模板的全面测试:
# 运行所有测试
pnpm test
# 测试输出保存在tests/output/
# 生成图像以验证实际功能
测试结构:
构建使用:
服务器不会响应base64编码的图像,而是将图像保存到Vercel Blob存储中,并响应指向对象的引用URL。大多数MCP客户端和响应都有大小限制。
该URL公开访问,但通过附加到文件名的大随机字符串进行混淆。
欢迎贡献!请随时提交拉取请求。
git checkout -b feature/amazing-feature)git commit -m '添加精彩功能')git push origin feature/amazing-feature)Mozilla公共许可证第2.0版 - 详情见LICENSE文件
对于问题和疑问,请使用GitHub Issues页面。