reddit_search_subreddit
Search for content within a specific Reddit community using keywords, with options to sort results and limit the number of posts returned.
Instructions
Search within a specific subreddit.
Args: subreddit: Subreddit name without r/ prefix (e.g., 'Python', 'MachineLearning') query: Search keywords limit: Maximum number of results to return (default: 25, max: 100) sort: Sort order for results (relevance, hot, top, new, comments)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subreddit | Yes | ||
| query | Yes | ||
| limit | No | ||
| sort | No |
Implementation Reference
- The handler function `reddit_search_subreddit` that processes the tool call by delegating to the search_service and serializing the response.
async def reddit_search_subreddit( subreddit: str, query: str, ctx: Context, limit: int = 25, sort: str | None = None, ) -> list[dict[str, Any]]: try: results = await service.search_subreddit(subreddit, query, limit=limit, sort=sort) return McpSerializer.serialize_list(results) except Exception as e: McpErrorMapper.map(e, "reddit_search_subreddit") - Registration of the `reddit_search_subreddit` tool using the FastMCP decorator.
@mcp.tool( name="reddit_search_subreddit", description=( "Search within a specific subreddit.\n\n" "Args:\n" " subreddit: Subreddit name without r/ prefix " "(e.g., 'Python', 'MachineLearning')\n" " query: Search keywords\n" " limit: Maximum number of results to return " "(default: 25, max: 100)\n" " sort: Sort order for results " "(relevance, hot, top, new, comments)" ), )