Skip to main content
Glama

get_subreddit

Access a subreddit by name to retrieve its content and information for analysis or interaction.

Instructions

Accéder à un subreddit par nom

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subreddit_nameYesLe nom du subreddit

Implementation Reference

  • The primary handler function for the 'get_subreddit' MCP tool. It retrieves subreddit data using the Reddit client, formats it with formatSubredditInfo, and returns a formatted text response with details like stats, description, metadata, links, analysis, and engagement tips.
    export async function getSubreddit(params: { subreddit_name: string }) { const { subreddit_name } = params; const client = getRedditClient(); if (!client) { throw new McpError( ErrorCode.InternalError, "Reddit client not initialized" ); } try { console.log(`[Tool] Getting subreddit r/${subreddit_name}`); const subreddit = await client.getSubreddit(subreddit_name); const formattedSubreddit = formatSubredditInfo(subreddit); return { content: [ { type: "text", text: ` # r/${formattedSubreddit.name} ## Informations générales - Titre: ${formattedSubreddit.title} - Abonnés: ${formattedSubreddit.stats.subscribers.toLocaleString()} - Utilisateurs actifs: ${formattedSubreddit.stats.activeUsers} ## Description ### Description courte ${formattedSubreddit.description.short} ### Description complète ${formattedSubreddit.description.full} ## Métadonnées - Créé: ${formattedSubreddit.metadata.created} - Drapeaux: ${formattedSubreddit.metadata.flags.length ? formattedSubreddit.metadata.flags.join(", ") : "Aucun"} ## Liens - Subreddit: ${formattedSubreddit.links.subreddit} - Wiki: ${formattedSubreddit.links.wiki} ## Analyse de la communauté ${formattedSubreddit.communityAnalysis} ## Conseils d'engagement ${formattedSubreddit.engagementTips} `, }, ], }; } catch (error) { console.error(`[Error] Error getting subreddit: ${error}`); throw new McpError( ErrorCode.InternalError, `Failed to fetch subreddit: ${error}` ); } }
  • src/index.ts:277-290 (registration)
    Registration of the 'get_subreddit' tool in the ListToolsRequestHandler, including the tool name, description, and input schema definition.
    { name: "get_subreddit", description: "Accéder à un subreddit par nom", inputSchema: { type: "object", properties: { subreddit_name: { type: "string", description: "Le nom du subreddit", }, }, required: ["subreddit_name"], }, },
  • src/index.ts:488-491 (registration)
    Dispatch logic in the CallToolRequestHandler switch statement that routes calls to the 'get_subreddit' tool to the imported tools.getSubreddit handler function.
    case "get_subreddit": return await tools.getSubreddit( toolParams as { subreddit_name: string } );
  • Re-export of functions from search-tools.ts (including getSubreddit) in the tools index module, allowing centralized import as 'tools.getSubreddit' from src/index.ts.
    export * from "./search-tools";
  • Input schema definition for the 'get_subreddit' tool, specifying the required 'subreddit_name' parameter.
    inputSchema: { type: "object", properties: { subreddit_name: { type: "string", description: "Le nom du subreddit", }, }, required: ["subreddit_name"], },

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