Skip to main content
Glama
Hawstein

MCP Server Reddit

by Hawstein

get_post_comments

Retrieve comments from Reddit posts by providing a post ID, with configurable limits for comment quantity.

Instructions

Get comments from a post

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
post_idYesID of the post
limitNoNumber of comments to return (default: 10)

Implementation Reference

  • The core handler function that fetches the comment tree from Reddit using redditwarp.Client and constructs a flat list of top-level Comment objects using the _build_comment_tree helper.
    def get_post_comments(self, post_id: str, limit: int = 10) -> list[Comment]:
        """Get comments from a post"""
        comments = []
        tree_node = self.client.p.comment_tree.fetch(post_id, sort='top', limit=limit)
        for node in tree_node.children:
            comment = self._build_comment_tree(node)
            if comment:
                comments.append(comment)
        return comments
  • The input schema definition for the get_post_comments tool, registered in the list_tools handler.
    Tool(
        name=RedditTools.GET_POST_COMMENTS.value,
        description="Get comments from a post",
        inputSchema={
            "type": "object",
            "properties": {
                "post_id": {
                    "type": "string",
                    "description": "ID of the post",
                },
                "limit": {
                    "type": "integer",
                    "description": "Number of comments to return (default: 10)",
                    "default": 10,
                    "minimum": 1,
                    "maximum": 100
                }
            },
            "required": ["post_id"]
        }
    ),
  • The dispatch case in the call_tool handler that validates arguments and invokes the get_post_comments method.
    case RedditTools.GET_POST_COMMENTS.value:
        post_id = arguments.get("post_id")
        if not post_id:
            raise ValueError("Missing required argument: post_id")
        limit = arguments.get("limit", 10)
        result = reddit_server.get_post_comments(post_id, limit)
  • Recursive helper function to build nested Comment objects from the redditwarp comment tree node, limiting depth to prevent excessive recursion.
    def _build_comment_tree(self, node, depth: int = 3) -> Comment | None:
        """Helper method to recursively build comment tree"""
        if depth <= 0 or not node:
            return None
    
        comment = node.value
        replies = []
        for child in node.children:
            child_comment = self._build_comment_tree(child, depth - 1)
            if child_comment:
                replies.append(child_comment)
    
        return Comment(
            id=comment.id36,
            author=comment.author_display_name or '[deleted]',
            body=comment.body,
            score=comment.score,
            replies=replies
        )
  • Pydantic model defining the structure of a Comment, used as return type for get_post_comments.
    class Comment(BaseModel):
        id: str
        author: str
        body: str
        score: int
        replies: list['Comment'] = []
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Get comments from a post' implies a read-only operation, but it doesn't specify authentication needs, rate limits, pagination behavior, or error conditions. For a tool with no annotation coverage, this leaves significant gaps in understanding its operational characteristics.

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 with zero wasted words. It's front-loaded with the core purpose and appropriately sized for a simple retrieval tool, making it easy to parse quickly.

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?

Given no annotations and no output schema, the description is incomplete for a tool that likely returns structured comment data. It doesn't explain what the return format looks like (e.g., list of comments with fields like author, text, timestamp), error handling, or any dependencies. For a retrieval tool with missing structured context, this is inadequate.

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%, with clear documentation for both parameters (post_id and limit with default and constraints). The description doesn't add any meaningful semantic context beyond what the schema already provides, such as explaining what constitutes a valid post_id or how comments are ordered. Baseline 3 is appropriate when the schema does the heavy lifting.

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 'Get comments from a post' clearly states the action (get) and resource (comments from a post), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_post_content' which might also retrieve post-related data, so it's not fully distinctive.

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_post_content' that might retrieve different aspects of a post, there's no indication of when comments are needed versus post content or how this differs from other comment-related tools that might exist in a broader context.

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