使用说明
拥抱脸部MCP服务器
MCP(模型上下文协议)服务器,提供对Hugging Face的AI图像生成模型的访问,包括稳定扩散。
特性
- 使用多个稳定扩散模型生成图像
- 支持负面提示和指导量表
- 在本地保存图像或以base64格式返回
- 检查API状态和令牌有效性
- 提供免费套餐(有价格限制)
可用型号
- 稳定扩散2.1:高品质通用型号
- 稳定扩散XL:最新、最先进的型号
- OpenJourney:中旅风格的艺术图像
- 梦幻般的扩散:幻想和艺术风格
- 任何v5:动漫/漫画风格的图像
安装
- 克隆此存储库:
git clone https://github.com/nikolausm/huggingface-mcp-server.git
cd huggingface-mcp-server
- 安装依赖项:
npm install
-
获取拥抱脸API代币:
- 转到https://huggingface.co/settings/tokens
- 创建新令牌(免费)
- 复制令牌
-
设置环境变量:
export HUGGINGFACE_TOKEN="your_token_here"
Claude桌面中的配置
添加到您的Claude Desktop配置(~/Library/Application Support/Claude/claude_desktop_config.json 在 macOS 上:
{
"mcpServers": {
"huggingface": {
"command": "node",
"args": ["/path/to/huggingface-mcp-server/index.js"],
"env": {
"HUGGINGFACE_TOKEN": "your_token_here"
}
}
}
}
用法
生成图像
// Basic usage
generate_image({
prompt: "a cute guinea pig in a garden, children's book illustration style"
})
// Advanced usage
generate_image({
prompt: "a beautiful landscape with mountains",
model: "stable-diffusion-xl",
negative_prompt: "ugly, blurry, low quality",
guidance_scale: 10,
save_path: "/tmp/landscape.png"
})
列出可用型号
list_models()
检查API状态
check_status()
免费等级限制
- 速率限制在每分钟约10-20个请求
- 某些型号可能有排队时间
- 对于生产用途,考虑升级到付费计划
获得更好结果的提示
- 要具体:“红色谷仓的水彩画”比“谷仓”效果更好
- 添加样式:包括“油画”、“铅笔素描”、“数字艺术”等艺术风格
- 使用负面提示:告诉模特要避免什么
- 调整引导比例:值越高(10-15),提示越紧密
例子
儿童图书插图
prompt: "cute guinea pig eating carrots, children's book illustration, watercolor style, soft colors"
negative_prompt: "realistic, photo, dark, scary"
教育图
prompt: "simple diagram of guinea pig anatomy, educational poster, labeled parts, clean design"
model: "stable-diffusion-xl"
许可证
麻省理工学院
作者
迈克尔·尼古拉斯