Skip to main content
Glama
Hawstein

MCP Server Reddit

by Hawstein

get_subreddit_top_posts

Retrieve top posts from any subreddit using time filters and customizable limits to monitor trending discussions and content.

Instructions

Get top posts from a specific subreddit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subreddit_nameYesName of the subreddit (e.g. 'Python', 'news')
limitNoNumber of posts to return (default: 10)
timeNoTime filter for top posts (e.g. 'hour', 'day', 'week', 'month', 'year', 'all')

Implementation Reference

  • The core handler function in the RedditServer class that fetches the top posts from a subreddit using the redditwarp client, builds Post objects using the _build_post helper, and returns the list.
    def get_subreddit_top_posts(self, subreddit_name: str, limit: int = 10, time: str = '') -> list[Post]:
        """Get top posts from a specific subreddit"""
        posts = []
        for subm in self.client.p.subreddit.pull.top(subreddit_name, limit, time=time):
            posts.append(self._build_post(subm))
        return posts
  • Input JSON schema for the get_subreddit_top_posts tool, defining parameters subreddit_name (required), limit, and time filter.
    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
            },
            "time": {
                "type": "string",
                "description": "Time filter for top posts (e.g. 'hour', 'day', 'week', 'month', 'year', 'all')",
                "default": "",
                "enum": ["", "hour", "day", "week", "month", "year", "all"]
            }
        },
        "required": ["subreddit_name"]
    }
  • Registration of the get_subreddit_top_posts tool in the list_tools() handler, including name, description, and input schema.
    Tool(
        name=RedditTools.GET_SUBREDDIT_TOP_POSTS.value,
        description="Get top 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
                },
                "time": {
                    "type": "string",
                    "description": "Time filter for top posts (e.g. 'hour', 'day', 'week', 'month', 'year', 'all')",
                    "default": "",
                    "enum": ["", "hour", "day", "week", "month", "year", "all"]
                }
            },
            "required": ["subreddit_name"]
        }
    ),
  • Dispatch logic in the MCP server's call_tool handler that extracts arguments and calls the get_subreddit_top_posts method on the RedditServer instance.
    case RedditTools.GET_SUBREDDIT_TOP_POSTS.value:
        subreddit_name = arguments.get("subreddit_name")
        if not subreddit_name:
            raise ValueError("Missing required argument: subreddit_name")
        limit = arguments.get("limit", 10)
        time = arguments.get("time", "")
        result = reddit_server.get_subreddit_top_posts(subreddit_name, limit, time)
  • Helper function used by get_subreddit_top_posts to construct Post model instances from redditwarp submission objects.
    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)
        )
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 what the tool does but provides no information about authentication requirements, rate limits, error conditions, response format, or pagination behavior. For a read operation that likely has API constraints, this is a significant gap.

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 a single, efficient sentence that communicates the core purpose without any wasted words. It's appropriately sized for a straightforward tool and gets directly to the point.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what 'top' means algorithmically, doesn't describe the return format, and provides no context about authentication or API limitations. The description should do more to compensate for the lack of structured metadata.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so all parameters are well-documented in the schema itself. The description adds no additional parameter information beyond what's already in the schema descriptions. This meets the baseline expectation when schema coverage is complete.

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 verb 'Get' and resource 'top posts from a specific subreddit', making the purpose immediately understandable. It distinguishes from some siblings like 'get_subreddit_info' or 'get_post_comments', but doesn't explicitly differentiate from other post-fetching siblings like 'get_subreddit_hot_posts' or 'get_subreddit_new_posts'.

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. With siblings like 'get_subreddit_hot_posts', 'get_subreddit_new_posts', and 'get_subreddit_rising_posts' available, there's no indication of what 'top' means or when it's preferable to other sorting methods.

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

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