image-tools-mcp-server
v1.2.0
Published
MCP server for image optimization, thumbnail generation, and format conversion using ImageMagick
Downloads
10
Maintainers
Readme
Image Tools MCP Server
A Model Context Protocol (MCP) server that provides powerful image processing capabilities using ImageMagick. This server enables AI assistants to perform image optimization, thumbnail generation, format conversion, and batch processing operations.
Quick Install
# Install globally
npm install -g image-tools-mcp-server
# Or run directly without installing (recommended)
npx image-tools-mcp-serverThen add to your Q CLI MCP configuration:
{
"mcpServers": {
"image-tools": {
"command": "npx",
"args": ["image-tools-mcp-server"],
"env": {}
}
}
}Or if installed globally:
{
"mcpServers": {
"image-tools": {
"command": "image-tools-mcp-server",
"args": [],
"env": {}
}
}
}Note: The MCP server runs via stdio - Q CLI launches the server process and communicates with it through standard input/output.
Features
- Image Optimization: Reduce file sizes while maintaining quality
- Thumbnail Generation: Create thumbnails with flexible sizing options
- Icon Creation: Generate icons in standard sizes (16x16, 32x32, 64x64, 128x128, 256x256)
- Format Conversion: Convert between popular image formats (JPG, PNG, WebP, GIF, BMP, TIFF, ICO)
- Image Information: Extract detailed metadata and properties
- Batch Processing: Process multiple images in directories
Prerequisites
ImageMagick Installation
This server requires ImageMagick to be installed on your system.
macOS
# Using Homebrew
brew install imagemagick
# Using MacPorts
sudo port install ImageMagickUbuntu/Debian
sudo apt-get update
sudo apt-get install imagemagickWindows
Download and install from: https://imagemagick.org/script/download.php#windows
Verify Installation
magick -versionNode.js
Requires Node.js 18.0.0 or higher.
Installation
Option 1: Install via npm (Recommended)
# Install globally
npm install -g image-tools-mcp-server
# Or run directly with npx (no installation required)
npx image-tools-mcp-serverOption 2: Install from source
- Clone the repository:
git clone https://github.com/jon-the-dev/image-tools-mcp-server.git
cd image-tools-mcp-server- Install dependencies:
npm install- Test the installation:
npm startConfiguration
Adding to Q CLI
To use this MCP server with Amazon Q CLI, add it to your MCP configuration:
If using npx (recommended - no installation required):
{
"mcpServers": {
"image-tools": {
"command": "npx",
"args": ["image-tools-mcp-server"],
"env": {}
}
}
}If installed globally:
{
"mcpServers": {
"image-tools": {
"command": "image-tools-mcp-server",
"args": [],
"env": {}
}
}
}If running from source:
{
"mcpServers": {
"image-tools": {
"command": "node",
"args": ["/path/to/image-tools-mcp-server/src/index.js"],
"env": {}
}
}
}Environment Variables
No environment variables are required for basic operation.
Available Tools
1. optimize_image
Optimize an image to reduce file size while maintaining quality.
Parameters:
inputPath(required): Path to the input image fileoutputPath(required): Path for the optimized output imagequality(optional): Quality level (1-100, default: 85)maxWidth(optional): Maximum width in pixelsmaxHeight(optional): Maximum height in pixels
Example:
{
"inputPath": "/path/to/image.jpg",
"outputPath": "/path/to/optimized.jpg",
"quality": 80,
"maxWidth": 1920,
"maxHeight": 1080
}2. create_thumbnail
Create a thumbnail from an image with specified dimensions.
Parameters:
inputPath(required): Path to the input image fileoutputPath(required): Path for the thumbnail outputwidth(required): Thumbnail width in pixelsheight(required): Thumbnail height in pixelsmaintainAspectRatio(optional): Whether to maintain aspect ratio (default: true)cropToFit(optional): Whether to crop to fit exact dimensions (default: false)
Example:
{
"inputPath": "/path/to/image.jpg",
"outputPath": "/path/to/thumbnail.jpg",
"width": 300,
"height": 200,
"maintainAspectRatio": true,
"cropToFit": false
}3. create_icon
Create icons in standard sizes from an image.
Parameters:
inputPath(required): Path to the input image fileoutputDir(required): Directory to save icon filessizes(optional): Array of icon sizes to generate (default: [16, 32, 64, 128, 256])format(optional): Output format (png, ico, default: png)
Example:
{
"inputPath": "/path/to/logo.png",
"outputDir": "/path/to/icons/",
"sizes": [16, 32, 64, 128, 256],
"format": "png"
}4. convert_format
Convert an image from one format to another.
Parameters:
inputPath(required): Path to the input image fileoutputPath(required): Path for the converted output imageformat(required): Target format (jpg, png, webp, gif, bmp, tiff)quality(optional): Quality level for lossy formats (1-100, default: 90)
Example:
{
"inputPath": "/path/to/image.png",
"outputPath": "/path/to/image.webp",
"format": "webp",
"quality": 85
}5. get_image_info
Get detailed information about an image file.
Parameters:
imagePath(required): Path to the image file
Example:
{
"imagePath": "/path/to/image.jpg"
}6. batch_optimize
Optimize multiple images in a directory.
Parameters:
inputDir(required): Directory containing images to optimizeoutputDir(required): Directory to save optimized imagesquality(optional): Quality level (1-100, default: 85)maxWidth(optional): Maximum width in pixelsmaxHeight(optional): Maximum height in pixelsextensions(optional): File extensions to process (default: [jpg, jpeg, png, webp])
Example:
{
"inputDir": "/path/to/input/images/",
"outputDir": "/path/to/output/images/",
"quality": 80,
"maxWidth": 1920,
"extensions": ["jpg", "jpeg", "png", "webp"]
}Usage Examples
Basic Image Optimization
# After installing and configuring with Q CLI
q chat "Optimize the image at /Users/jon/photos/vacation.jpg and save it to /Users/jon/photos/vacation-optimized.jpg with 80% quality"Creating Thumbnails
q chat "Create a 300x200 thumbnail from /Users/jon/photos/landscape.jpg and save it to /Users/jon/photos/landscape-thumb.jpg"Batch Processing
q chat "Optimize all images in /Users/jon/photos/raw/ and save them to /Users/jon/photos/optimized/ with 85% quality"Getting Started
- Install:
npm install -g image-tools-mcp-server - Configure with Q CLI (see configuration section above)
- Start using:
q chat "Get image info for any image file"
Development
Running in Development Mode
npm run devProject Structure
image-tools-mcp-server/
├── src/
│ ├── index.js # Main MCP server
│ └── imageProcessor.js # ImageMagick wrapper
├── docs/ # Documentation
├── package.json
├── README.md
└── .gitignoreAdding New Features
- Add new tool definitions in
src/index.js - Implement the processing logic in
src/imageProcessor.js - Add corresponding handler methods in the main server class
- Update documentation
Error Handling
The server includes comprehensive error handling for:
- Missing ImageMagick installation
- Invalid file paths
- Unsupported image formats
- Processing failures
- Directory creation issues
Performance Considerations
- Large images may take significant time to process
- Batch operations process files sequentially to avoid memory issues
- Consider using appropriate quality settings to balance file size and image quality
- Monitor disk space when processing large batches
Supported Image Formats
Input formats: JPG, JPEG, PNG, WebP, GIF, BMP, TIFF, ICO Output formats: JPG, JPEG, PNG, WebP, GIF, BMP, TIFF, ICO
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and feature requests, please create an issue in the GitHub repository.
