Skip to main content
Glama
Hawstein

MCP Server Reddit

by Hawstein

get_frontpage_posts

Retrieve trending posts from the Reddit frontpage to monitor popular discussions and content.

Instructions

Get hot posts from Reddit frontpage

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of posts to return (default: 10)

Implementation Reference

  • The core handler function implementing get_frontpage_posts. Fetches hot posts from Reddit's frontpage using redditwarp.Client, builds Post models using _build_post helper, and returns a list of them.
    def get_frontpage_posts(self, limit: int = 10) -> list[Post]: """Get hot posts from Reddit frontpage""" posts = [] for subm in self.client.p.front.pull.hot(limit): posts.append(self._build_post(subm)) return posts
  • Pydantic BaseModel schema defining the structure of a Reddit Post, used in the return type of get_frontpage_posts.
    class Post(BaseModel): id: str title: str author: str score: int subreddit: str url: str created_at: str comment_count: int post_type: PostType content: str | None
  • Registers the get_frontpage_posts tool with the MCP server in the list_tools handler, specifying name, description, and input JSON schema.
    name=RedditTools.GET_FRONTPAGE_POSTS.value, description="Get hot posts from Reddit frontpage", inputSchema={ "type": "object", "properties": { "limit": { "type": "integer", "description": "Number of posts to return (default: 10)", "default": 10, "minimum": 1, "maximum": 100 } } } ),
  • Key helper function that converts a redditwarp submission object into a structured Post model, called by get_frontpage_posts.
    def _build_post(self, submission) -> Post: """Helper method to build Post object from submission""" return Post( id=submission.id36, title=submission.title, author=submission.author_display_name or '[deleted]', score=submission.score, subreddit=submission.subreddit.name, url=submission.permalink, created_at=submission.created_at.astimezone().isoformat(), comment_count=submission.comment_count, post_type=self._get_post_type(submission), content=self._get_post_content(submission) )
  • In the MCP call_tool handler, matches on tool name and dispatches to the get_frontpage_posts method with parsed arguments.
    case RedditTools.GET_FRONTPAGE_POSTS.value: limit = arguments.get("limit", 10) result = reddit_server.get_frontpage_posts(limit)

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/Hawstein/mcp-server-reddit'

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