Navigation
AI Image Generation: Boost Creativity, Scale Workflows - MCP Implementation

AI Image Generation: Boost Creativity, Scale Workflows

AI-Powered Image Generation for Cursor MCP: Seamlessly integrate, boost creativity, and scale visual workflows for enterprise projects. Ready to innovate?" )

Developer Tools
4.6(196 reviews)
294 saves
137 comments

Ranked in the top 3% of all AI tools in its category

About AI Image Generation

What is AI Image Generation: Boost Creativity, Scale Workflows?

This service integrates Together AI’s image generation capabilities with the Cursor MCP platform to streamline creative workflows. By enabling customizable output parameters and robust error handling, it empowers users to efficiently produce high-quality images while maintaining control over resource allocation and project scalability.

How to Use AI Image Generation: Boost Creativity, Scale Workflows?

Start by configuring your development environment with Python 3.10+ and Node.js, then install the uv package manager. Obtain a Together AI API key via their portal and set up the provided repository using Git. Adjust configurations in mcp_server.py for image dimensions, output paths, and API parameters. Deploy the service in development or production mode using uv commands, then trigger image generation directly within the Cursor IDE’s composer interface.

AI Image Generation Features

Key Features of AI Image Generation: Boost Creativity, Scale Workflows?

Core functionalities include:

  • Adaptive Generation: Customize dimensions up to 1024x1024px and select output formats like PNG/JPG.
  • Batch Processing: Generate up to 4 images simultaneously to accelerate iterative design cycles.
  • Resilient Workflow: Automatic retries with delay backoff and granular error logging ensure stability during API failures.
  • Path Security: Enforce absolute path requirements and extension whitelisting to prevent misconfigurations.

Use Cases of AI Image Generation: Boost Creativity, Scale Workflows?

AI Image Generation FAQ

FAQ from AI Image Generation: Boost Creativity, Scale Workflows?

Q: How do I resolve "invalid API key" errors?
Verify the API key format matches "YOUR_API_KEY" and check network access to Together AI’s endpoints. Clear cached credentials if rotating keys.

Q: Why are images saved to unexpected locations?
Confirm the base_folder uses absolute paths (e.g., /Users/username/output) and verify write permissions via chmod.

Q: Can I generate larger images than 1024px?
Current model limitations restrict maximum dimensions to 1024x1024px. Monitor Together AI’s roadmap for upcoming high-resolution capabilities.

Content

AI 图像生成服务

基于 Together AI 的图像生成服务,专门设计用于与 Cursor MCP 服务集成。支持自定义图片大小、保存路径等功能。

功能特点

  • 支持高质量图像生成
  • 自动重试和错误处理
  • 支持批量生成多张图片
  • 完整的路径和权限验证
  • 详细的错误提示
  • 异步处理支持

环境准备

1. Python 环境

2. uv 包管理工具

uv 是一个快速的 Python 包管理器,需要先安装:

# macOS 安装 uv
brew install uv

# 或者使用 pip 安装
pip install uv

3. Together AI API 密钥

  1. 访问 Together AI API Keys
  2. 注册/登录账号
  3. 创建新的 API 密钥
  4. 复制密钥并保存,格式如:YOUR_API_KEY

4. Cursor

  • 下载并安装 Cursor IDE
  • 确保 Cursor 已正确配置 Python 环境

安装配置

  1. 克隆项目:
git clone [https://github.com/chenyeju295/mcp_generate_images.git]
  1. 安装依赖(cd 到mcp_generate_images 安装):
python3 -m pip install fastmcp requests

出现证书问题可以使用:

python3 -m pip install fastmcp requests --trusted-host pypi.org --trusted-host files.pythonhosted.org --upgrade --force-reinstall --no-cache-dir
  1. 配置 API 密钥:

mcp_server.py 中修改 TOGETHER_API_KEY

TOGETHER_API_KEY = "your_api_key_here"  # 替换为你的 Together AI API 密钥
  1. 配置服务:

mcp_server.py 中可以修改以下配置:

CONFIG = {
    "api": {
        "url": "https://api.together.xyz/v1/images/generations",
        "model": "black-forest-labs/FLUX.1-schnell-Free",
        "timeout": 30,
        "max_retries": 3,
        "retry_delay": 5
    },
    "image": {
        "max_width": 1024,
        "max_height": 1024,
        "default_width": 1024,
        "default_height": 1024,
        "default_steps": 2,
        "max_batch_size": 4
    },
    "output": {
        "base_folder": "你的默认保存路径",
        "allowed_extensions": [".png", ".jpg", ".jpeg"],
        "default_extension": ".png"
    }
}

运行服务

  1. 开发模式运行(带调试界面):
  • 运行检查是否成功:

    uv run --with fastmcp fastmcp dev /Users/username/Documents/mcp_generate_images/mcp_server.py

  1. 生产模式运行:
uv run --with fastmcp fastmcp run /Users/username/Documents/mcp_generate_images/mcp_server.py
  1. 如果端口被占用,可以指定其他端口:
PORT=5174 uv run --with fastmcp fastmcp dev /Users/username/Documents/mcp_generate_images/mcp_server.py

使用说明

在 Cursor IDE 中使用

  1. 确保服务正在运行
  2. 在 Cursor 中引入MCP:
  • 添加mcp 服务:

    uv run --with fastmcp fastmcp run /Users/username/Documents/mcp_generate_images/mcp_server.py

  • 如图(运行成功): image.png

  1. 在 Cursor 中使用:
  • 在composer 的 agent 模式下,直接输入相关的提示: image.png

错误排查

如果遇到问题,请检查:

  1. 服务是否正常运行
  2. 保存路径是否正确(必须是绝对路径)
  3. 目录权限是否正确
  4. 网络连接是否正常
  5. API 密钥是否有效
  6. Python 环境是否正确配置
  7. uv 是否正确安装
  8. 依赖包是否完整安装

Related MCP Servers & Clients