Image Tools Mcp について
Image Tools MCPは、URLまたはローカルファイルの画像サイズ確認と圧縮を行うMCPサービスです。出力形式の変換に加え、Figmaから画像リンクを取得して圧縮できます。
主な機能
- 01URL画像のサイズ取得
- 02ローカル画像のサイズ取得
- 03TinyPNGによるリモート画像圧縮
- 04TinyPNGによるローカル画像圧縮
- 05WebP、JPEG、PNGへの変換
- 06Figma画像の取得と圧縮
活用シーン
- 01リモート画像素材のサイズ確認
- 02納品用ローカル画像の圧縮
- 03Figmaの画像リンクの処理
MCP 対応
画像サイズの取得、URLまたはローカル画像の圧縮、Figmaの画像リンク取得と圧縮のツールをMCPクライアントに提供します。圧縮とFigmaのツールには、それぞれ対応するAPIキーが必要です。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
ツール
2掲載時のツール一覧 · 3 週間前に更新
| パラメーター | 型 | 必須 | 説明 |
|---|---|---|---|
| options | object | はい | 画像サイズを取得するためのオプション |
| options.imageUrl | string | はい | 取得する画像の URL |
詳細
Image Tools MCP
URL とローカルファイルの両方を対象に、画像サイズの取得と画像の圧縮を行う Model Context Protocol(MCP)サービスです。
機能
- URL から画像サイズを取得
- ローカルファイルから画像サイズを取得
- TinyPNG API を使用して URL の画像を圧縮
- TinyPNG API を使用してローカル画像を圧縮
- 画像を異なる形式(webp、jpeg/jpg、png)に変換
- 幅、高さ、形式、MIME タイプ、圧縮情報を返します
結果の例


figma の URL からダウンロードして圧縮

使い方
MCP サービスとして使用
このサービスは、次の 5 つのツール関数を提供します。
get_image_size- リモート画像のサイズを取得get_local_image_size- ローカル画像のサイズを取得compress_image_from_url- TinyPNG API を使用してリモート画像を圧縮compress_local_image- TinyPNG API を使用してローカル画像を圧縮figma- Figma API から画像リンクを取得し、TinyPNG API を使用して圧縮
クライアントとの統合
この MCP サービスを使用するには、MCP クライアントから接続する必要があります。異なるクライアントとの統合例を以下に示します。
使い方
{
"mcpServers": {
"image-tools": {
"command": "npx",
"args": ["image-tools-mcp"],
"env": {
"TINIFY_API_KEY": "<YOUR_TINIFY_API_KEY>",
"FIGMA_API_TOKEN": "<YOUR_FIGMA_API_TOKEN>"
}
}
}
}
MCP クライアントライブラリとの使用
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
}
}
変更履歴
- 2025-05-12: Figma API を更新し、2x 画像スケーリングを含む追加パラメーターをサポートしました。
技術的な実装
このプロジェクトは、次のライブラリを基盤としています。
- probe-image-size - 画像サイズの検出用
- tinify - TinyPNG API を使用した画像圧縮用
- figma-api - Figma API から画像リンクを取得するために使用
環境変数
TINIFY_API_KEY- 画像圧縮機能に必要です。API キーは TinyPNG から取得してください- 指定されていない場合、圧縮ツール(
compress_image_from_urlとcompress_local_image)は登録されません
- 指定されていない場合、圧縮ツール(
FIGMA_API_TOKEN- Figma API から画像リンクを取得するために必要です。API トークンは Figma から取得してください- 指定されていない場合、Figma ツール(
figma)は登録されません
- 指定されていない場合、Figma ツール(
注:基本的な画像サイズ取得ツール(get_image_size と get_local_image_size)は、API キーの有無にかかわらず常に利用できます。
ライセンス
MIT
コメント
Markdown 対応
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。