This MCP server leverages the Jimeng AI platform to generate images directly from text prompts within the Cursor IDE. By integrating this tool, you can create images without leaving your development environment, with the generated images automatically saved to your specified directory.
Before installing the image generation server, ensure you have the following prerequisites:
git clone https://github.com/fengin/image-gen-server.git
cd image-gen-server
pip install -r requirements.txt
pip install uv
Open server.py
and modify the following configuration parameters:
# API Configuration
JIMENG_API_TOKEN = "057f7addf85dxxxxxxxxxxxxx" # Your Jimeng session_id, multiple tokens can be comma-separated
IMG_SAVA_FOLDER = "D:/code/image-gen-server/images" # Default path to save generated images
You can also install the Image-Gen-Server automatically via Smithery:
npx -y @smithery/cli install @fengin/image-gen-server --client claude
Open Cursor settings:
Enter the server configuration:
image-gen-server
(or any preferred name)command
uv run --with fastmcp fastmcp run /path/to/image-gen-server/server.py
Replace /path/to/image-gen-server/server.py
with your actual file path:
uv run --with fastmcp fastmcp run D:/code/image-gen-server/server.py
uv run --with fastmcp fastmcp run /Users/username/code/image-gen-server/server.py
Note: On Windows, try different slash styles if you encounter path issues.
Once configured, a terminal window will open, indicating the server is running. You can now use the image generation tool within Cursor.
In Cursor's agent mode, you can use prompts like:
Help me generate a product logo for my project and save it in the images directory.
Or:
Based on the project requirements, help me create a website header banner image.
To use this tool, you'll need a Jimeng session token:
sessionid
valueJIMENG_API_TOKEN
in server.pyasync def generate_image(
prompt: str,
file_name: str,
save_folder: str = None,
sample_strength: float = 0.5,
width: int = 1024,
height: int = 1024
) -> list:
"""Generate an image based on text description
Args:
prompt: Text prompt describing the image
file_name: Filename for the generated image (without path, .jpg is added if no extension)
save_folder: Absolute directory path to save the image (optional, defaults to IMG_SAVA_FOLDER)
sample_strength: Image generation fidelity (optional, range 0-1, default 0.5)
width: Generated image width (optional, default 1024)
height: Generated image height (optional, default 1024)
Returns:
List: Contains the generation results as JSON string
"""
If the terminal window appears and quickly disappears with "No tools found" status, check:
To view call logs or debug the application, modify the command:
uv run --with fastmcp fastmcp dev /path/to/image-gen-server/server.py
Or run this command in a terminal:
fastmcp dev /path/to/image-gen-server/server.py
This will provide a debugging URL (http://localhost:5173/) where you can open the MCP Inspector for debugging.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "image-gen-server" '{"command":"uv","args":["run","--with","fastmcp","fastmcp","run","path/to/server.py"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"image-gen-server": {
"command": "uv",
"args": [
"run",
"--with",
"fastmcp",
"fastmcp",
"run",
"path/to/server.py"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"image-gen-server": {
"command": "uv",
"args": [
"run",
"--with",
"fastmcp",
"fastmcp",
"run",
"path/to/server.py"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect