Skip to main content
Glama

get_subreddit_info

Retrieve detailed information about any Reddit community, including description, subscriber count, and activity metrics, using the subreddit name.

Instructions

Get information about a subreddit

Args: subreddit: The name of the subreddit (without r/)

Returns: Human readable string containing subreddit information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subredditYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler decorated with @mcp.tool(). It checks if client is initialized, calls reddit_client.get_subreddit_info, formats the dictionary into a human-readable string, handles errors.
    @mcp.tool()
    async def get_subreddit_info(subreddit: str) -> str:
        """
        Get information about a subreddit
    
        Args:
            subreddit: The name of the subreddit (without r/)
    
        Returns:
            Human readable string containing subreddit information
        """
        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:
            subreddit_info = await reddit_client.get_subreddit_info(subreddit)
            
            result = (
                f"**r/{subreddit_info['name']}**\n\n"
                f"Title: {subreddit_info['title']}\n"
                f"Subscribers: {subreddit_info['subscribers']:,}\n"
                f"Active Users: {subreddit_info['active_user_count'] or 'N/A'}\n"
                f"NSFW: {subreddit_info['over18']}\n"
                f"URL: {subreddit_info['url']}\n\n"
                f"Description:\n{subreddit_info['public_description']}\n"
            )
            
            if subreddit_info['description'] and subreddit_info['description'] != subreddit_info['public_description']:
                result += f"\nFull Description:\n{subreddit_info['description']}\n"
            
            return result
            
        except Exception as e:
            logger.error(f"Error getting subreddit info for r/{subreddit}: {str(e)}")
            return f"Error getting subreddit info for r/{subreddit}: {str(e)}"
  • Core helper method in RedditClient class that uses asyncpraw to fetch subreddit details and returns a structured dictionary with key info like title, subscribers, description, etc.
    async def get_subreddit_info(self, subreddit_name: str) -> Dict[str, Any]:
        """Get information about a subreddit."""
        try:
            subreddit = await self.reddit.subreddit(subreddit_name)
            
            return {
                "name": subreddit.display_name,
                "title": subreddit.title,
                "description": subreddit.description[:500] + "..." if len(subreddit.description) > 500 else subreddit.description,
                "subscribers": subreddit.subscribers,
                "active_user_count": subreddit.active_user_count,
                "created_utc": subreddit.created_utc,
                "over18": subreddit.over18,
                "public_description": subreddit.public_description,
                "url": f"https://reddit.com/r/{subreddit.display_name}",
            }
            
        except Exception as e:
            raise Exception(f"Error getting subreddit info for 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 full burden but offers minimal behavioral context. It mentions the return format ('Human readable string') but doesn't disclose authentication needs, rate limits, error conditions, or whether it's a read-only operation. The description is functional but lacks important operational details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and well-structured with clear sections for Args and Returns. The main purpose is stated upfront, and the parameter documentation is concise. The structure helps with readability, though the 'Human readable string' return description could be more specific.

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 (though not shown), the description doesn't need to detail return values. However, with no annotations and minimal behavioral disclosure, the description is adequate but incomplete. It covers the basic purpose and parameter but lacks context about when to use it versus siblings and operational considerations.

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?

Schema description coverage is 0%, but the description provides clear parameter semantics: 'The name of the subreddit (without r/)'. This adds valuable context beyond the bare schema. However, with only one parameter, the baseline would be 4 if no param info was provided; the description adds some value but doesn't fully compensate for the lack of schema descriptions.

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 tool's purpose with a specific verb ('Get') and resource ('information about a subreddit'). It distinguishes from siblings by focusing on subreddit metadata rather than posts or search, though it doesn't explicitly contrast with sibling tools.

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?

No guidance is provided on when to use this tool versus alternatives like get_hot_reddit_posts or search_reddit_posts. The description only states what it does, not when it's appropriate or what distinguishes it from similar tools.

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