Skip to main content
Glama
adhikasp
by adhikasp

fetch_reddit_post_content

Retrieve detailed Reddit post content including comments by providing a post ID, enabling analysis and review of discussions.

Instructions

Fetch detailed content of a specific post

Args: post_id: Reddit post ID comment_limit: Number of top level comments to fetch comment_depth: Maximum depth of comment tree to traverse

Returns: Human readable string containing post content and comments tree

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
post_idYes
comment_limitNo
comment_depthNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main asynchronous handler function for the 'fetch_reddit_post_content' tool. It fetches the Reddit post using redditwarp Client, extracts post details, retrieves top comments up to specified limit and depth, formats them using helper functions, and returns a formatted string. Registered via @mcp.tool() decorator.
    async def fetch_reddit_post_content(post_id: str, comment_limit: int = 20, comment_depth: int = 3) -> str:
        """
        Fetch detailed content of a specific post
    
        Args:
            post_id: Reddit post ID
            comment_limit: Number of top level comments to fetch
            comment_depth: Maximum depth of comment tree to traverse
    
        Returns:
            Human readable string containing post content and comments tree
        """
        try:
            submission = await client.p.submission.fetch(post_id)
    
            content = (
                f"Title: {submission.title}\n"
                f"Score: {submission.score}\n"
                f"Author: {submission.author_display_name or '[deleted]'}\n"
                f"Type: {_get_post_type(submission)}\n"
                f"Content: {_get_content(submission)}\n"
            )
    
            comments = await client.p.comment_tree.fetch(post_id, sort='top', limit=comment_limit, depth=comment_depth)
            if comments.children:
                content += "\nComments:\n"
                for comment in comments.children:
                    content += "\n" + _format_comment_tree(comment)
            else:
                content += "\nNo comments found."
    
            return content
    
        except Exception as e:
            return f"An error occurred: {str(e)}"
  • Recursive helper function to format the comment tree with indentation, including author, score, and body for each comment and its children.
    def _format_comment_tree(comment_node, depth: int = 0) -> str:
        """Helper method to recursively format comment tree with proper indentation"""
        comment = comment_node.value
        indent = "-- " * depth
        content = (
            f"{indent}* Author: {comment.author_display_name or '[deleted]'}\n"
            f"{indent}  Score: {comment.score}\n"
            f"{indent}  {comment.body}\n"
        )
    
        for child in comment_node.children:
            content += "\n" + _format_comment_tree(child, depth + 1)
    
        return content
  • Helper function to determine the type of the Reddit submission (link, text, gallery, or unknown).
    def _get_post_type(submission) -> str:
        """Helper method to determine post type"""
        if isinstance(submission, LinkPost):
            return 'link'
        elif isinstance(submission, TextPost):
            return 'text'
        elif isinstance(submission, GalleryPost):
            return 'gallery'
        return 'unknown'
  • Helper function to extract the appropriate content string from the submission based on its type.
    def _get_content(submission) -> Optional[str]:
        """Helper method to extract post content based on type"""
        if isinstance(submission, LinkPost):
            return submission.permalink
        elif isinstance(submission, TextPost):
            return submission.body
        elif isinstance(submission, GalleryPost):
            return str(submission.gallery_link)
        return None
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. While it states the tool fetches content and returns a human-readable string, it doesn't cover important behavioral aspects like rate limits, authentication requirements, error conditions, pagination, or whether this is a read-only operation. The description is minimal and leaves significant behavioral questions unanswered.

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 extremely well-structured and concise. It begins with a clear purpose statement, then provides a clean 'Args:' section with parameter explanations, followed by a 'Returns:' section. Every sentence earns its place, and the information is front-loaded with the most important details first. No wasted words or redundancy.

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

Completeness3/5

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

Given that there's an output schema (though not shown), the description doesn't need to explain return values in detail. However, for a tool with 3 parameters, 0% schema description coverage, and no annotations, the description provides adequate but minimal coverage. It explains what the tool does and what parameters mean, but lacks behavioral context and usage guidance that would make it more complete.

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

Parameters4/5

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

The description adds significant value beyond the input schema, which has 0% description coverage. It clearly explains what each parameter means: 'post_id: Reddit post ID', 'comment_limit: Number of top level comments to fetch', and 'comment_depth: Maximum depth of comment tree to traverse'. This provides essential semantic context that the bare schema lacks, though it doesn't specify format details or constraints.

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 tool's purpose: 'Fetch detailed content of a specific post' - a specific verb ('fetch') and resource ('detailed content of a specific post'). It distinguishes from the sibling tool 'fetch_reddit_hot_threads' by focusing on individual posts rather than hot threads. However, it doesn't explicitly contrast with the sibling beyond the inherent difference in scope.

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. It doesn't mention the sibling tool 'fetch_reddit_hot_threads' or explain when to fetch a specific post versus browsing hot threads. There are no usage prerequisites, exclusions, or contextual recommendations provided.

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

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