reddit_get_subreddit_posts
Fetch posts from any Reddit subreddit by specifying category, time filter, and quantity limits to gather community discussions.
Instructions
Get posts from a subreddit listing.
Args: subreddit: Subreddit name without r/ prefix (e.g., 'Python', 'news') limit: Maximum number of posts (default: 25, max: 100) category: Listing category (hot, top, new, rising). Default: hot time_filter: Time window for top listings (hour, day, week, month, year, all). Default: all
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subreddit | Yes | ||
| limit | No | ||
| category | No | ||
| time_filter | No |
Implementation Reference
- The handler function for 'reddit_get_subreddit_posts' which uses the PostService to fetch posts and serializes the response.
async def reddit_get_subreddit_posts( subreddit: str, ctx: Context, limit: int = 25, category: str | None = None, time_filter: str | None = None, ) -> list[dict[str, Any]]: try: results = await service.get_subreddit_posts( subreddit, limit=limit, category=category, time_filter=time_filter ) return McpSerializer.serialize_list(results) except Exception as e: McpErrorMapper.map(e, "reddit_get_subreddit_posts") - Registration of the 'reddit_get_subreddit_posts' tool with its description and arguments using FastMCP.
@mcp.tool( name="reddit_get_subreddit_posts", description=( "Get posts from a subreddit listing.\n\n" "Args:\n" " subreddit: Subreddit name without r/ prefix (e.g., 'Python', 'news')\n" " limit: Maximum number of posts (default: 25, max: 100)\n" " category: Listing category (hot, top, new, rising). Default: hot\n" " time_filter: Time window for top listings " "(hour, day, week, month, year, all). Default: all" ), )