image-tools-mcp
Image Tools MCP is a Model Context Protocol (MCP) service that retrieves image dimensions and compresses images from URLs and local files using the TinyPNG API. It supports converting images to formats like webp, jpeg/jpg, and png, providing detailed information on width, height, type, and compressi
kshern
Tools
get_image_size
Get the size of an image from URL
get_local_image_size
Get the size of a local image
compress_image_from_url
Compress a single image from URL using TinyPNG API (only supports image files, not folders)
compress_local_image
Compress a single local image file using TinyPNG API (only supports image files, not folders)
README
Image Tools MCP
A Model Context Protocol (MCP) service for retrieving image dimensions and compressing images, supporting both URL and local file sources.
Features
- Retrieve image dimensions from URLs
- Get image dimensions from local files
- Compress images from URLs using TinyPNG API
- Compress local images using TinyPNG API
- Convert images to different formats (webp, jpeg/jpg, png)
- Returns width, height, type, MIME type, and compression information
Example Results
download from figma url and compress
Usage
Using as an MCP Service
This service provides five tool functions:
get_image_size
- Get dimensions of remote imagesget_local_image_size
- Get dimensions of local imagescompress_image_from_url
- Compress remote images using TinyPNG APIcompress_local_image
- Compress local images using TinyPNG APIfigma
- Fetch image links from Figma API and compress them using TinyPNG API
Client Integration
To use this MCP service, you need to connect to it from an MCP client. Here are examples of how to integrate with different clients:
Using with Claude Desktop
- Install Claude Desktop from claude.ai/download
- Get TinyPNG API key: Visit TinyPNG and get your API key
- Configure Claude Desktop to use this MCP server by editing the configuration file:
{
"mcpServers": {
"image-tools": {
"command": "npx",
"args": ["image-tools-mcp"],
"env": {
"TINIFY_API_KEY": "<YOUR_TINIFY_API_KEY>",
"FIGMA_API_TOKEN": "<YOUR_FIGMA_API_TOKEN>"
}
}
}
}
- Restart Claude Desktop
- Ask Claude to get image dimensions: "Can you tell me the dimensions of this image: https://example.com/image.jpg"
- Ask Claude to compress an image: "Can you compress this image: https://example.com/image.jpg"
- Ask Claude to compress a local image: "Can you compress this image: D:/path/to/image.png"
- Ask Claude to compress a local image folder: "Can you compress this folder: D:/imageFolder"
- Ask Claude to fetch image links from Figma API: "Can you fetch image links from Figma API: https://www.figma.com/file/XXXXXXX"
Using with MCP Client Library
import { McpClient } from "@modelcontextprotocol/client";
// Initialize the client
const client = new McpClient({
transport: "stdio" // or other transport options
});
// Connect to the server
await client.connect();
// Get image dimensions from URL
const urlResult = await client.callTool("get_image_size", {
options: {
imageUrl: "https://example.com/image.jpg"
}
});
console.log(JSON.parse(urlResult.content[0].text));
// Output: { width: 800, height: 600, type: "jpg", mime: "image/jpeg" }
// Get image dimensions from local file
const localResult = await client.callTool("get_local_image_size", {
options: {
imagePath: "D:/path/to/image.png"
}
});
console.log(JSON.parse(localResult.content[0].text));
// Output: { width: 1024, height: 768, type: "png", mime: "image/png", path: "D:/path/to/image.png" }
// Compress image from URL
const compressUrlResult = await client.callTool("compress_image_from_url", {
options: {
imageUrl: "https://example.com/image.jpg",
outputFormat: "webp" // Optional: convert to webp, jpeg/jpg, or png
}
});
console.log(JSON.parse(compressUrlResult.content[0].text));
// Output: { originalSize: 102400, compressedSize: 51200, compressionRatio: "50.00%", tempFilePath: "/tmp/compressed_1615456789.webp", format: "webp" }
// Compress local image
const compressLocalResult = await client.callTool("compress_local_image", {
options: {
imagePath: "D:/path/to/image.png",
outputPath: "D:/path/to/compressed.webp", // Optional
outputFormat: "image/webp" // Optional: convert to image/webp, image/jpeg, or image/png
}
});
console.log(JSON.parse(compressLocalResult.content[0].text));
// Output: { originalSize: 102400, compressedSize: 51200, compressionRatio: "50.00%", outputPath: "D:/path/to/compressed.webp", format: "webp" }
// Fetch image links from Figma API
const figmaResult = await client.callTool("figma", {
options: {
figmaUrl: "https://www.figma.com/file/XXXXXXX"
}
});
console.log(JSON.parse(figmaResult.content[0].text));
// Output: { imageLinks: ["https://example.com/image1.jpg", "https://example.com/image2.jpg"] }
### Tool Schemas
#### get_image_size
```typescript
{
options: {
imageUrl: string // URL of the image to retrieve dimensions for
}
}
get_local_image_size
{
options: {
imagePath: string // Absolute path to the local image file
}
}
compress_image_from_url
{
options: {
imageUrl: string // URL of the image to compress
outputFormat?: "image/webp" | "image/jpeg" | "image/jpg" | "image/png" // Optional output format
}
}
compress_local_image
{
options: {
imagePath: string // Absolute path to the local image file
outputPath?: string // Optional absolute path for the compressed output image
outputFormat?: "image/webp" | "image/jpeg" | "image/jpg" | "image/png" // Optional output format
}
}
figma
{
options: {
figmaUrl: string // URL of the Figma file to fetch image links from
}
}
Technical Implementation
This project is built on the following libraries:
- probe-image-size - For image dimension detection
- tinify - For image compression via the TinyPNG API
- figma-api - For fetching image links from Figma API
Environment Variables
TINIFY_API_KEY
- Required for image compression functionality. Get your API key from TinyPNGFIGMA_API_TOKEN
- Required for fetching image links from Figma API. Get your API token from Figma
License
MIT
Recommended Servers
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Excel MCP Server
A Model Context Protocol server that enables AI assistants to read from and write to Microsoft Excel files, supporting formats like xlsx, xlsm, xltx, and xltm.
Playwright MCP Server
Provides a server utilizing Model Context Protocol to enable human-like browser automation with Playwright, allowing control over browser actions such as navigation, element interaction, and scrolling.
@kazuph/mcp-fetch
Model Context Protocol server for fetching web content and processing images. This allows Claude Desktop (or any MCP client) to fetch web content and handle images appropriately.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
Apple MCP Server
Enables interaction with Apple apps like Messages, Notes, and Contacts through the MCP protocol to send messages, search, and open app content using natural language.
contentful-mcp
Update, create, delete content, content-models and assets in your Contentful Space
serper-search-scrape-mcp-server
This Serper MCP Server supports search and webpage scraping, and all the most recent parameters introduced by the Serper API, like location.