Skip to main content
Glama
liuyang1520

Reddit MCP Server

by liuyang1520

search_posts

Find Reddit posts by searching with keywords, filtering by subreddit, sorting by relevance or time, and retrieving specific numbers of results.

Instructions

Search for Reddit posts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
subredditNoOptional: restrict search to specific subreddit
sortNoSort order for search resultsrelevance
timeNoTime period to filter results (works best with sort=top)
limitNoNumber of results to retrieve (1-100)

Implementation Reference

  • MCP tool handler for 'search_posts': parses arguments using SearchPostsSchema, calls redditClient.searchPosts, and returns JSON stringified results.
    case 'search_posts': {
      const args = SearchPostsSchema.parse(request.params.arguments);
      const posts = await redditClient.searchPosts(args.query, args.subreddit, args.sort, args.time, args.limit);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(posts, null, 2),
          },
        ],
      };
    }
  • Zod schema for validating 'search_posts' tool input parameters.
    const SearchPostsSchema = z.object({
      query: z.string().min(1, "Search query is required"),
      subreddit: z.string().optional(),
      sort: z.enum(['relevance', 'hot', 'top', 'new', 'comments']).default('relevance'),
      time: z.enum(['hour', 'day', 'week', 'month', 'year', 'all']).optional(),
      limit: z.number().min(1).max(100).default(25),
    });
  • src/index.ts:232-267 (registration)
    Tool registration in listTools response, defining name, description, and JSON inputSchema matching the Zod schema.
    {
      name: 'search_posts',
      description: 'Search for Reddit posts',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query',
          },
          subreddit: {
            type: 'string',
            description: 'Optional: restrict search to specific subreddit',
          },
          sort: {
            type: 'string',
            enum: ['relevance', 'hot', 'top', 'new', 'comments'],
            description: 'Sort order for search results',
            default: 'relevance',
          },
          time: {
            type: 'string',
            enum: ['hour', 'day', 'week', 'month', 'year', 'all'],
            description: 'Time period to filter results (works best with sort=top)',
          },
          limit: {
            type: 'number',
            description: 'Number of results to retrieve (1-100)',
            minimum: 1,
            maximum: 100,
            default: 25,
          },
        },
        required: ['query'],
      },
    },
  • Core implementation of post search logic in RedditClient: constructs Reddit search API endpoint with parameters and fetches/maps results.
    async searchPosts(query: string, subreddit?: string, sort: 'relevance' | 'hot' | 'top' | 'new' | 'comments' = 'relevance', time?: 'hour' | 'day' | 'week' | 'month' | 'year' | 'all', limit: number = 25): Promise<RedditPost[]> {
      const searchPath = subreddit ? `/r/${subreddit}/search` : '/search';
      const params = new URLSearchParams({
        q: query,
        sort,
        limit: limit.toString(),
        type: 'link',
        ...(subreddit && { restrict_sr: 'true' }),
        ...(time && { t: time })
      });
      
      const data = await this.makeRequest(`${searchPath}?${params}`);
      return data.data.children.map((child: any) => this.mapPost(child.data));
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the basic action ('Search for Reddit posts') without mentioning any behavioral traits such as rate limits, authentication needs, pagination, error handling, or what the search results include (e.g., post metadata). This leaves significant gaps for an agent to understand how the tool behaves in practice.

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 ('Search for Reddit posts') that is front-loaded and wastes no words. It directly conveys the core purpose without unnecessary elaboration, making it highly concise and well-structured for quick understanding.

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

Completeness3/5

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

Given the tool's moderate complexity (5 parameters, no output schema, no annotations), the description is minimally adequate but incomplete. It covers the basic action but lacks context on behavioral traits, usage guidelines, and output details, which are crucial for an agent to use the tool effectively. Without annotations or output schema, more descriptive context would be beneficial.

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 input schema has 100% description coverage, with each parameter clearly documented (e.g., 'query' as search query, 'subreddit' as optional restriction). The description adds no additional meaning beyond what the schema provides, such as explaining how parameters interact (e.g., that 'time' works best with 'sort=top'). Baseline 3 is appropriate since the schema does the heavy lifting.

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

Purpose4/5

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

The description 'Search for Reddit posts' clearly states the verb (search) and resource (Reddit posts), making the purpose immediately understandable. However, it doesn't distinguish this tool from sibling tools like 'search_subreddits' or 'get_subreddit_posts', which also involve searching or retrieving Reddit content, so it lacks sibling differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to prefer this over 'search_subreddits' (for finding subreddits) or 'get_subreddit_posts' (for browsing posts in a specific subreddit), nor does it specify any prerequisites or exclusions for usage.

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

Install Server

Other Tools

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