get_subreddit_info
Retrieve detailed information about a specific subreddit, such as description, rules, and activity metrics, using the public Reddit API through the MCP Server Reddit.
Instructions
Get information about a subreddit
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subreddit_name | Yes | Name of the subreddit (e.g. 'Python', 'news') |
Implementation Reference
- src/mcp_server_reddit/server.py:116-123 (handler)The handler function that implements the core logic of fetching subreddit information using redditwarp Client and constructing a SubredditInfo object.def get_subreddit_info(self, subreddit_name: str) -> SubredditInfo: """Get information about a subreddit""" subr = self.client.p.subreddit.fetch_by_name(subreddit_name) return SubredditInfo( name=subr.name, subscriber_count=subr.subscriber_count, description=subr.public_description )
- Pydantic BaseModel defining the output structure for the get_subreddit_info tool.class SubredditInfo(BaseModel): name: str subscriber_count: int description: str | None
- src/mcp_server_reddit/server.py:218-231 (registration)Tool registration in the list_tools() function, defining the tool name, description, and input schema.Tool( name=RedditTools.GET_SUBREDDIT_INFO.value, description="Get information about a subreddit", inputSchema={ "type": "object", "properties": { "subreddit_name": { "type": "string", "description": "Name of the subreddit (e.g. 'Python', 'news')", } }, "required": ["subreddit_name"] } ),
- src/mcp_server_reddit/server.py:384-388 (registration)Dispatch logic in the call_tool() function that extracts arguments and invokes the handler.case RedditTools.GET_SUBREDDIT_INFO.value: subreddit_name = arguments.get("subreddit_name") if not subreddit_name: raise ValueError("Missing required argument: subreddit_name") result = reddit_server.get_subreddit_info(subreddit_name)
- Enum value defining the tool name constant.GET_SUBREDDIT_INFO = "get_subreddit_info"