Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mcp-image-size) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Image Size MCP
A Model Context Protocol (MCP) service for retrieving image dimensions, supporting both URL and local file sources.
Features
- Retrieve image dimensions from URLs
- Get image dimensions from local files
- Returns width, height, type, and MIME type information
Installation
npm install image-size-mcp
Usage
Using as an MCP Service
This service provides two tool functions:
get_image_size
- Get dimensions of remote imagesget_local_image_size
- Get dimensions of local images
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
- Configure Claude Desktop to use this MCP server by editing the configuration file:
{
"mcpServers": {
"image-size": {
"command": "npx",
"args": ["image-size-mcp"]
}
}
}
- Restart Claude Desktop
- Ask Claude to get image dimensions: "Can you tell me the dimensions of this image: https://example.com/image.jpg?"
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" }
Tool Schemas
get_image_size
{
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
}
}
Technical Implementation
This project is built on the probe-image-size library for image dimension detection.
License
MIT