Skip to main content
Glama
liuyang1520

Reddit MCP Server

by liuyang1520

get_subreddit_info

Retrieve subreddit details like description, subscriber count, and rules to analyze community data from Reddit's API.

Instructions

Get information about a subreddit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subredditYesName of the subreddit (without r/ prefix)

Implementation Reference

  • Core handler function that authenticates, makes API request to Reddit for subreddit info, and maps the response to a structured RedditSubreddit object.
    async getSubredditInfo(subreddit: string): Promise<RedditSubreddit> {
      const data = await this.makeRequest(`/r/${subreddit}/about`);
      return this.mapSubreddit(data.data);
    }
  • Zod schema for validating input parameters (subreddit name) to the get_subreddit_info tool.
    const GetSubredditInfoSchema = z.object({
      subreddit: z.string().min(1, "Subreddit name is required"),
    });
  • src/index.ts:150-163 (registration)
    Tool registration in the MCP server's listTools response, defining name, description, and input schema.
    {
      name: 'get_subreddit_info',
      description: 'Get information about a subreddit',
      inputSchema: {
        type: 'object',
        properties: {
          subreddit: {
            type: 'string',
            description: 'Name of the subreddit (without r/ prefix)',
          },
        },
        required: ['subreddit'],
      },
    },
  • MCP dispatch handler case that parses arguments using the schema, calls the RedditClient handler, and formats the JSON response.
    case 'get_subreddit_info': {
      const args = GetSubredditInfoSchema.parse(request.params.arguments);
      const subreddit = await redditClient.getSubredditInfo(args.subreddit);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(subreddit, null, 2),
          },
        ],
      };
    }
  • TypeScript interface defining the output structure for subreddit information returned by the handler.
    export interface RedditSubreddit {
      display_name: string;
      title: string;
      description: string;
      subscribers: number;
      created_utc: number;
      public_description: string;
      url: string;
      over18: boolean;
    }

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/liuyang1520/reddit-mcp'

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