Skip to main content
Glama

get_trending_subreddits

Fetch a list of currently popular and trending subreddits, including details like name, title, subscribers, description, and URL, for streamlined discovery and analysis.

Instructions

๐Ÿ”ฅ Get trending/popular subreddits ๐ŸŽฏ What it does: Fetches list of currently popular and trending subreddits ๐Ÿ“ Required: None (no parameters needed) ๐Ÿ’ก Examples: โ€ข Get trending: {} โ€ข Simple call: {} ๐Ÿ” Output: List of trending subreddits with name, title, subscribers, description, and URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core execution logic of the get_trending_subreddits tool handler. It applies smart defaults, calls the Reddit API service to fetch trending subreddits, validates the response, creates a custom formatter for subreddits, uses formatDataList helper to preview limited results, and returns a formatted markdown text response via createSuccessResponse.
    createToolHandler(async (params: z.infer<typeof SimpleTrendingSubredditsSchema>) => { // ๐Ÿง  Smart defaults - no parameters needed const smartDefaults = getSmartDefaults(params, 'trending'); const finalParams = { ...smartDefaults }; const result = await redditAPI.getTrendingSubreddits(finalParams.limit || 25); // โœ… DRY: Sแปญ dแปฅng validateApiResponse helper const subreddits = validateApiResponse(result, "trending subreddits"); if (subreddits.length === 0) { return createSuccessResponse("No trending subreddits found"); } const summary = `๐Ÿ”ฅ Found ${subreddits.length} trending subreddits`; // โœ… DRY: Sแปญ dแปฅng formatDataList helper vแป›i custom formatter const subredditFormatter = (subreddit: any) => { const name = subreddit.display_name || 'Unknown'; const title = subreddit.title || 'No title'; const subscribers = subreddit.subscribers || 0; const description = subreddit.public_description || 'No description'; let result = `๐Ÿ  **r/${name}** - ${title}\n`; result += `๐Ÿ‘ฅ ${subscribers.toLocaleString()} subscribers\n`; if (description.length > 100) { result += `๐Ÿ“„ ${description.substring(0, 100)}...\n`; } else { result += `๐Ÿ“„ ${description}\n`; } result += `๐Ÿ”— https://reddit.com/r/${name}\n`; return result; }; const subredditDetails = formatDataList(subreddits, subredditFormatter, TRENDING_SUBREDDIT_LIMIT, "subreddits"); const resultText = `${summary}\n\n${subredditDetails}`; return createSuccessResponse(resultText); })
  • src/index.ts:661-712 (registration)
    MCP server tool registration for 'get_trending_subreddits'. Registers the tool with name, detailed usage description including examples, input schema reference, and the wrapped handler function using createToolHandler.
    server.tool( "get_trending_subreddits", "๐Ÿ”ฅ Get trending/popular subreddits\n" + "๐ŸŽฏ What it does: Fetches list of currently popular and trending subreddits\n" + "๐Ÿ“ Required: None (no parameters needed)\n" + "๐Ÿ’ก Examples:\n" + " โ€ข Get trending: {}\n" + " โ€ข Simple call: {}\n" + "๐Ÿ” Output: List of trending subreddits with name, title, subscribers, description, and URL", SimpleTrendingSubredditsSchema.shape, createToolHandler(async (params: z.infer<typeof SimpleTrendingSubredditsSchema>) => { // ๐Ÿง  Smart defaults - no parameters needed const smartDefaults = getSmartDefaults(params, 'trending'); const finalParams = { ...smartDefaults }; const result = await redditAPI.getTrendingSubreddits(finalParams.limit || 25); // โœ… DRY: Sแปญ dแปฅng validateApiResponse helper const subreddits = validateApiResponse(result, "trending subreddits"); if (subreddits.length === 0) { return createSuccessResponse("No trending subreddits found"); } const summary = `๐Ÿ”ฅ Found ${subreddits.length} trending subreddits`; // โœ… DRY: Sแปญ dแปฅng formatDataList helper vแป›i custom formatter const subredditFormatter = (subreddit: any) => { const name = subreddit.display_name || 'Unknown'; const title = subreddit.title || 'No title'; const subscribers = subreddit.subscribers || 0; const description = subreddit.public_description || 'No description'; let result = `๐Ÿ  **r/${name}** - ${title}\n`; result += `๐Ÿ‘ฅ ${subscribers.toLocaleString()} subscribers\n`; if (description.length > 100) { result += `๐Ÿ“„ ${description.substring(0, 100)}...\n`; } else { result += `๐Ÿ“„ ${description}\n`; } result += `๐Ÿ”— https://reddit.com/r/${name}\n`; return result; }; const subredditDetails = formatDataList(subreddits, subredditFormatter, TRENDING_SUBREDDIT_LIMIT, "subreddits"); const resultText = `${summary}\n\n${subredditDetails}`; return createSuccessResponse(resultText); }) );
  • Zod input schema for the get_trending_subreddits tool. Defined as an empty object since the tool requires no parameters, allowing parameterless calls.
    export const SimpleTrendingSubredditsSchema = z.object({});
  • Supporting API service method in RedditAPIService that performs the authenticated GET request to Reddit's /subreddits/popular.json endpoint to retrieve the list of popular/trending subreddits, handling OAuth, rate limiting, and error responses.
    async getTrendingSubreddits(limit: number = 25): Promise<ApiCallResult> { return this.makeRequest<{ data: { children: Array<{ data: RedditSubreddit }> } }>( "/subreddits/popular.json", { limit }, ); }

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/tandat8503/mcp-reddit'

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