search_subreddits
Find relevant subreddits by searching names and descriptions to discover communities matching specific topics or interests.
Instructions
Search for subreddits
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query for subreddit names/descriptions | |
| limit | No | Number of results to retrieve (1-100) |
Implementation Reference
- src/index.ts:400-411 (handler)MCP tool handler for 'search_subreddits' that validates input with SearchSubredditsSchema and delegates to redditClient.searchSubredditscase 'search_subreddits': { const args = SearchSubredditsSchema.parse(request.params.arguments); const subreddits = await redditClient.searchSubreddits(args.query, args.limit); return { content: [ { type: 'text', text: JSON.stringify(subreddits, null, 2), }, ], }; }
- src/index.ts:81-84 (schema)Zod schema defining input parameters for the search_subreddits tool: query (required string) and limit (optional number, default 25, 1-100)const SearchSubredditsSchema = z.object({ query: z.string().min(1, "Search query is required"), limit: z.number().min(1).max(100).default(25), });
- src/index.ts:268-288 (registration)Registration of the 'search_subreddits' tool in the ListTools response, specifying name, description, and JSON input schema{ name: 'search_subreddits', description: 'Search for subreddits', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query for subreddit names/descriptions', }, limit: { type: 'number', description: 'Number of results to retrieve (1-100)', minimum: 1, maximum: 100, default: 25, }, }, required: ['query'], }, },
- src/reddit-client.ts:185-188 (helper)Core implementation of subreddit search in RedditClient class, making API request to /subreddits/search and mapping results to RedditSubreddit objectsasync searchSubreddits(query: string, limit: number = 25): Promise<RedditSubreddit[]> { const data = await this.makeRequest(`/subreddits/search?q=${encodeURIComponent(query)}&limit=${limit}`); return data.data.children.map((child: any) => this.mapSubreddit(child.data)); }