get_subreddit_new_posts
Retrieve recent posts from a specified subreddit using the Reddit API. Specify the subreddit name and limit the number of posts to fetch for up-to-date content monitoring.
Instructions
Get new posts from a specific subreddit
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of posts to return (default: 10) | |
| subreddit_name | Yes | Name of the subreddit (e.g. 'Python', 'news') |
Implementation Reference
- src/mcp_server_reddit/server.py:152-157 (handler)The handler function that implements the logic to fetch new posts from a subreddit using the redditwarp client.def get_subreddit_new_posts(self, subreddit_name: str, limit: int = 10) -> list[Post]: """Get new posts from a specific subreddit""" posts = [] for subm in self.client.p.subreddit.pull.new(subreddit_name, limit): posts.append(self._build_post(subm)) return posts
- The input schema and description for the tool, used in MCP tool registration.Tool( name=RedditTools.GET_SUBREDDIT_NEW_POSTS.value, description="Get new posts from a specific subreddit", inputSchema={ "type": "object", "properties": { "subreddit_name": { "type": "string", "description": "Name of the subreddit (e.g. 'Python', 'news')", }, "limit": { "type": "integer", "description": "Number of posts to return (default: 10)", "default": 10, "minimum": 1, "maximum": 100 } }, "required": ["subreddit_name"] } ),
- src/mcp_server_reddit/server.py:397-402 (registration)The dispatch case in the call_tool handler that routes arguments to the tool handler.case RedditTools.GET_SUBREDDIT_NEW_POSTS.value: subreddit_name = arguments.get("subreddit_name") if not subreddit_name: raise ValueError("Missing required argument: subreddit_name") limit = arguments.get("limit", 10) result = reddit_server.get_subreddit_new_posts(subreddit_name, limit)
- src/mcp_server_reddit/server.py:23-23 (registration)Enum value defining the standardized name for the tool.GET_SUBREDDIT_NEW_POSTS = "get_subreddit_new_posts"