iRAG MCP Server
The iRAG MCP Server enables image generation via Baidu's iRAG API through a standardized MCP interface. It allows MCP clients like Claude Desktop to generate custom images with these capabilities:
Generate images from text prompts with optional reference images
Select image quantity (1-4 images)
Choose from multiple dimensions (512x512, 768x768, 1024x768, 1024x1024, 1536x1536, 2048x1152, etc.)
Switch between models:
irag-1.0(Baidu's proprietary model) orflux.1-schnell(faster with advanced controls)Customize advanced parameters for the
flux.1-schnellmodel:Set random seed for reproducible results
Configure sampling steps (1-50)
Adjust guidance density (0-30)
Configure resource handling (local storage or URL/base64 data)
Utilize automatic retry mechanisms for failed API requests
Enable detailed logging for debugging
Integrates with Baidu's iRAG image generation API to create images using different models (irag-1.0, flux.1-schnell), with support for various parameters like size, steps, seed, and guidance.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@iRAG MCP Servergenerate an image of a sunset over mountains with a lake"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
百度iRAG MCP服务器
一个基于百度iRAG图片生成API的MCP(Model Context Protocol)服务器,允许MCP客户端(如Claude Desktop)通过标准化接口调用百度的图片生成服务。
🚨 重要提醒
在使用前,请务必进行真实API测试!
基础测试只验证服务器启动,要确保完全可用,需要:
获取真实的百度API Key
运行
npm run test:api进行真实API测试验证图片生成和Base64转换功能
详细设置指南请查看:FINAL_SETUP.md
Related MCP server: Gemini MCP Server for Claude Desktop
功能特性
🎨 支持百度iRAG图片生成API
🔧 完整的MCP协议实现
📝 支持多种模型(irag-1.0, flux.1-schnell)
🖼️ 灵活的图片尺寸配置
🔄 自动重试机制
📊 完善的日志记录
✅ 全面的参数验证
🧪 完整的测试覆盖
支持的模型
irag-1.0: 百度自研的图片生成模型
flux.1-schnell: 支持更多高级参数的快速生成模型
安装
前置要求
Node.js >= 18.0.0
npm 或 yarn
克隆项目
git clone <repository-url>
cd irag-mcp-server安装依赖
npm install构建项目
npm run build配置
1. 获取百度API Key
访问百度智能云控制台
创建API Key并选择千帆ModelBuilder
配置对应的应用资源
复制API Key(格式:
bce-v3/ALTAK-****/****)
2. 环境变量配置
复制环境变量模板:
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图片保存配置说明
RESOURCE_MODE=local: 图片将保存到本地文件系统,同时返回base64数据和文件路径
RESOURCE_MODE=url: 仅返回图片URL和base64数据,不保存本地文件
BASE_PATH: 自定义图片保存路径,留空则使用默认路径(用户桌面/irag-images文件夹)
MODEL: 设置默认使用的图片生成模型
irag-1.0: 百度自研模型,通用性好,速度快flux.1-schnell: 支持更多高级参数,质量更高
使用方法
启动服务器
# 开发模式
npm run dev
# 生产模式
npm startMCP客户端配置
Claude Desktop配置
在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"
}
}
}
}API参考
generate_image 工具
生成图片的MCP工具。
参数
参数名 | 类型 | 必需 | 默认值 | 描述 |
| string | ✅ | - | 图片生成提示词 |
| string | ❌ | - | 参考图片URL |
| integer | ❌ | 1 | 生成图片数量(1-4) |
| string | ❌ | 1024x1024 | 图片尺寸 |
| integer | ❌ | - | 采样步数(1-50,仅flux.1-schnell) |
| integer | ❌ | - | 随机种子(仅flux.1-schnell) |
| 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无效
确保API Key格式正确:
bce-v3/ALTAK-****/****检查API Key是否已配置千帆ModelBuilder资源
连接超时
检查网络连接
增加
API_TIMEOUT配置值
图片生成失败
检查提示词是否符合要求
确认模型参数配置正确
Base64验证错误
服务器会自动下载图片并转换为base64格式
如果下载失败,会返回错误信息和原始URL
检查网络连接和图片URL的可访问性
MCP客户端连接问题
确保Claude Desktop配置文件路径正确
检查Node.js版本(需要>=18.0.0)
验证项目已正确构建(运行
npm run build)
日志调试
设置日志级别为debug:
LOG_LEVEL=debug查看详细的API调用日志和图片下载过程。
许可证
MIT License
贡献
欢迎提交Issue和Pull Request!
更新日志
v1.0.0
初始版本发布
支持百度iRAG图片生成API
完整的MCP协议实现
支持多种模型和参数配置
Available Tools
1 toolgenerate_imageC
使用百度iRAG API生成图片
| Name | Required | Description | Default |
|---|---|---|---|
| guidance | No | 指导密度值(仅flux.1-schnell模型支持),默认为3.5 | |
| n | No | 生成图片数量,默认为1 | |
| prompt | Yes | 图片生成提示词,描述要生成的图片内容 | |
| refer_image | No | 参考图片URL(可选) | |
| seed | No | 随机种子(仅flux.1-schnell模型支持) | |
| size | No | 图片尺寸,默认为1024x1024 | 1024x1024 |
| steps | No | 采样步数(仅flux.1-schnell模型支持) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. However, it only states the basic action without any behavioral traits such as rate limits, authentication needs, cost implications, output format, or error handling. This is inadequate for a tool with 7 parameters and no output schema.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence with no wasted words. It is appropriately sized and front-loaded, directly stating the tool's function. Every part of the description earns its place by conveying the essential action and API source.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (7 parameters, no output schema, no annotations), the description is incomplete. It lacks crucial context such as behavioral traits, usage guidelines, and output details. Without annotations or an output schema, the description should provide more information to help the agent understand how to use the tool effectively, but it falls short.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, meaning all parameters are documented in the input schema. The description adds no additional meaning beyond what the schema provides, as it doesn't mention any parameters. With high schema coverage, the baseline score is 3, reflecting that the description doesn't compensate but also doesn't need to given the schema's completeness.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description '使用百度iRAG API生成图片' (Use Baidu iRAG API to generate images) states the general action but is vague. It specifies the API provider (Baidu iRAG) and the outcome (generate images), but lacks a specific verb+resource combination and doesn't differentiate from potential siblings (though none exist). The purpose is clear at a high level but lacks detail about what type of image generation this is.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any context, prerequisites, or exclusions. With no sibling tools, this is less critical, but the description still fails to offer any usage instructions or scenarios, leaving the agent without direction.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
With only one tool, there is no possibility of ambiguity or overlap between tools. The tool's purpose is clearly defined as generating images using the iRAG API.
A single tool inherently has perfect naming consistency, as there are no other tools to compare against. The name 'generate_image' follows a clear verb_noun pattern.
One tool is too few for a server named 'iRAG MCP Server', which suggests a broader scope related to retrieval-augmented generation. This feels thin and limits functionality to just image generation.
The server is severely incomplete; it only offers image generation, missing core iRAG operations like querying, retrieving information, or text generation. This gap will likely cause agent failures in typical iRAG workflows.
Maintenance
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
MCP server for Qwen Image 3 AI image generation
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
Related MCP Servers
FlicenseBqualityDmaintenanceA Model Context Protocol server that enables Claude to generate and upscale images through the Letz AI API, allowing users to create images directly within Claude conversations.22- AlicenseBqualityFmaintenanceA server that enables Claude Desktop to generate images using Google's Gemini AI models through the Model Context Protocol (MCP).107019MIT
- FlicenseAqualityDmaintenanceA Model Context Protocol server that enables Claude to display and interact with images from the local filesystem, allowing users to view images directly in conversations and retrieve image metadata.35
- AlicenseDqualityDmaintenanceA Model Context Protocol server that enables searching for similar images by text description, integrating Inspire's backend image search capabilities with LLM interfaces like Claude Desktop.13GPL 3.0
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/kuai0901/irag-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server