Content
[](https://mseep.ai/app/fengin-image-gen-server)
# Image-Gen-Server
<div align="center">
<img src="images/logo_0.png" alt="Image-Gen-Server Logo" width="100%">
</div>
[](https://smithery.ai/server/@fengin/image-gen-server)
Image-Gen-Server is an image generation service based on JiMeng AI, specifically designed for integration with Cursor IDE. It receives text descriptions from Cursor, generates corresponding images, and provides functionality for downloading and saving images.
You can check out the development process of this plugin on my website: [Developing an MCP Server Integrated with Cursor, Giving Cursor Wings!](https://aibook.ren/archives/mcp-server-for-cursor)
For more AI knowledge, see the AI Book (https://aibook.ren).
<div align="center">
<img src="images/example.png" alt="Image-Gen-Server Example" width="100%">
</div>
## Features
- Perfect integration with Cursor IDE
- Supports text-to-image generation
- Automatically saves generated images
- Supports custom save paths
- Generates four images at once for more options
## Installation
### Installing via Smithery
To install Image-Gen-Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@fengin/image-gen-server):
```bash
npx -y @smithery/cli install @fengin/image-gen-server --client claude
```
1. Environment preparation: MCP is a relatively new technology, and the dependency environment versions are quite recent.
- Python 3.10+
- Install npm
- Install Node.js (versions 15 and 16 have been tested and do not work; version 20 has been verified in the development environment, others are unverified)
- Install with `pip install uv`
- If you want to debug, you also need to install this: `npm install -g @modelcontextprotocol/inspector@0.4.0`
2. Clone the project
```bash
git clone https://github.com/fengin/image-gen-server.git
cd image-gen-server
```
3. Install dependencies
```bash
pip install -r requirements.txt
pip install uv
```
4. Set JiMeng Token and default image save path
Modify these two configurations in the `server.py` file
```bash
# API Configuration
JIMENG_API_TOKEN = "057f7addf85dxxxxxxxxxxxxx" # Your session_id obtained from JiMeng, supports multiple, separated by commas
IMG_SAVA_FOLDER = "D:/code/image-gen-server/images" # Default image save path
```
## Cursor Integration
<div align="center">
<img src="images/cursor_config.png" alt="Cursor Configuration" width="100%">
</div>
1. Open Cursor settings
- Click the settings icon in the lower left corner
- Select Features > MCP Servers
- Click "Add new MCP server"
2. Fill in the server configuration
- Name: `image-gen-server` (or any name you prefer)
- Type: `command`
- Command:
```bash
uv run --with fastmcp fastmcp run D:\code\image-gen-service\server.py
```
Note: Replace the path with your actual project path
- Windows example: `uv run --with fastmcp fastmcp run D:/code/image-gen-service/server.py`
- macOS/Linux example: `uv run --with fastmcp fastmcp run /Users/username/code/image-gen-server/server.py`
There are many path issues on Windows, try various slashes for `D:/code/image-gen-server/server.py`.
After filling in, a black window will pop up, and then you can ask Cursor to generate the images you need. Currently, the black window will keep running, and there is no way to resolve this issue yet.
## Usage
In Cursor, to generate images, you need to prompt it to understand how to use the image tool in agent mode, and then directly state your image generation requirements and the save location.
## Obtaining JiMeng Token
1. Visit [JiMeng](https://jimeng.jianying.com/)
2. Log in to your account
3. Press F12 to open the developer tools
4. Find `sessionid` in Application > Cookies
5. Set the found `sessionid` in `server.py`'s `JIMENG_API_TOKEN`
## Function Descriptions
### generate_image
```python
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 the text description
Args:
prompt: The text prompt description for the image
file_name: The filename for the generated image (without path; defaults to .jpg if no suffix is provided)
save_folder: The absolute directory for saving the image (optional; defaults to IMG_SAVA_FOLDER)
sample_strength: The fineness of the generated image (optional; range 0-1; defaults to 0.5)
width: The width of the generated image (optional; defaults to 1024)
height: The height of the generated image (optional; defaults to 1024)
Returns:
List: A JSON string containing the generation results
"""
```
### Technical Implementation
1. `server.py` uses fastmcp to implement MCP server capabilities for Cursor/Claude.
2. `server.py` calls the `proxy.jimeng` module to interact with JiMeng AI in reverse. The `proxy.jimeng` reverse module can also be installed separately and provides the following main functionalities:
- Image generation (`generate_images`)
- Synchronous dialogue completion (`create_completion`)
- Streaming dialogue completion (`create_completion_stream`)
- Multi-account token support
- Comprehensive error handling
For more detailed information, please refer to `proxy/jimeng/README.md`.
### Usage Examples
```cmd
# In Cursor agent mode
# Example 1
Based on the project requirements you provided, help me generate a product logo and place it in the project directory under images.
# Example 2
Based on the project requirements, help me create the homepage of the website, with a banner image at the top.
```
## License
MIT License
Author: Ling Feng
## Troubleshooting
1. After configuration, a black window pops up and quickly disappears, and the tool status changes to "No tools found."
Reason: Did not start properly, generally due to the following reasons:
- Incorrect configuration command; check if the command is correct, usually the `server.py` path is incorrect, or the path contains Chinese characters, or the slashes are incorrect.
- The required environment is not prepared.
- The terminal for running dependencies is incorrect; for example, on Windows, there are terminals like Git Bash, CMD, PowerShell, WSL, etc. Try these terminals. My default terminal for Cursor configuration is CMD. If you encounter errors running in the corresponding terminal, it is usually due to the environment not being set up correctly; installing the environment should resolve it.
2. After running normally, if you want to see the call logs or debug, how to do it?
Change the command to the following:
```
uv run --with fastmcp fastmcp dev D:/code/image-gen-service/server.py
```
Just change the last `run` to `dev`.
Alternatively, find a terminal and run the following command to enter debug mode:
```
fastmcp dev D:/code/image-gen-service/server.py
```
A debug address will be output: `http://localhost:5173/`, which you can open in a browser to access the MCP Inspector for debugging. For specific usage of MCP Inspector, please refer to the official documentation.
You Might Also Like
OpenWebUI
Open WebUI is an extensible web interface for customizable applications.

NextChat
NextChat: A light and fast AI assistant supporting Claude, DeepSeek, GPT4 &...

Continue
Continue is an open-source project for enhancing MCP Server functionality.
semantic-kernel
Semantic Kernel is an SDK for building and deploying AI agents and systems.

repomix
Repomix packages codebases into AI-friendly formats for coding with multiple...
UI-TARS-desktop
UI-TARS-desktop is part of the TARS Multimodal AI Agent stack.