Cover image
Try Now
2025-03-20

可用于光标集成MCP服务器

3 years

Works with Finder

1

Github Watches

2

Github Forks

13

Github Stars

AI 图像生成服务

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

功能特点

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

环境准备

1. Python 环境

# macOS 安装 pyenv
brew install pyenv

# 安装 Python
pyenv install 3.13.2
pyenv global 3.13.2

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. 依赖包是否完整安装

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Khalid kalib
  • Write professional emails

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • OffchainLabs
  • 进行以太坊的实施

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

    Reviews

    4 (1)
    Avatar
    user_t796bXcn
    2025-04-17

    I've been using mcp_generate_images for a while now, and it's truly impressive. The capabilities of this tool in generating realistic images are outstanding. The user-friendly interface and the seamless integration with different projects make it a top choice for image generation tasks. Kudos to chenyeju295 for creating such a versatile and powerful tool! Highly recommend checking it out on GitHub.