Skip to main content
Glama
olamide-olaniyan

SociaVault MCP Server

get_reddit_subreddit

Retrieve posts from a specific Reddit community to analyze content, trends, or discussions. Enter the subreddit name to access recent posts and engagement data.

Instructions

Get Reddit subreddit posts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subredditYesSubreddit name (without r/)

Implementation Reference

  • Handler for the get_reddit_subreddit tool: extracts subreddit name from arguments, calls Sociavault API, processes response with extractRedditSubreddit helper, and returns formatted posts as JSON.
    if (name === "get_reddit_subreddit") { const { subreddit } = args as { subreddit: string }; const response = await axios.get(`${BASE_URL}/reddit/subreddit`, { headers: { "X-API-Key": API_KEY }, params: { subreddit }, }); const extracted = extractRedditSubreddit(response.data, 10); return { content: [ { type: "text", text: JSON.stringify( { subreddit, posts: extracted, total_returned: extracted.length }, null, 2 ), }, ], }; }
  • src/index.ts:328-341 (registration)
    Registration of the get_reddit_subreddit tool in the tools array, including name, description, and input schema requiring 'subreddit' parameter.
    { name: "get_reddit_subreddit", description: "Get Reddit subreddit posts", inputSchema: { type: "object", properties: { subreddit: { type: "string", description: "Subreddit name (without r/)", }, }, required: ["subreddit"], }, },
  • Input schema for get_reddit_subreddit tool, defining a required 'subreddit' string parameter.
    inputSchema: { type: "object", properties: { subreddit: { type: "string", description: "Subreddit name (without r/)", }, }, required: ["subreddit"], }, },
  • Helper function extractRedditSubreddit that parses API response data into a list of up to 10 formatted post objects with key fields like title, author, score, etc.
    function extractRedditSubreddit(data: any, limit = 10) { const posts = data?.data?.children || data?.children || data?.data?.posts || data?.posts || []; return posts.slice(0, limit).map((item: any) => { const post = item.data || item; return { title: post.title, author: post.author, score: post.score || 0, upvote_ratio: post.upvote_ratio || 0, num_comments: post.num_comments || 0, created_utc: post.created_utc, url: post.url, permalink: post.permalink, selftext: (post.selftext || "").substring(0, 200), // Limit text length is_video: post.is_video || false, }; }); }

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/olamide-olaniyan/sociavault-mcp'

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