Skip to main content
Glama

markitup_remove_background

Remove background from images using AI, returning a transparent PNG. Accepts image URL or base64 input.

Instructions

Remove the background from an image using Photoroom's HD AI background-removal service. Returns a transparent PNG. Costs 1 credit (free for active Pro/Power subscribers). Provide the source image as URL or base64.

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

Implementation Reference

  • Main handler function `runBgRemove` that processes the background removal request. It validates mutual exclusivity of image_url/image_base64, fetches the image if a URL is provided, calls the API endpoint /bgremove, and returns the result as text + image content.
    export async function runBgRemove(
      api: MarkItUpApiClient,
      args: Record<string, unknown>
    ): Promise<{
      content: Array<TextContent | ImageContent>;
      structuredContent: BgRemoveBackendResponse;
    }> {
      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";
    
      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 data = await api.post<BgRemoveBackendResponse>("/bgremove", { imageDataUrl });
    
      const content: Array<TextContent | ImageContent> = [
        { type: "text", text: "Background removed." },
      ];
      const parsed = parseDataUrl(data.imageDataUrl);
      if (parsed) {
        content.push({ type: "image", data: parsed.data, mimeType: parsed.mimeType });
      }
    
      return { content, structuredContent: data };
    }
  • Tool definition with name 'markitup_remove_background', description, and inputSchema defining image_url, image_base64, and image_mime_type parameters.
    export const bgremoveTool = {
      name: "markitup_remove_background",
      description:
        "Remove the background from an image using Photoroom's HD AI background-removal service. " +
        "Returns a transparent PNG. Costs 1 credit (free for active Pro/Power subscribers). " +
        "Provide the source image as URL or base64.",
      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" },
        },
        additionalProperties: false,
      },
    } as const;
  • src/index.ts:41-47 (registration)
    Tool is registered in the tools array alongside other tools (bgremoveTool at line 46).
    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,
    ];
  • src/index.ts:63-64 (registration)
    Tool handler dispatch: case 'markitup_remove_background' routes to runBgRemove(api, args).
    case bgremoveTool.name:
      return await runBgRemove(api, args ?? {});
  • Helper function `fetchAsDataUrl` that downloads an image from a URL and converts it to a data URL.
    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")}`;
    }
Behavior3/5

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

No annotations provided, so description bears full burden. Discloses return format (transparent PNG) and credit cost, but omits error conditions, size limits, or processing time.

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?

Three concise sentences covering purpose, output, cost, and input format. No unnecessary words.

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

Completeness4/5

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

Describes output (transparent PNG) and cost, but no output schema. Lacks details on error handling or limits, which would improve completeness.

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

Parameters4/5

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

Schema covers 2 of 3 parameters. Description adds that image_url and image_base64 are mutually exclusive and clarifies cost. Adds value beyond schema.

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?

Clearly states it removes background from an image and returns a transparent PNG. Differentiates from sibling tools (credit_balance, extend, generate, regen) by specifying the unique service.

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?

Mentions cost and free access for subscribers, and provides source image input options (URL or base64). Lacks explicit guidance on when not to use or alternatives, but context is clear.

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