Skip to main content
Glama

get_trending_gifs

Retrieve currently trending GIFs from Giphy with options to filter by content rating and control result quantity for integration into applications and content.

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

  • Core handler function that fetches and formats trending GIFs from the Giphy API using axios.
    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); } }
  • MCP server request handler case that parses arguments, calls the service function, and returns the JSON 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 }), }, ], }; }
  • Tool definition including name, description, and input schema for validation.
    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)", }, }, }, };
  • src/server.ts:107-111 (registration)
    Registration of the tool in the MCP server's list of available tools.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [searchGifsTool, getRandomGifTool, getTrendingGifsTool], }; });

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