Skip to main content
Glama
magarcia

MCP Server Giphy

get_trending_gifs

Retrieve trending GIFs from Giphy with options to filter by content rating and control result quantity.

Instructions

Get currently trending GIFs on Giphy

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of objects to return (default: 10, max: 50)
offsetNoResults offset (default: 0)
ratingNoContent rating (g, pg, pg-13, r)

Implementation Reference

  • Main handler function implementing the core logic for fetching trending GIFs from Giphy API using axios, handling parameters, building URL, error handling, and formatting the response.
    export async function getTrendingGifs(params: {
      limit?: number;
      offset?: number;
      rating?: "g" | "pg" | "pg-13" | "r";
    }) {
      const { limit = 10, offset = 0, rating = "g" } = params;
    
      const searchParams = {
        limit,
        offset,
        rating,
      };
    
      const url = buildUrl("trending", 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);
      }
    }
  • Tool schema definition including name, description, and input schema for validating parameters like limit, offset, rating.
    export const getTrendingGifsTool: Tool = {
      name: "get_trending_gifs",
      description: "Get currently trending GIFs on Giphy",
      inputSchema: {
        type: "object",
        properties: {
          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)",
          },
        },
      },
    };
  • MCP server tool call handler that dispatches to the getTrendingGifs service function and formats the MCP response.
    case "get_trending_gifs": {
      const trendingParams = args as {
        limit?: number;
        offset?: number;
        rating?: "g" | "pg" | "pg-13" | "r";
      };
      const gifs = await getTrendingGifs(trendingParams);
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({ gifs }),
          },
        ],
      };
    }
  • src/server.ts:107-111 (registration)
    Registration of the tool in the MCP server's listTools handler, making it discoverable.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [searchGifsTool, getRandomGifTool, getTrendingGifsTool],
      };
    });
  • Helper function to format array of GIFs for the response.
    function formatGifs(gifs: GiphyGif[]) {
      return gifs.map(formatGif);
    }
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 states what the tool does but doesn't add any behavioral context beyond that—such as rate limits, authentication requirements, or what the output looks like (e.g., format, pagination details). This is a significant gap for a tool with no annotation coverage.

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's appropriately sized and front-loaded, making it easy for an agent 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. It doesn't explain behavioral aspects like rate limits or output format, which are crucial for proper tool invocation. For a tool with three parameters and no structured output information, more context is needed to be fully helpful.

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, with clear documentation for all three parameters (limit, offset, rating). The description doesn't add any parameter semantics beyond what the schema provides, so it meets the baseline score of 3 where 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 verb ('Get') and resource ('currently trending GIFs on Giphy'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'get_random_gif' or 'search_gifs', which would require mentioning it's specifically for trending content rather than random or search-based retrieval.

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 'search_gifs'. It lacks any context about scenarios where trending GIFs are preferred over random or searched ones, leaving the agent to infer usage based on tool names alone.

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