image-webp-mcp-server

ChrisTansey007/image-webp-mcp-server

3.2

If you are the rightful owner of image-webp-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Image-to-WebP MCP Server is a FastMCP server designed to convert images to WebP format with optional resizing capabilities.

Tools
  1. convert_image

    Convert a single image to WebP format with optional resizing.

  2. bulk_convert

    Convert multiple images to WebP format in a single request.

Image-to-WebP MCP Server

A FastMCP server that provides image conversion tools to convert images to WebP format with optional resizing capabilities.

Features

  • Single Image Conversion: Convert one image to WebP format
  • Bulk Image Conversion: Convert multiple images in a single request
  • Optional Resizing: Resize images while maintaining aspect ratio
  • Quality Control: Adjustable WebP quality settings
  • HTTP Transport: Accessible via HTTP for easy integration

Tools

1. convert_image

Convert a single image to WebP format with optional resizing.

Parameters:

  • image_path (str): Path to the input image
  • quality (int, default=80): WebP quality (0-100)
  • width (Optional[int]): Target width (maintains aspect ratio if height not specified)
  • height (Optional[int]): Target height (maintains aspect ratio if width not specified)

Returns: Dictionary with conversion details

2. bulk_convert

Convert multiple images to WebP format in a single request.

Parameters:

  • image_paths (List[str]): List of paths to input images
  • quality (int, default=80): WebP quality (0-100)
  • width (Optional[int]): Target width for all images
  • height (Optional[int]): Target height for all images

Returns: List of dictionaries with conversion details for each image

Installation

Prerequisites

  • Python 3.11+
  • pip or uv package manager

Install Dependencies

Using pip:

pip install fastmcp pillow

Using uv:

uv pip install fastmcp pillow

Usage

Running the Server

Local Development
python image_webp_mcp_server.py

The server will start on http://0.0.0.0:8000/mcp

Using Docker
  1. Build the Docker image:
docker build -t image-webp-mcp-server .
  1. Run the container:
docker run -p 8000:8000 -v /path/to/your/images:/images image-webp-mcp-server

Example Usage

Once the server is running, you can use any MCP-compatible client to access the tools:

Convert Single Image
{
  "tool": "convert_image",
  "arguments": {
    "image_path": "/path/to/image.jpg",
    "quality": 85,
    "width": 800
  }
}
Bulk Convert Images
{
  "tool": "bulk_convert",
  "arguments": {
    "image_paths": [
      "/path/to/image1.jpg",
      "/path/to/image2.png",
      "/path/to/image3.gif"
    ],
    "quality": 80,
    "width": 1200,
    "height": 800
  }
}

Supported Image Formats

The server supports all image formats that PIL (Python Imaging Library) can handle:

  • JPEG
  • PNG
  • GIF
  • BMP
  • TIFF
  • And many more

Configuration

Quality Settings

  • 0-100: WebP quality level
  • 80: Default quality (good balance of size and quality)
  • Higher values: Better quality, larger file size
  • Lower values: Smaller file size, reduced quality

Resizing Behavior

  • If both width and height are specified: Image is resized to exact dimensions
  • If only width is specified: Height is calculated to maintain aspect ratio
  • If only height is specified: Width is calculated to maintain aspect ratio
  • If neither is specified: Original dimensions are preserved

Error Handling

The server gracefully handles errors during conversion:

  • Invalid file paths
  • Unsupported image formats
  • File permission issues
  • Memory limitations

Errors are returned in the response with descriptive messages.

Development

Project Structure

image-webp-mcp-server/
ā”œā”€ā”€ image_webp_mcp_server.py  # Main server file
ā”œā”€ā”€ Dockerfile                # Docker configuration
ā”œā”€ā”€ requirements.txt          # Python dependencies
└── README.md                # This file

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments