image-processing-server
v1.0.6
Published
An MCP server for image processing using JIMP library
Downloads
735
Readme
Image Processing MCP Server
A microservice for image processing based on FastMCP and Jimp, providing multiple image processing capabilities.
Introduction
The Image Processing MCP Server is a feature-rich image processing service that supports various common image operations, including resizing, cropping, rotating, drawing shapes, adding watermarks, edge detection, grayscale conversion, Gaussian blur, thresholding, and flipping. The service provides interfaces through the Model Context Protocol (MCP) and can be easily integrated into AI applications.
Features List
- Resize - Resize images to specified dimensions
- Crop - Crop a specified area of an image
- Rotate - Rotate images by a specified angle
- Draw Shape - Draw rectangles or circles on images
- Concatenate - Horizontally or vertically concatenate multiple images
- Edge Detection - Detect edges in images
- Grayscale - Convert images to grayscale
- Gaussian Blur - Apply Gaussian blur to images
- Threshold - Apply threshold processing to images
- Flip - Horizontally, vertically, or bidirectionally flip images
Installation and Running
Requirements
- Node.js (version 16 or higher)
- npm (usually installed with Node.js)
Installation Steps
Clone or download the project code
Navigate to the server directory:
cd serverInstall dependencies:
npm installCompile TypeScript code:
npm run build
Running the Server
npm startThe server will start on the default port and listen for MCP connections.
Tool Details
1. Resize
Resize an image to specified width and height.
Parameters:
imagePath: Image file path or URLwidth: Target widthheight: Target height
2. Crop
Crop a specified area of an image.
Parameters:
imagePath: Image file path or URLx: X-coordinate of the top-left corner of the crop areay: Y-coordinate of the top-left corner of the crop areawidth: Width of the crop areaheight: Height of the crop area
3. Rotate
Rotate an image by a specified angle.
Parameters:
imagePath: Image file path or URLdegrees: Rotation angle (0-360)
4. Draw Shape
Draw rectangles or circles on an image.
Parameters:
imagePath: Image file path or URLshape: Shape type ('rectangle' or 'circle')x: Starting point x-coordinatey: Starting point y-coordinatewidth: Shape widthheight: Shape heightcolor: Color (hexadecimal)
5. Concatenate
Horizontally or vertically concatenate multiple images.
Parameters:
imagePaths: Array of image pathsdirection: Concatenation direction ('horizontal' or 'vertical')
6. Edge Detection
Detect edges in an image.
Parameters:
imagePath: Image file path or URL
7. Grayscale
Convert an image to grayscale.
Parameters:
imagePath: Image file path or URL
8. Gaussian Blur
Apply Gaussian blur to an image.
Parameters:
imagePath: Image file path or URLradius: Blur radius
9. Threshold
Apply threshold processing to an image.
Parameters:
imagePath: Image file path or URLthresholdValue: Threshold value (0-255)
10. Flip
Horizontally, vertically, or bidirectionally flip an image.
Parameters:
imagePath: Image file path or URLdirection: Flip direction ('horizontal', 'vertical', 'both')
Usage Examples
After connecting to the server through an MCP client, you can call any of the above tools for image processing.
For example, to resize an image:
{
"tool": "resize",
"arguments": {
"imagePath": "/path/to/image.jpg",
"width": 800,
"height": 600
}
}Return Format
All tools return a unified JSON format:
{
"status": true,
"outputPath": "/path/to/output/image.jpg",
"imgData": "base64_encoded_image_data",
"error": ""
}status: Whether the operation was successfuloutputPath: Output file path (for local files)imgData: Base64 encoded image data (for web images)error: Error message (if any)
Technology Stack
- TypeScript
- FastMCP - Model Context Protocol framework
- Jimp - Image processing library
- Zod - Parameter validation library
