JSPM

mcp-image-size

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q22508F
  • License MIT

A Model Context Protocol (MCP) service for retrieving image dimensions, supporting both URL and local file sources.

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:

    1. get_image_size - Get dimensions of remote images
    2. get_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

    1. Install Claude Desktop from claude.ai/download
    2. Configure Claude Desktop to use this MCP server by editing the configuration file:
    {
      "mcpServers": {
        "image-size": {
          "command": "npx",
          "args": ["image-size-mcp"]
        }
      }
    }
    1. Restart Claude Desktop
    2. 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