Skip to main content
Glama

get_subreddit_info

Retrieve key details about any Reddit community, including rules, member counts, and activity metrics, to understand its purpose and engagement.

Instructions

Get information about a subreddit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subreddit_nameYesName of the subreddit

Implementation Reference

  • Main tool handler that fetches subreddit data via RedditClient, formats it using formatSubredditInfo, and returns a formatted Markdown response.
    export async function getSubredditInfo(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 info for r/${subreddit_name}`);
        const subreddit = await client.getSubredditInfo(subreddit_name);
        const formattedSubreddit = formatSubredditInfo(subreddit);
    
        return {
          content: [
            {
              type: "text",
              text: `
    # Subreddit Information: r/${formattedSubreddit.name}
    
    ## Overview
    - Name: r/${formattedSubreddit.name}
    - Title: ${formattedSubreddit.title}
    - Subscribers: ${formattedSubreddit.stats.subscribers.toLocaleString()}
    - Active Users: ${
                typeof formattedSubreddit.stats.activeUsers === "number"
                  ? formattedSubreddit.stats.activeUsers.toLocaleString()
                  : formattedSubreddit.stats.activeUsers
              }
    
    ## Description
    ${formattedSubreddit.description.short}
    
    ## Detailed Description
    ${formattedSubreddit.description.full}
    
    ## Metadata
    - Created: ${formattedSubreddit.metadata.created}
    - Flags: ${formattedSubreddit.metadata.flags.join(", ")}
    
    ## Links
    - Subreddit: ${formattedSubreddit.links.subreddit}
    - Wiki: ${formattedSubreddit.links.wiki}
    
    ## Community Analysis
    - ${formattedSubreddit.communityAnalysis.replace(/\n  - /g, "\n- ")}
    
    ## Engagement Tips
    - ${formattedSubreddit.engagementTips.replace(/\n  - /g, "\n- ")}
              `,
            },
          ],
        };
      } catch (error) {
        console.error(`[Error] Error getting subreddit info: ${error}`);
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to fetch subreddit data: ${error}`
        );
      }
    }
  • Input schema definition for the get_subreddit_info tool, specifying subreddit_name as required string parameter.
      name: "get_subreddit_info",
      description: "Get information about a subreddit",
      inputSchema: {
        type: "object",
        properties: {
          subreddit_name: {
            type: "string",
            description: "Name of the subreddit",
          },
        },
        required: ["subreddit_name"],
      },
    },
  • src/index.ts:446-449 (registration)
    Tool call routing in the switch statement that invokes the getSubredditInfo handler from the tools module.
    case "get_subreddit_info":
      return await tools.getSubredditInfo(
        toolParams as { subreddit_name: string }
      );
  • RedditClient method that performs the actual API call to fetch raw subreddit data from Reddit.
    async getSubredditInfo(subredditName: string): Promise<RedditSubreddit> {
      await this.authenticate();
      try {
        const response = await this.api.get(`/r/${subredditName}/about.json`);
        const data = response.data.data;
    
        return {
          displayName: data.display_name,
          title: data.title,
          description: data.description || "",
          publicDescription: data.public_description || "",
          subscribers: data.subscribers,
          activeUserCount: data.active_user_count,
          createdUtc: data.created_utc,
          over18: data.over18,
          subredditType: data.subreddit_type,
          url: data.url,
        };
      } catch (error) {
        console.error(
          `[Error] Failed to get subreddit info for ${subredditName}:`,
          error
        );
        throw new Error(`Failed to get subreddit info for ${subredditName}`);
      }
    }
  • Helper function that formats raw RedditSubreddit data into a structured FormattedSubredditInfo object with analysis and tips.
    export function formatSubredditInfo(
      subreddit: RedditSubreddit
    ): FormattedSubredditInfo {
      const flags: string[] = [];
      if (subreddit.over18) flags.push("NSFW");
      if (subreddit.subredditType) flags.push(`Type: ${subreddit.subredditType}`);
    
      const ageDays = (Date.now() / 1000 - subreddit.createdUtc) / (24 * 3600);
    
      return {
        name: subreddit.displayName,
        title: subreddit.title,
        stats: {
          subscribers: subreddit.subscribers,
          activeUsers:
            subreddit.activeUserCount !== undefined
              ? subreddit.activeUserCount
              : "Unknown",
        },
        description: {
          short: subreddit.publicDescription,
          full:
            subreddit.description.length > 300
              ? subreddit.description.substring(0, 297) + "..."
              : subreddit.description,
        },
        metadata: {
          created: formatTimestamp(subreddit.createdUtc),
          flags: flags.length ? flags : ["None"],
        },
        links: {
          subreddit: `https://reddit.com${subreddit.url}`,
          wiki: `https://reddit.com/r/${subreddit.displayName}/wiki`,
        },
        communityAnalysis: analyzeSubredditHealth(
          subreddit.subscribers,
          subreddit.activeUserCount,
          ageDays
        ),
        engagementTips: getSubredditEngagementTips(subreddit),
      };
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It doesn't disclose behavioral traits such as whether this is a read-only operation (implied by 'Get' but not stated), rate limits, authentication needs, error handling, or what happens if the subreddit doesn't exist. The description is minimal and lacks essential context for safe and effective use.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's appropriately sized for a simple tool and front-loaded with the core purpose. Every word earns its place, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what information is returned (e.g., description, subscriber count, rules), potential errors, or usage constraints. For a tool with no structured data beyond the input schema, more context is needed to guide the agent effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no meaning beyond the input schema, which has 100% coverage for the single parameter 'subreddit_name'. The schema already describes it as 'Name of the subreddit', so the description doesn't compensate or provide additional context like format examples (e.g., 'programming' without 'r/'). Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get information about a subreddit' states a clear verb ('Get') and resource ('subreddit'), but it's vague about what specific information is retrieved. It distinguishes from siblings like 'get_top_posts' or 'get_trending_subreddits' by focusing on subreddit metadata rather than content, but lacks specificity about the scope of information.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't clarify if this should be used before posting to check subreddit rules versus using 'get_top_posts' for content discovery, or how it differs from 'get_user_info' for user-specific data. The description implies usage for subreddit metadata but offers no explicit context or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.