Skip to main content
Glama
haltakov
by haltakov

generateMeme

Create meme images by providing a template ID and text, using the Imgflip API to generate visual content from text prompts.

Instructions

Generate a meme image from Imgflip using the numeric template id and text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateNumericIdYes
text0Yes
text1No

Implementation Reference

  • The handler function that implements the generateMeme tool: calls Imgflip API with template ID and texts, downloads the generated image, encodes to base64, and returns it as inline content or error.
    async ({ templateNumericId, text0, text1 }) => {
      try {
        // Prepare the Imgflip API request
        const formData = new FormData();
        formData.append("template_id", templateNumericId);
        formData.append("text0", text0);
        if (text1) formData.append("text1", text1);
        formData.append("username", process.env.IMGFLIP_USERNAME || "");
        formData.append("password", process.env.IMGFLIP_PASSWORD || "");
    
        // Send the request to the Imgflip API
        const response = await axios.post("https://api.imgflip.com/caption_image", formData, {
          headers: {
            "Content-Type": "multipart/form-data",
          },
        });
    
        // Get the image URL from the response
        const imageUrl = response.data.data.url;
    
        // Download the image
        const imageResponse = await axios.get(imageUrl, { responseType: "arraybuffer" });
        const imageDataBase64 = imageResponse.data.toString("base64");
    
        // Return the image as a base64 encoded string
        return {
          content: [{ type: "image", data: imageDataBase64, mimeType: "image/png" }],
        };
      } catch (error) {
        // Return an error message
        return {
          content: [
            {
              type: "text",
              text: "Failed to generate meme image",
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema using Zod: templateNumericId (string), text0 (string), text1 (optional string).
      templateNumericId: z.string(),
      text0: z.string(),
      text1: z.string().optional(),
    },
  • src/index.ts:15-64 (registration)
    Registration of the generateMeme tool using server.tool() with name, description, input schema, and handler function.
    server.tool(
      "generateMeme",
      "Generate a meme image from Imgflip using the numeric template id and text",
      {
        templateNumericId: z.string(),
        text0: z.string(),
        text1: z.string().optional(),
      },
      async ({ templateNumericId, text0, text1 }) => {
        try {
          // Prepare the Imgflip API request
          const formData = new FormData();
          formData.append("template_id", templateNumericId);
          formData.append("text0", text0);
          if (text1) formData.append("text1", text1);
          formData.append("username", process.env.IMGFLIP_USERNAME || "");
          formData.append("password", process.env.IMGFLIP_PASSWORD || "");
    
          // Send the request to the Imgflip API
          const response = await axios.post("https://api.imgflip.com/caption_image", formData, {
            headers: {
              "Content-Type": "multipart/form-data",
            },
          });
    
          // Get the image URL from the response
          const imageUrl = response.data.data.url;
    
          // Download the image
          const imageResponse = await axios.get(imageUrl, { responseType: "arraybuffer" });
          const imageDataBase64 = imageResponse.data.toString("base64");
    
          // Return the image as a base64 encoded string
          return {
            content: [{ type: "image", data: imageDataBase64, mimeType: "image/png" }],
          };
        } catch (error) {
          // Return an error message
          return {
            content: [
              {
                type: "text",
                text: "Failed to generate meme image",
              },
            ],
            isError: true,
          };
        }
      }
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions generating a meme image but fails to describe key behaviors such as whether this is a read-only or mutating operation, potential rate limits, authentication needs, or what the output looks like (e.g., image URL or data). This leaves significant gaps in understanding the tool's behavior.

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 that directly states the tool's function without unnecessary words. It is front-loaded with the core action and includes essential details (source and inputs), making it highly concise and well-structured for quick comprehension.

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 tool's complexity (3 parameters, no output schema, no annotations), the description is incomplete. It lacks details on parameter meanings, behavioral traits, output format, and usage context. For a tool that generates external content, more information is needed to guide effective use, making it inadequate for the context.

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

Parameters2/5

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

Schema description coverage is 0%, meaning the schema provides no descriptions for the three parameters. The description adds minimal semantics by naming the parameters ('numeric template id and text'), but it doesn't explain what 'templateNumericId', 'text0', or 'text1' represent, their formats, or examples. This insufficiently compensates for the lack of schema documentation.

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 action ('Generate a meme image') and the resource ('from Imgflip'), specifying the verb and target. It mentions the required inputs (template id and text), making the purpose specific. However, without sibling tools, it doesn't need to differentiate from alternatives, so it falls short of a perfect score.

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, prerequisites, or context for its application. It simply states what the tool does without indicating appropriate scenarios or limitations, leaving the agent with minimal usage direction.

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/haltakov/meme-mcp'

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