Skip to main content
Glama

get_hot_reddit_posts

Retrieve trending posts from any subreddit to monitor popular discussions and content in real-time.

Instructions

Get hot posts from a subreddit

Args: subreddit: The name of the subreddit (without r/) limit: Number of posts to return (default: 10, max: 100)

Returns: Human readable string containing hot posts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
subredditYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The FastMCP tool handler for 'get_hot_reddit_posts', decorated with @mcp.tool(). Handles input validation via type hints, client initialization check, fetches posts via RedditClient, formats output as a human-readable string, and includes comprehensive error handling.
    @mcp.tool()
    async def get_hot_reddit_posts(subreddit: str, limit: int = 10) -> str:
        """
        Get hot posts from a subreddit
    
        Args:
            subreddit: The name of the subreddit (without r/)
            limit: Number of posts to return (default: 10, max: 100)
    
        Returns:
            Human readable string containing hot posts
        """
        if reddit_client is None:
            return """Error: Reddit client not initialized. 
    
    To fix this:
    1. Copy env.example to .env: cp env.example .env
    2. Edit .env with your Reddit API credentials:
       - Get credentials from https://old.reddit.com/prefs/apps/
       - Create a 'script' type app
       - Fill in REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET, and REDDIT_USER_AGENT
    3. Restart the MCP server
    
    Example .env content:
    REDDIT_CLIENT_ID=your_14_char_client_id
    REDDIT_CLIENT_SECRET=your_27_char_client_secret  
    REDDIT_USER_AGENT=reddit-mcp-tool:v0.2.0 (by /u/yourusername)"""
        
        try:
            posts = await reddit_client.get_hot_posts(subreddit, min(limit, 100))
            
            if not posts:
                return f"No hot posts found in r/{subreddit}"
            
            result = f"Hot posts from r/{subreddit}:\n\n"
            
            for i, post in enumerate(posts, 1):
                result += (
                    f"{i}. **{post['title']}**\n"
                    f"   Author: {post['author']}\n"
                    f"   Score: {post['score']} (upvote ratio: {post['upvote_ratio']:.0%})\n"
                    f"   Comments: {post['num_comments']}\n"
                    f"   Link: {post['permalink']}\n"
                )
                
                if post['selftext'] and len(post['selftext']) > 0:
                    preview = post['selftext'][:150] + "..." if len(post['selftext']) > 150 else post['selftext']
                    result += f"   Content: {preview}\n"
                
                result += "\n"
            
            return result
            
        except Exception as e:
            logger.error(f"Error getting hot posts from r/{subreddit}: {str(e)}")
            return f"Error getting hot posts from r/{subreddit}: {str(e)}"
  • Core helper method in RedditClient class that performs the actual Reddit API call using asyncpraw to fetch hot posts from a subreddit and structures the data into a standardized list of dictionaries.
    async def get_hot_posts(self, subreddit_name: str, limit: int = 10) -> List[Dict[str, Any]]:
        """Get hot posts from a subreddit."""
        try:
            subreddit = await self.reddit.subreddit(subreddit_name)
            
            posts = []
            async for submission in subreddit.hot(limit=limit):
                post_data = {
                    "id": submission.id,
                    "title": submission.title,
                    "author": str(submission.author) if submission.author else "[deleted]",
                    "score": submission.score,
                    "upvote_ratio": submission.upvote_ratio,
                    "url": submission.url,
                    "permalink": f"https://reddit.com{submission.permalink}",
                    "created_utc": submission.created_utc,
                    "num_comments": submission.num_comments,
                    "selftext": submission.selftext[:200] + "..." if len(submission.selftext) > 200 else submission.selftext,
                    "is_self": submission.is_self,
                    "domain": submission.domain,
                    "subreddit": str(submission.subreddit),
                }
                posts.append(post_data)
            
            return posts
            
        except Exception as e:
            raise Exception(f"Error getting hot posts from r/{subreddit_name}: {str(e)}")
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 return format ('Human readable string') but lacks critical details: whether authentication is required, rate limits, error handling, or what 'hot' means algorithmically. For a tool with zero annotation coverage, this leaves significant gaps in understanding its 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 efficiently structured with a clear purpose statement followed by Args and Returns sections. Every sentence adds value: the first states the action, and the subsequent lines provide essential parameter and output details without redundancy. It's front-loaded and appropriately sized for the tool's complexity.

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

Completeness3/5

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

Given the tool has an output schema (implied by 'Has output schema: true'), the description doesn't need to detail return values. However, with no annotations and 2 parameters, it partially compensates with parameter semantics but lacks behavioral context like authentication or rate limits. For a simple read operation, it's adequate but has clear gaps in completeness.

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 description adds meaningful context beyond the input schema, which has 0% description coverage. It explains that 'subreddit' excludes the 'r/' prefix and provides default and max values for 'limit', which aren't in the schema. This compensates well for the low schema coverage, though it doesn't detail parameter constraints like valid subreddit formats.

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 'hot posts from a subreddit', making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_subreddit_info' or 'search_reddit_posts', which might also retrieve subreddit content. The purpose is specific but lacks sibling 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 'search_reddit_posts' or 'get_subreddit_info'. It mentions what the tool does but offers no context about when it's appropriate, such as for trending content versus general searches, or prerequisites like authentication needs.

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

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