Skip to main content
Glama

MCP Server Reddit

by Hawstein

get_post_content

Retrieve post content, top-level comments, and nested replies from Reddit using a post ID. Specify comment depth and limit for tailored results with the MCP Server Reddit integration.

Instructions

Get detailed content of a specific post

Input Schema

NameRequiredDescriptionDefault
comment_depthNoMaximum depth of comment tree (default: 3)
comment_limitNoNumber of top-level comments to return (default: 10)
post_idYesID of the post

Input Schema (JSON Schema)

{ "properties": { "comment_depth": { "default": 3, "description": "Maximum depth of comment tree (default: 3)", "maximum": 10, "minimum": 1, "type": "integer" }, "comment_limit": { "default": 10, "description": "Number of top-level comments to return (default: 10)", "maximum": 100, "minimum": 1, "type": "integer" }, "post_id": { "description": "ID of the post", "type": "string" } }, "required": [ "post_id" ], "type": "object" }

Implementation Reference

  • The main handler method for the 'get_post_content' tool. It fetches the Reddit post submission by ID, builds the Post object using internal helpers, fetches comments via get_post_comments, and returns a PostDetail object containing the post and its comments.
    def get_post_content(self, post_id: str, comment_limit: int = 10, comment_depth: int = 3) -> PostDetail: """Get detailed content of a specific post including comments""" submission = self.client.p.submission.fetch(post_id) post = self._build_post(submission) # Fetch comments comments = self.get_post_comments(post_id, comment_limit) return PostDetail(post=post, comments=comments)
  • Pydantic input schema for the get_post_content tool, defining required post_id and optional comment_limit and comment_depth parameters with validation.
    Tool( name=RedditTools.GET_POST_CONTENT.value, description="Get detailed content of a specific post", inputSchema={ "type": "object", "properties": { "post_id": { "type": "string", "description": "ID of the post", }, "comment_limit": { "type": "integer", "description": "Number of top-level comments to return (default: 10)", "default": 10, "minimum": 1, "maximum": 100 }, "comment_depth": { "type": "integer", "description": "Maximum depth of comment tree (default: 3)", "default": 3, "minimum": 1, "maximum": 10 } }, "required": ["post_id"] } ),
  • Registration and dispatch logic in the @server.call_tool() handler that matches the tool name, validates and extracts arguments, and invokes the handler method.
    case RedditTools.GET_POST_CONTENT.value: post_id = arguments.get("post_id") if not post_id: raise ValueError("Missing required argument: post_id") comment_limit = arguments.get("comment_limit", 10) comment_depth = arguments.get("comment_depth", 3) result = reddit_server.get_post_content(post_id, comment_limit, comment_depth)
  • Helper method used by the post builder to extract content (permalink, body, or gallery link) from the submission based on its type.
    def _get_post_content(self, submission) -> str | None: """Helper method to extract post content based on type""" if isinstance(submission, redditwarp.models.submission_SYNC.LinkPost): return submission.permalink elif isinstance(submission, redditwarp.models.submission_SYNC.TextPost): return submission.body elif isinstance(submission, redditwarp.models.submission_SYNC.GalleryPost): return str(submission.gallery_link) return None
  • Pydantic model defining the output structure of the get_post_content tool, containing the Post and list of Comments.
    class PostDetail(BaseModel): post: Post comments: list[Comment]

Other Tools

Related 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