Generate images using Baidu's iRAG API through a standardized MCP interface.
一个基于百度iRAG图片生成API的MCP(Model Context Protocol)服务器,允许MCP客户端(如Claude Desktop)通过标准化接口调用百度的图片生成服务。
在使用前,请务必进行真实API测试!
基础测试只验证服务器启动,要确保完全可用,需要:
npm run test:api
进行真实API测试详细设置指南请查看:FINAL_SETUP.md
git clone <repository-url>
cd irag-mcp-server
npm install
npm run build
bce-v3/ALTAK-****/****
)复制环境变量模板:
cp .env.example .env
编辑 .env
文件:
# 必需配置
BAIDU_API_KEY=bce-v3/ALTAK-your-access-key/your-secret-key
# 图片资源配置
RESOURCE_MODE=local # local: 保存到本地文件 | url: 仅返回URL和base64
BASE_PATH= # 自定义保存路径(可选,默认为桌面/irag-images)
MODEL=irag-1.0 # 默认模型: irag-1.0 | flux.1-schnell
# 可选配置
SERVER_NAME=irag-mcp-server
SERVER_VERSION=1.0.0
LOG_LEVEL=info
LOG_FILE=logs/server.log
API_TIMEOUT=30000
MAX_RETRIES=3
irag-1.0
: 百度自研模型,通用性好,速度快flux.1-schnell
: 支持更多高级参数,质量更高# 开发模式
npm run dev
# 生产模式
npm start
在Claude Desktop的配置文件中添加:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"irag-image-generator": {
"command": "node",
"args": ["/path/to/irag-mcp-server/dist/index.js"],
"env": {
"BAIDU_API_KEY": "bce-v3/ALTAK-your-access-key/your-secret-key"
}
}
}
}
生成图片的MCP工具。
参数名 | 类型 | 必需 | 默认值 | 描述 |
---|---|---|---|---|
prompt | string | ✅ | - | 图片生成提示词 |
refer_image | string | ❌ | - | 参考图片URL |
n | integer | ❌ | 1 | 生成图片数量(1-4) |
size | string | ❌ | 1024x1024 | 图片尺寸 |
steps | integer | ❌ | - | 采样步数(1-50,仅flux.1-schnell) |
seed | integer | ❌ | - | 随机种子(仅flux.1-schnell) |
guidance | number | ❌ | 3.5 | 指导密度值(0-30,仅flux.1-schnell) |
注意: 模型通过配置文件的MODEL
参数设置,不在请求中指定。
512x512
, 768x768
, 1024x768
, 1024x1024
{
"name": "generate_image",
"arguments": {
"prompt": "一只可爱的橘猫坐在窗台上,阳光透过窗户洒在它身上",
"size": "1024x1024",
"n": 2
}
}
src/
├── client/ # API客户端
├── config/ # 配置管理
├── server/ # MCP服务器
├── types/ # 类型定义
├── utils/ # 工具函数
├── __tests__/ # 测试文件
└── index.ts # 主入口
# 开发模式运行
npm run dev
# 构建项目
npm run build
# 运行测试
npm test
# 监听测试
npm run test:watch
# 代码检查
npm run lint
# 修复代码风格
npm run lint:fix
# 清理构建文件
npm run clean
运行所有测试:
npm test
查看测试覆盖率:
npm test -- --coverage
API Key无效
bce-v3/ALTAK-****/****
连接超时
API_TIMEOUT
配置值图片生成失败
Base64验证错误
MCP客户端连接问题
npm run build
)设置日志级别为debug:
LOG_LEVEL=debug
查看详细的API调用日志和图片下载过程。
MIT License
欢迎提交Issue和Pull Request!
Single tool to control all 100+ API integrations, and UI components
Enables persistent memory for Claude using a local knowledge graph of entities, relations, and observations.
Interact with iOS simulators and devices using Facebook's iOS Development Bridge (idb).
Provides remote machine control capabilities, eliminating SSH overhead for token-efficient system operations.
A customizable MCP service with flexible tool selection and configuration. Requires a 302AI API key.
A server for managing structured project context using SQLite, with support for vector embeddings for semantic search and Retrieval Augmented Generation (RAG).
A TypeScript agent that integrates MCP servers with Ollama, allowing AI models to use various tools through a unified interface.
Run Python in a code sandbox.
Provides direct access to local documentation files through a context.md file in the project root.
Generates AI agent tools from Postman collections and requests using the Postman API.