Image Gen Server logo

Image Gen Server

Community
fengin

一个能与Cursor集成的图片生成mcp server工具,实现调用即梦逆向接口

Publisherfengin
Repositoryimage-gen-server
LanguagePython
Forks
30
Stars
229
Available tools
0
Transport typestdio
LicenseMIT
Links
  • Connect tools to AI workflows

    Image Gen Server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    229 stars and 30 forks from the linked repository.

MseeP.ai Security Assessment Badge

Image-Gen-Server

smithery badge

基于即梦AI的图像生成服务,专门设计用于与Cursor IDE集成。它接收来自Cursor的文本描述,生成相应的图像,并提供图片下载和保存功能。

此插件的开发过程可以看我的网站:开发一个MCP Server与Cursor集成,给Cursor插上翅膀!

更多AI知识,见AI全书(https://aibook.ren)

特性

  • 与Cursor IDE完美集成
  • 支持文本到图像的生成
  • 自动保存生成的图像
  • 支持自定义保存路径
  • 一次生成四张图,供更多选择

安装

Installing via Smithery

To install Image-Gen-Server for Claude Desktop automatically via Smithery:

bash
npx -y @smithery/cli install @fengin/image-gen-server --client claude
  1. 环境准备,MCP比较新的东西,依赖环境版本都比较新
  • python 3.10+

  • 安装npm

  • 安装nodejs(实测v15 v16都不行,开发环境验证v20可以,其他未验证)

  • 安装 pip install uv

  • 如果要调试,还需要安装这个:npm install -g @modelcontextprotocol/inspector@0.4.0

  1. 克隆项目

    bash
    git clone https://github.com/fengin/image-gen-server.git
    cd image-gen-server
  2. 安装依赖

    bash
    pip install -r requirements.txt
    pip install uv
  3. 设置即梦Token和图片默认保存地址 修改server.py文件里面这两个配置

    bash
    # API配置
    JIMENG_API_TOKEN = "057f7addf85dxxxxxxxxxxxxx" # 你登录即梦获得的session_id,支持多个,在后面用逗号分隔   
    IMG_SAVA_FOLDER = "D:/code/image-gen-server/images" # 图片默认保存路径

    

Cursor集成

  1. 打开Cursor设置

    • 点击左下角的设置图标
    • 选择 Features > MCP Servers
    • 点击 "Add new MCP server"
  2. 填写服务器配置

    • Name: image-gen-server(或其他你喜欢的名称)

    • Type: command

    • Command:

      bash
      uv run --with fastmcp fastmcp run D:\code\image-gen-service\server.py

      注意:将路径替换为你的实际项目路径

      • Windows示例: uv run --with fastmcp fastmcp run D:/code/image-gen-service/server.py
      • macOS/Linux示例: uv run --with fastmcp fastmcp run /Users/username/code/image-gen-server/server.py

      windows路径问题比较多,D:/code/image-gen-server/server.py 各种斜杠都试下

      填写完后,会弹出一个黑窗口,然后你就可以叫Cursor给你生成需要的图片了,目前黑窗口会一直运行,目前还没办法解决弹出这个的问题

使用方法

在Cursor中,你要让cursor生成图片,在agent模式下,你提示它了解下图片工具使用方法,然后直接提你要生成的图片要求,保存位置就行了

获取即梦Token

  1. 访问 即梦
  2. 登录账号
  3. 按F12打开开发者工具
  4. 在Application > Cookies中找到sessionid
  5. 将找到的sessionid设置到server.py的JIMENG_API_TOKEN中

工具函数说明

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]:
    """根据文本描述生成图片

    Args:
        prompt: 图片的文本prompt描述
        file_name: 生成图片的文件名(不含路径,如果没有后缀则默认使用.jpg)
        save_folder: 图片保存绝对地址目录(可选,默认使用IMG_SAVA_FOLDER)
        sample_strength: 生成图片的精细度(可选,范围0-1,默认0.5)
        width: 生成图片的宽度(可选,默认1024)
        height: 生成图片的高度(可选,默认1024)

    Returns:
        List: 包含生成结果的JSON字符串
    """

技术实现

  1. server.py采用了fastmcp实现了mcp sever的能力,提供给cursor/claude使用

    2.sever.py调用了proxy.jimeng模块逆向与即梦AI进行交互。 proxy.jimeng逆向模块也可以单独install使用,主要提供了以下主要功能:

  • 图像生成(generate_images)
  • 同步对话补全(create_completion)
  • 流式对话补全(create_completion_stream)
  • 多账号token支持
  • 完整的错误处理

更多详细信息请参考proxy/jimeng/README.md。

使用示例

cmd
# cursor agent模式下
#例子一
根据提供过你的项目需求,帮我生成一张产品logo,放在项目目录images下面

#例子二
根据项目需求,帮我制作网站的首页,头部需要有banner图片。

许可证

MIT License 作者:凌封

故障排除

1.配置完后跳出黑窗口,很快消失,工具状态变成No tools found

原因:没有正常启动,一般有以下原因

  • 配置命令不对,检查命令是否正确,一般是server.py路径不对,或者路径中包含中文,或者正反斜杠不对
  • 依赖的环境没准备好
  • 依赖运行的终端不对,像我windows的,终端有git bash,cmd,powershell,wsl等,这些终端都试下,cursor配置我这默认终端是cmd,如果你在这对应终端运行报错,一般是环境没装好,安装环境就可以

2.正常运行后,想看调用日志,或者调试怎么弄

命令改成以下:

uv run --with fastmcp fastmcp dev D:/code/image-gen-service/server.py

即把最后一个run 改成 dev。

或者找个终端运行以下命令进入调试模式:

fastmcp dev D:/code/image-gen-service/server.py

会有一个调试地址输出:http://localhost:5173/,你可以浏览器打开这地址MCP Inspector进行调试,具体MCP Inspector怎么使用,可以看官方文档

Use Image Gen Server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Image Gen Server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Image Gen Server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Image Gen Server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "image-gen-server": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Image Gen Server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Image Gen Server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Image Gen Server to help me with this task?
Image Gen Server
Sure. I read it.
Here is what I found using Image Gen Server.

Frequently asked questions

What is the Image Gen Server MCP server used for?

Image Gen Server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Image Gen Server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Image Gen Server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Image Gen Server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Image Gen Server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Image Gen Server MCP to TypingMind?

Image Gen Server runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Image Gen Server MCP provide in TypingMind?

Image Gen Server exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Image Gen Server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Image Gen Server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇