Skip to main content
Glama

search_subreddits

Find Reddit subreddits by name or description, retrieving detailed matches based on specific search parameters and preferences for NSFW or full descriptions.

Instructions

Search for subreddits using either name-based or description-based search.

Args:
    by: Search parameters, either SearchByName or SearchByDescription

Returns:
    List of matching subreddits with their details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
byYes

Implementation Reference

  • The core handler function that implements the search_subreddits tool logic. It uses the RedditClient to search subreddits by name or description based on input parameters and maps results to SubredditResult models.
    def search_subreddits(by: SearchParams) -> List[SubredditResult]:
        """
        Search for subreddits using either name-based or description-based search.
    
        Args:
            by: Search parameters, either SearchByName or SearchByDescription
    
        Returns:
            List of matching subreddits with their details
        """
        client = RedditClient.get_instance()
    
        if by.type == "name":
            subreddits = client.reddit.subreddits.search_by_name(
                by.query, exact=by.exact_match, include_nsfw=by.include_nsfw
            )
        else:  # by.type == "description"
            subreddits = client.reddit.subreddits.search(by.query)
    
        return [
            SubredditResult(
                name=subreddit.display_name,
                public_description=subreddit.public_description,
                description=(
                    subreddit.description
                    if (by.type == "description" and by.include_full_description)
                    else None
                ),
                url=subreddit.url,
                subscribers=subreddit.subscribers,
                created_utc=format_utc_timestamp(subreddit.created_utc),
            )
            for subreddit in subreddits
        ]
  • Input schema definitions for the tool, discriminating union between SearchByName and SearchByDescription parameters.
    class SearchByName(BaseModel):
        """Parameters for searching subreddits by name"""
    
        type: Literal["name"]
        query: str
        include_nsfw: bool = Field(
            default=False,
            description="Whether to include NSFW subreddits in search results",
        )
        exact_match: bool = Field(
            default=False, description="If True, only return exact name matches"
        )
    
    
    class SearchByDescription(BaseModel):
        """Parameters for searching subreddits by description"""
    
        type: Literal["description"]
        query: str
        include_full_description: bool = Field(
            default=False,
            description="Whether to include the full subreddit description (aka sidebar description) in results -- can be very long and contain markdown formatting",
        )
    
    
    SearchParams = Union[SearchByName, SearchByDescription]
  • Output schema model defining the structure of each subreddit result returned by the tool.
    class SubredditResult(BaseModel):
        """Subreddit search result"""
    
        name: str = Field(description="Display name of the subreddit")
        public_description: str = Field(description="Short description shown publicly")
        url: str = Field(description="URL of the subreddit")
        subscribers: int | None = Field(default=None, description="Number of subscribers")
        created_utc: str = Field(description="UTC date when subreddit was created")
        description: str | None = Field(
            default=None,
            description="Full subreddit description with markdown formatting",
        )
  • The search_subreddits tool function is included in the central tools registry list, which is imported and used by the MCP server for registration.
    tools = [
        get_submission,
        get_subreddit,
        get_comments_by_submission,
        get_comment_by_id,
        search_posts,
        search_subreddits,
    ]
  • Generic registration loop in the MCP server that applies mcp.tool() decorator to each function in the tools list, including search_subreddits.
    for tool in tools:
        logger.info(f"Registering tool: {tool.__name__}")
        mcp.tool()(tool)
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 states the tool returns a list of matching subreddits with details, but lacks critical information such as whether this is a read-only operation, potential rate limits, authentication requirements, or how results are sorted/paginated. The description is minimal and misses key behavioral traits for a search tool.

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 extremely concise and well-structured, using only three sentences that efficiently cover purpose, parameters, and return value. Every sentence adds value with no wasted words, and it's front-loaded with the core functionality.

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's moderate complexity (search with two modes), no annotations, no output schema, and 0% schema description coverage, the description is incomplete. It covers the basic purpose and parameter structure but lacks behavioral details, usage context, and output specifics. It's adequate as a minimal overview but leaves significant gaps for an AI agent to operate effectively.

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 by explaining that the 'by' parameter accepts either 'SearchByName' or 'SearchByDescription' objects, clarifying the two distinct search modes. Since schema description coverage is 0% (parameters have no descriptions in the schema), the description compensates well by outlining the parameter's purpose, though it doesn't detail the nested properties within each search type.

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 searches for subreddits using name-based or description-based search, providing a specific verb ('search') and resource ('subreddits'). It distinguishes from sibling tools like 'search_posts' (which searches posts) and 'get_subreddit' (which retrieves a specific subreddit), though it doesn't explicitly differentiate from them in the description text itself.

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 'get_subreddit' (for retrieving a known subreddit) or 'search_posts' (for searching within subreddit content). It mentions the two search methods but offers no context on which to choose or any prerequisites for usage.

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

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

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