Skip to main content
Glama

search_reddit_all

Find posts across all of Reddit using customizable search parameters including sorting by relevance, time filters, and result limits to locate specific content.

Instructions

Search for posts across all of Reddit (site-wide search)

Args: query: The search query to search across all Reddit limit: Number of posts to return (default: 10, max: 100) sort: Sort method - "relevance", "hot", "top", "new", "comments" (default: "relevance") time_filter: Time filter - "all", "day", "week", "month", "year" (default: "all")

Returns: Human readable string containing search results from across Reddit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
queryYes
sortNorelevance
time_filterNoall

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The FastMCP tool handler for 'search_reddit_all'. Decorated with @mcp.tool() for automatic registration and schema inference from signature/docstring. Handles client check, calls RedditClient.search_all_reddit, formats and returns results as string.
    @mcp.tool()
    async def search_reddit_all(
        query: str,
        limit: int = 10,
        sort: str = "relevance", 
        time_filter: str = "all"
    ) -> str:
        """
        Search for posts across all of Reddit (site-wide search)
    
        Args:
            query: The search query to search across all Reddit
            limit: Number of posts to return (default: 10, max: 100)
            sort: Sort method - "relevance", "hot", "top", "new", "comments" (default: "relevance")
            time_filter: Time filter - "all", "day", "week", "month", "year" (default: "all")
    
        Returns:
            Human readable string containing search results from across Reddit
        """
        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.search_all_reddit(
                query=query,
                limit=min(limit, 100),
                sort=sort,
                time_filter=time_filter
            )
            
            if not posts:
                return f"No posts found across Reddit for query: '{query}'"
            
            result = f"Found {len(posts)} posts across all Reddit for query: '{query}'\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"
                    f"   Subreddit: r/{post['subreddit']}\n"
                )
                
                if post['selftext'] and len(post['selftext']) > 0:
                    preview = post['selftext'][:200] + "..." if len(post['selftext']) > 200 else post['selftext']
                    result += f"   Content: {preview}\n"
                
                result += "\n"
            
            return result
            
        except Exception as e:
            logger.error(f"Error searching all Reddit for query '{query}': {str(e)}")
            return f"Error searching all Reddit for query '{query}': {str(e)}"
  • Supporting method in RedditClient that uses asyncpraw to search subreddit('all') with the given parameters and returns formatted post data dictionaries.
    async def search_all_reddit(
        self, 
        query: str, 
        limit: int = 10,
        sort: str = "relevance",
        time_filter: str = "all"
    ) -> List[Dict[str, Any]]:
        """Search for posts across all of Reddit (site-wide search)."""
        try:
            # Search all of reddit using the 'all' subreddit
            all_subreddit = await self.reddit.subreddit("all")
            
            posts = []
            search_results = all_subreddit.search(
                query, 
                limit=limit, 
                sort=sort, 
                time_filter=time_filter
            )
            
            async for submission in search_results:
                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[:500] + "..." if len(submission.selftext) > 500 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 searching all Reddit for query '{query}': {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 for behavioral disclosure. It mentions the return format ('Human readable string containing search results') but doesn't cover important aspects like rate limits, authentication requirements, error conditions, or whether this is a read-only operation. The description is minimal beyond basic functionality.

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 and efficiently organized. It starts with the core purpose, then provides a clear Args section with bullet-point style documentation for each parameter, followed by a Returns section. Every sentence adds value with no wasted words.

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 4 parameters with no schema descriptions and an output schema exists, the description does a good job documenting parameters but is light on behavioral context. For a search tool with sibling alternatives, more guidance on usage context would be beneficial. The existence of an output schema means the description doesn't need to detail return values.

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 provides excellent parameter documentation with clear explanations for all 4 parameters, including defaults, ranges, and allowed values. With 0% schema description coverage, the description fully compensates by adding comprehensive semantic information beyond what the bare schema provides.

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: 'Search for posts across all of Reddit (site-wide search)'. This specifies the verb (search), resource (posts), and scope (all of Reddit). However, it doesn't explicitly differentiate from sibling tools like 'search_reddit_posts', which might have different scope or functionality.

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. With sibling tools like 'search_reddit_posts' and 'get_hot_reddit_posts', there's no indication of when this site-wide search is preferred over other search or listing methods.

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