Skip to main content
Glama

get_local_image_size

Retrieve the dimensions of a local image by providing its absolute file path, enabling quick access to width and height details.

Instructions

Get the size of a local image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
optionsYesOptions for retrieving local image size

Implementation Reference

  • The core handler function that implements the logic for getting the size of a local image file using probe-image-size library. It checks file existence, reads the file into buffer, probes synchronously, and returns width, height, type, mime, and path.
    export async function getLocalImageSize(imagePath: string) {
      // 检查文件是否存在
      if (!fs.existsSync(imagePath)) {
        throw new Error(`文件不存在: ${imagePath}`);
      }
    
      // 使用Buffer(同步方法)
      const imageBuffer = fs.readFileSync(imagePath);
      const result = probe.sync(imageBuffer);
    
      if (!result) {
        throw new Error(`无法识别图片格式: ${imagePath}`);
      }
    
      return {
        width: result.width,
        height: result.height,
        type: result.type,
        mime: result.mime,
        path: imagePath,
      };
    }
  • src/server.ts:201-230 (registration)
    The MCP server.tool registration block for the 'get_local_image_size' tool, including schema, description, and the wrapper async function that calls the core handler `getLocalImageSize`.
    server.tool(
      "get_local_image_size",
      "Get the size of a local image",
      {
        options: z
          .object({
            imagePath: z.string().describe("Absolute path to the local image"),
          })
          .describe("Options for retrieving local image size"),
      },
      async ({ options = {} }) => {
        try {
          const { imagePath } = options as { imagePath: string };
          // Call tool function implementation
          const result = await getLocalImageSize(imagePath);
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(result, null, 2),
              },
            ],
          };
        } catch (error) {
          throw new Error(
            `Failed to get local image size: ${(error as Error).message}`,
          );
        }
      },
    );
  • The input schema (Zod) definition for 'get_local_image_size' in the server's capabilities declaration.
    get_local_image_size: {
      options: z
        .object({
          imagePath: z.string().describe("Absolute path to the local image"),
        })
        .describe("Options for retrieving local image size"),
    },
  • src/server.ts:21-21 (registration)
    Initial inclusion of 'get_local_image_size' in the set of available tools.
    const availableTools = new Set(["get_image_size", "get_local_image_size"]);
  • Import of the getLocalImageSize handler from tools/index.js.
    import {
      getImageSizeFromUrl,
      getLocalImageSize,
      compressImageFromUrl,
      compressLocalImage,
      getFigmaImages,
    } from "./tools/index.js";
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't add context beyond the basic action—missing details like error handling, performance implications, or what the output looks like (e.g., dimensions in pixels). This leaves significant gaps for a tool that interacts with local files.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste, front-loading the core purpose without unnecessary details. It's appropriately sized for a simple tool, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool that reads local files. It doesn't explain the return value (e.g., width and height), error cases, or security considerations, leaving the agent with insufficient context to use it effectively beyond the basic parameter.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, documenting the 'imagePath' parameter as an absolute path. The description doesn't add any meaning beyond this, such as format examples or constraints, so it meets the baseline of 3 where the schema does the heavy lifting without extra value from the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'size of a local image', making the purpose specific and understandable. However, it doesn't explicitly differentiate from its sibling 'get_image_size', which might handle remote images or have different scope, leaving room for ambiguity in sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, such as its sibling 'get_image_size'. It lacks context on prerequisites, exclusions, or specific scenarios, offering only a basic statement of function without usage instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kshern/image-tools-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server