Labsco
rmcendarfer2017 logo

Image Generator

from rmcendarfer2017

Generate and save images using the Replicate API.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredAdvanced setup

Image Generator MCP Server

An MCP server that uses Replicate to generate images and allows users to save them.

Components

Resources

The server implements an image storage system with:

  • Custom image:// URI scheme for accessing individual generated images
  • Each image resource has a name based on its prompt, description with creation date, and image/png mimetype

Prompts

The server provides a single prompt:

  • generate-image: Creates prompts for generating images using Stable Diffusion
    • Optional "style" argument to control the image style (realistic/artistic/abstract)
    • Generates a prompt template with style-specific guidance

Tools

The server implements three tools:

  • generate-image: Generates an image using Replicate's Stable Diffusion model
    • Takes "prompt" as a required string argument
    • Optional parameters include "negative_prompt", "width", "height", "num_inference_steps", and "guidance_scale"
    • Returns the generated image and its URL
  • save-image: Saves a generated image to the local filesystem
    • Takes "image_url" and "prompt" as required string arguments
    • Generates a unique ID for the image and saves it to the "generated_images" directory
  • list-saved-images: Lists all saved images
    • Returns a list of all saved images with their metadata and thumbnails

Development

Building and Publishing

To prepare the package for distribution:

  1. Sync dependencies and update lockfile:
uv sync
  1. Build package distributions:
uv build

This will create source and wheel distributions in the dist/ directory.

  1. Publish to PyPI:
uv publish

Note: You'll need to set PyPI credentials via environment variables or command flags:

  • Token: --token or UV_PUBLISH_TOKEN
  • Or username/password: --username/UV_PUBLISH_USERNAME and --password/UV_PUBLISH_PASSWORD

Debugging

Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.

You can launch the MCP Inspector via npm with this command:

npx @modelcontextprotocol/inspector uv --directory B:\NEWTEST\image-generator run image-generator

Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.