Skip to main content
Glama
Hawstein

MCP Server Reddit

by Hawstein

get_post_content

Retrieve detailed content from Reddit posts including comments with configurable depth and limits for analysis or integration.

Instructions

Get detailed content of a specific post

Input Schema

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

Implementation Reference

  • Primary handler function in RedditServer class that fetches the Reddit post by ID, builds the Post object using helper, retrieves comments, and returns a PostDetail object containing post and 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)
  • Registration of the get_post_content tool in the MCP server's list_tools() handler, defining name, description, and input schema.
    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"] } ),
  • Input schema (JSON Schema) for the get_post_content tool, defining parameters post_id (required), comment_limit, and comment_depth.
    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"] }
  • Dispatch handler in the MCP call_tool() function that handles the get_post_content tool call by parsing arguments and invoking the RedditServer.get_post_content 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 function used by _build_post to extract the content string from a Reddit submission based on its type (link, text, gallery). Called indirectly via the main handler.
    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

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