Skip to main content
Glama
magarcia

MCP Server Giphy

search_gifs

Search for GIFs on Giphy using keywords, with options to filter by content rating, language, and limit results.

Instructions

Search for GIFs on Giphy with a query string

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query term or phrase
limitNoMaximum number of objects to return (default: 10, max: 50)
offsetNoResults offset (default: 0)
ratingNoContent rating (g, pg, pg-13, r)
langNoLanguage code (default: en)

Implementation Reference

  • The core handler function that implements the search_gifs tool logic: constructs API parameters, calls Giphy search endpoint, formats response GIFs, and handles errors.
    export async function searchGifs(params: {
      query: string;
      limit?: number;
      offset?: number;
      rating?: "g" | "pg" | "pg-13" | "r";
      lang?: string;
    }) {
      const { query, limit = 10, offset = 0, rating = "g", lang = "en" } = params;
    
      const searchParams = {
        q: query,
        limit,
        offset,
        rating,
        lang,
      };
    
      const url = buildUrl("search", searchParams);
    
      try {
        const response = await axios.get(url);
        const responseData = response.data as GiphyResponse;
        return formatGifs(responseData.data);
      } catch (error) {
        let errorMsg = "Giphy API error";
    
        if (axios.isAxiosError(error) && error.response) {
          errorMsg = `${errorMsg}: ${error.response.status} ${error.response.statusText}`;
        } else if (error instanceof Error) {
          errorMsg = `${errorMsg}: ${error.message}`;
        }
    
        throw new Error(errorMsg);
      }
    }
  • Defines the input schema and metadata for the search_gifs tool, used for validation in MCP.
    export const searchGifsTool: Tool = {
      name: "search_gifs",
      description: "Search for GIFs on Giphy with a query string",
      inputSchema: {
        type: "object",
        properties: {
          query: { type: "string", description: "Search query term or phrase" },
          limit: {
            type: "number",
            description:
              "Maximum number of objects to return (default: 10, max: 50)",
          },
          offset: { type: "number", description: "Results offset (default: 0)" },
          rating: {
            type: "string",
            enum: ["g", "pg", "pg-13", "r"],
            description: "Content rating (g, pg, pg-13, r)",
          },
          lang: { type: "string", description: "Language code (default: en)" },
        },
        required: ["query"],
      },
    };
  • src/server.ts:107-111 (registration)
    Registers searchGifsTool in the MCP server's listTools handler, making it discoverable.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [searchGifsTool, getRandomGifTool, getTrendingGifsTool],
      };
    });
  • src/server.ts:32-50 (registration)
    Handles incoming callTool requests for search_gifs by invoking the searchGifs handler and formatting the MCP response.
    case "search_gifs": {
      const searchParams = args as {
        query: string;
        limit?: number;
        offset?: number;
        rating?: "g" | "pg" | "pg-13" | "r";
        lang?: string;
      };
      const gifs = await searchGifs(searchParams);
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({ gifs }),
          },
        ],
      };
    }
  • Helper function to format multiple GIFs from Giphy response, used by searchGifs.
    function formatGifs(gifs: GiphyGif[]) {
      return gifs.map(formatGif);
    }
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 mentions the action ('Search for GIFs') but fails to disclose critical traits like rate limits, authentication needs, error handling, or response format. This leaves significant gaps for an agent to understand operational 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 purpose without any wasted words. It is appropriately sized and front-loaded, 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 complexity of a search tool with 5 parameters and no output schema or annotations, the description is incomplete. It lacks details on behavioral aspects, usage context, and output expectations, leaving the agent with insufficient information for effective tool selection and invocation.

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 schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning beyond what the schema provides, such as usage examples or constraints not in the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

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 ('Search for GIFs') and resource ('on Giphy'), with the specific mechanism ('with a query string'). It distinguishes from siblings like 'get_random_gif' and 'get_trending_gifs' by specifying search functionality, though it could be more explicit about the 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 like 'get_random_gif' or 'get_trending_gifs'. It lacks context such as use cases for search versus random/trending GIFs, making it unclear when this is the appropriate choice.

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/magarcia/mcp-server-giphy'

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