占位符图像生成器MCP服务器
使用HTML5 Canvas生成可定制占位符图像的模型上下文协议(MCP)服务器。
特性
- 灵活的尺寸:生成1x1到4096x4096像素的图像
- 自定义颜色:支持十六进制、RGB和命名颜色
- 智能文本渲染:自动调整字体大小和换行
- 对比度检测:自动选择对比文本颜色
- 多种格式:输出PNG和JPEG图像
- 错误验证:具有有用错误消息的全面输入验证
安装
npm install
npm run build用法
这是一个MCP服务器,旨在与兼容MCP的客户端(如Claude for Desktop)一起使用。
工具:生成占位符图像
使用以下参数生成占位符图像:
filename(string):输出文件名,扩展名为(.png、.jpg、.jpeg)width(数字):图像宽度(像素)(1-4096)height(数字):图像高度(像素)(1-4096)color(string):背景颜色(十六进制,如#FF0000,rgb,如rgb(255,0,0),或命名颜色,如“红色”)text(string):要在图像上显示的文本
示例
{
"filename": "placeholder.png",
"width": 800,
"height": 600,
"color": "#3498db",
"text": "Sample Placeholder"
}桌面版Claude的配置
将以下内容添加到您的Claude桌面配置中:
视窗
{
"mcpServers": {
"placeholder-generator": {
"command": "node",
"args": ["D:\\path\\to\\generate-placeholder\\build\\index.js"]
}
}
}macOS/Linux
{
"mcpServers": {
"placeholder-generator": {
"command": "node",
"args": ["/absolute/path/to/generate-placeholder/build/index.js"]
}
}
}发展
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run dev技术细节
- 使用TypeScript和MCP SDK构建
- 使用
canvas服务器端图像生成库 - 为MCP通信实现stdio传输
- 基于图像尺寸的自动文本缩放
- 带换行功能的多行文本支持
支持的颜色格式
- 十六进制:
#FF0000,#f00 - 红绿蓝:
rgb(255, 0, 0) - 颜色值:
rgba(255, 0, 0, 0.5) - 命名:
red,blue,green,yellow,orange,purple,pink,brown,black,white,gray
许可证
国际协调委员会
