Skip to main content
Glama

get_reddit_post

Fetch specific Reddit posts by providing the subreddit name and post ID to retrieve content and discussions from any community.

Instructions

Get a Reddit post

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
post_idYesThe ID of the post to fetch
subredditYesThe subreddit to fetch posts from

Implementation Reference

  • Core handler function that executes the get_reddit_post tool: fetches Reddit post data, formats it richly with stats, metadata, engagement analysis, and returns MCP-formatted content.
    export async function getRedditPost(params: { subreddit: string; post_id: string; }) { const { subreddit, post_id } = params; const client = getRedditClient(); if (!client) { throw new McpError( ErrorCode.InternalError, "Reddit client not initialized" ); } try { console.log(`[Tool] Getting post ${post_id} from r/${subreddit}`); const post = await client.getPost(post_id, subreddit); const formattedPost = formatPostInfo(post); return { content: [ { type: "text", text: ` # Post from r/${formattedPost.subreddit} ## Post Details - Title: ${formattedPost.title} - Type: ${formattedPost.type} - Author: u/${formattedPost.author} ## Content ${formattedPost.content} ## Stats - Score: ${formattedPost.stats.score.toLocaleString()} - Upvote Ratio: ${(formattedPost.stats.upvoteRatio * 100).toFixed(1)}% - Comments: ${formattedPost.stats.comments.toLocaleString()} ## Metadata - Posted: ${formattedPost.metadata.posted} - Flags: ${ formattedPost.metadata.flags.length ? formattedPost.metadata.flags.join(", ") : "None" } - Flair: ${formattedPost.metadata.flair} ## Links - Full Post: ${formattedPost.links.fullPost} - Short Link: ${formattedPost.links.shortLink} ## Engagement Analysis - ${formattedPost.engagementAnalysis.replace(/\n - /g, "\n- ")} ## Best Time to Engage ${formattedPost.bestTimeToEngage} `, }, ], }; } catch (error) { console.error(`[Error] Error getting post: ${error}`); throw new McpError( ErrorCode.InternalError, `Failed to fetch post data: ${error}` ); } }
  • Tool schema definition including name, description, and input schema for validation in the ListTools response.
    name: "get_reddit_post", description: "Get a Reddit post", inputSchema: { type: "object", properties: { subreddit: { type: "string", description: "The subreddit to fetch posts from", }, post_id: { type: "string", description: "The ID of the post to fetch", }, }, required: ["subreddit", "post_id"], }, },
  • src/index.ts:429-432 (registration)
    Tool registration in the CallToolRequestHandler switch statement, dispatching to the handler function.
    case "get_reddit_post": return await tools.getRedditPost( toolParams as { subreddit: string; post_id: string } );

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/samy-clivolt/reddit-mcp-server'

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