Skip to main content
Glama
tandat8503

Reddit MCP Server

by tandat8503

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 },
      );
    }
Behavior3/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. It discloses that no parameters are needed and describes the output format, but lacks details on rate limits, authentication needs, or data freshness (e.g., how 'trending' is defined). The description adds value beyond annotations but is not comprehensive.

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 well-structured with emoji-led sections, front-loads the purpose, and includes only essential elements (what it does, parameters, examples, output). Every sentence earns its place without redundancy, making it efficient and easy to scan.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is largely completeβ€”it explains the purpose, parameter requirements, and output format. However, it could improve by mentioning limitations (e.g., no filtering options) or linking to siblings for more specific data.

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

Parameters4/5

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

The schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description explicitly states 'Required: None (no parameters needed)', which adds clarity beyond the empty schema, earning a baseline above 3 for addressing the parameterless nature.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states 'Fetches list of currently popular and trending subreddits' with a specific verb ('fetches') and resource ('subreddits'), clearly distinguishing it from sibling tools like get_subreddit_info (single subreddit) or search_reddit (search queries). The emoji 'πŸ”₯ Get trending/popular subreddits' reinforces the purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use it ('currently popular and trending subreddits'), but does not explicitly state when not to use it or name alternatives. It distinguishes from siblings by focusing on trending lists rather than specific subreddits or posts, though not with explicit 'vs' statements.

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

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