Skip to main content
Glama

markitup_extend

Extend image canvas to target aspect ratio and dimensions using AI outpainting. Provide source via URL or base64, specify aspect ratio and pixel size.

Instructions

AI-outpaint an image to a larger canvas. Useful for converting a square asset to 16:9 or 9:16, or extending a tight crop. Costs 1 credit. Provide the source image as URL or base64, plus the target aspect ratio and pixel dimensions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_urlNoPublic HTTPS URL of the source image.
image_base64NoBase64-encoded source image (no data: prefix). Mutually exclusive with image_url.
image_mime_typeNoimage/png
aspect_ratioYesTarget aspect ratio. One of: 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9.
target_widthYesTarget output width in pixels.
target_heightYesTarget output height in pixels.
image_sizeNo

Implementation Reference

  • Definition of the extendTool object with name 'markitup_extend' and its inputSchema (image_url, image_base64, aspect_ratio, target_width, target_height, image_size).
    import { MarkItUpApiClient } from "../api/client.js";
    
    export const extendTool = {
      name: "markitup_extend",
      description:
        "AI-outpaint an image to a larger canvas. Useful for converting a square asset to 16:9 or 9:16, or extending a tight crop. " +
        "Costs 1 credit. " +
        "Provide the source image as URL or base64, plus the target aspect ratio and pixel dimensions.",
      inputSchema: {
        type: "object",
        properties: {
          image_url: { type: "string", description: "Public HTTPS URL of the source image." },
          image_base64: { type: "string", description: "Base64-encoded source image (no data: prefix). Mutually exclusive with image_url." },
          image_mime_type: { type: "string", default: "image/png" },
          aspect_ratio: {
            type: "string",
            description: "Target aspect ratio. One of: 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9.",
          },
          target_width: { type: "number", description: "Target output width in pixels." },
          target_height: { type: "number", description: "Target output height in pixels." },
          image_size: { type: "string", enum: ["1K", "2K", "4K"] },
        },
        required: ["aspect_ratio", "target_width", "target_height"],
        additionalProperties: false,
      },
    } as const;
  • The runExtend handler function that validates inputs, converts the source image to a data URL, POSTs to /extend, and returns the result as text + image content.
    export async function runExtend(
      api: MarkItUpApiClient,
      args: Record<string, unknown>
    ): Promise<{
      content: Array<TextContent | ImageContent>;
      structuredContent: ExtendBackendResponse;
    }> {
      const imageUrl = typeof args.image_url === "string" ? args.image_url : undefined;
      const imageBase64 = typeof args.image_base64 === "string" ? args.image_base64 : undefined;
      const mimeType = typeof args.image_mime_type === "string" ? args.image_mime_type : "image/png";
      const aspectRatio = typeof args.aspect_ratio === "string" ? args.aspect_ratio : "";
      const targetWidth = typeof args.target_width === "number" ? args.target_width : 0;
      const targetHeight = typeof args.target_height === "number" ? args.target_height : 0;
      const imageSize = typeof args.image_size === "string" ? args.image_size : undefined;
    
      if (!aspectRatio || !targetWidth || !targetHeight) {
        throw new Error("aspect_ratio, target_width, and target_height are required");
      }
      if (!!imageUrl === !!imageBase64) {
        throw new Error("Provide exactly one of image_url or image_base64");
      }
    
      const imageDataUrl = imageUrl
        ? await fetchAsDataUrl(imageUrl)
        : `data:${mimeType};base64,${imageBase64}`;
    
      const body: Record<string, unknown> = {
        imageDataUrl,
        aspectRatio,
        targetWidth,
        targetHeight,
      };
      if (imageSize) body.imageSize = imageSize;
    
      const data = await api.post<ExtendBackendResponse>("/extend", body);
    
      const content: Array<TextContent | ImageContent> = [
        { type: "text", text: `Extended to ${data.width ?? targetWidth}x${data.height ?? targetHeight} (${aspectRatio}).` },
      ];
      const parsed = parseDataUrl(data.imageDataUrl);
      if (parsed) {
        content.push({ type: "image", data: parsed.data, mimeType: parsed.mimeType });
      }
    
      return { content, structuredContent: data };
    }
  • Helper functions fetchAsDataUrl (fetches a URL and returns a data URL) and parseDataUrl (parses a data URL into mimeType and base64 data).
    async function fetchAsDataUrl(url: string): Promise<string> {
      const res = await fetch(url);
      if (!res.ok) throw new Error(`Failed to fetch image_url (${res.status}): ${url}`);
      const buf = Buffer.from(await res.arrayBuffer());
      const contentType = res.headers.get("content-type") ?? "image/png";
      return `data:${contentType};base64,${buf.toString("base64")}`;
    }
    
    function parseDataUrl(dataUrl: string): { mimeType: string; data: string } | null {
      const match = dataUrl.match(/^data:([^;]+);base64,(.+)$/);
      if (!match) return null;
      return { mimeType: match[1], data: match[2] };
    }
  • src/index.ts:41-47 (registration)
    The extendTool is registered in the tools array alongside balance, generate, regen, and bgremove tools.
    const tools: Tool[] = [
      balanceTool as unknown as Tool,
      generateTool as unknown as Tool,
      regenTool as unknown as Tool,
      extendTool as unknown as Tool,
      bgremoveTool as unknown as Tool,
    ];
  • Registration of runExtend as the handler for extendTool.name ('markitup_extend') in the CallToolRequestSchema switch statement.
    case extendTool.name:
      return await runExtend(api, args ?? {});
Behavior3/5

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

With no annotations, the description carries full burden. It discloses cost (1 credit) and input options (URL or base64), but does not mention behavior on failure, max image size, or idempotency. It is adequate but not rich.

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 4 sentences, front-loaded with purpose. Each sentence adds value: purpose, use cases, cost, input format. No waste.

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 no output schema and 7 parameters, the description omits important context: expected output format, error handling, size limits, and the meaning of 'image_size' enum (output resolution?). This leaves gaps for an agent.

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?

Schema coverage is high (71%), so baseline is 3. The description adds context like 'plus the target aspect ratio and pixel dimensions' but does not provide deeper semantics for individual parameters (e.g., meaning of image_size enum).

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

Purpose5/5

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

The description uses a specific verb ('AI-outpaint') and resource ('image to a larger canvas'), and provides concrete use cases (converting square to 16:9, extending tight crop). It clearly distinguishes from sibling tools like markitup_generate and markitup_remove_background.

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

Usage Guidelines4/5

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

The description gives explicit context for when to use ('useful for converting a square asset to 16:9 or 9:16, or extending a tight crop'), but does not mention when not to use or list alternatives. It implies usage but lacks exclusions.

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

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/smythmyke/markitup-mcp-server'

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