AI 图像生成服务集成Cursor IDE支持文本到图像自动保存自定义路径
The Image-Gen-Server MCP Server, built specifically for integration with Cursor IDE and powered by即梦AI (Aidream AI), transforms textual descriptions into visual images. Designed as a middleware to connect advanced AI applications like Claude Desktop and Continue, it bridges the gap between text-based prompts and image generation, offering robust features such as automatic image saving, custom save paths, and multiple output capabilities.
The Image-Gen-Server leverages Model Context Protocol (MCP) for seamless integration. It supports various AI applications through its versatile MCP client compatibility matrix, ensuring broad adoption across the ecosystem. Key functionalities include:
The server uses uv
for running the MCP protocol and executes commands to generate images based on provided text prompts. This process involves setting up APIs, image generation, and handling responses efficiently.
Upon receiving a prompt from an AI application, it triggers the generation of one or more images, which are then saved in configured directories. The server uses asynchronous programming for efficient processing and returns results promptly to the calling application.
The generate_image
function, defined within server.py
, encapsulates the logic for generating images based on detailed text prompts. This function takes parameters such as prompt, file name, sample strength, width, and height to produce high-quality outputs.
async def generate_image(prompt: str, file_name: str, save_folder: str = None, sample_strength: float = 0.5, width: int = 1024, height: int = 1024) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
"""Generate an image based on a text prompt
Args:
prompt: Text description of the desired image.
file_name: Name of the generated image (excluding extension; defaults to .jpg).
save_folder: Absolute path for saving images (default uses IMG_SAVA_FOLDER).
sample_strength: Image generation quality parameter (0-1 range, default 0.5).
width: Width resolution of the generated image (default 1024).
height: Height resolution of the generated image (default 1024).
Returns:
List: Generated content including text and image resources.
"""
The core architecture of Image-Gen-Server is built around MCP, ensuring compatibility with various AI applications. It follows a client-server model where MCP clients (such as Cursor) initiate interactions by sending text prompts to the server.
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
graph TD
M[Model Context] -->|MCP Protocol| S[MCP Server]
S -> G[Graphics Server] -- API Call --> P[Parameterized Prompt]
P -.-> I[Image Generation] -.-> O[Output Storage]
O --> R[Result] --> S
M --> S
To install Image-Gen-Server, follow these steps:
Prepare the Environment: Ensure you have Python 3.10+ and Node.js installed.
Install Dependencies:
git clone https://github.com/fengin/image-gen-server.git
cd image-gen-server
pip install -r requirements.txt
pip install uv
npm i -g @modelcontextprotocol/[\[email protected\]](/cdn-cgi/l/email-protection)
Set API Token and Default Image Path: Modify server.py
to include your JIMENG_API_TOKEN
and IMG_SAVA_FOLDER
.
根据项目需求,帮我生成一张产品logo,放在项目目录images下面。
根据项目需求,帮我制作网站的首页,头部需要有banner图片。
Open Cursor Settings:
Fill in Server Details:
Name
: image-gen-server
(or any preferred name).Type
: command
.Command
:
uv run --with fastmcp fastmcp run D:\code\image-gen-service\server.py
Black Window Issue: Ensure the command path is correctly configured, and use a compatible terminal.
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ |
Continue | ✅ | ✅ | ✅ |
Cursor | ❌ | ✅ | ❌ |
For debugging and advanced configurations:
dev
mode for detailed logs.uv run --with fastmcp fastmcp dev D:/code/image-gen-service/server.py
generate_image
function settings like sample strength and resolution.Stay updated by exploring the Model Context Protocol documentation and community forums for future updates and integrations. Image-Gen-Server provides a powerful foundation for developers aiming to bridge text-based prompts with advanced image generation, enhancing AI application workflows through comprehensive MCP integration.
This document aims to provide a detailed understanding of the Image-Gen-Server's capabilities and serves as a guide for developers looking to implement similar solutions in their AI applications.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods