get_subreddit
Retrieve detailed information about a specific subreddit by providing its name. Use this tool to browse, search, and read subreddit content through the Reddit MCP server.
Instructions
Retrieve a subreddit by name.
Args:
subreddit_name: Name of the subreddit to retrieve
Returns:
Detailed information about the subreddit
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subreddit_name | Yes |
Implementation Reference
- The main handler function that retrieves subreddit details using RedditClient and returns a structured SubredditResult.@validate_call(validate_return=True) def get_subreddit(subreddit_name: str) -> SubredditResult: """ Retrieve a subreddit by name. Args: subreddit_name: Name of the subreddit to retrieve Returns: Detailed information about the subreddit """ client = RedditClient.get_instance() subreddit = client.reddit.subreddit(subreddit_name) return SubredditResult( display_name=subreddit.display_name, title=subreddit.title, description=subreddit.description, public_description=subreddit.public_description, subscribers=subreddit.subscribers, created_utc=subreddit.created_utc, over18=subreddit.over18, url=subreddit.url, )
- Pydantic BaseModel defining the output schema for the get_subreddit tool.class SubredditResult(BaseModel): """Subreddit details""" display_name: str = Field(description="Display name of the subreddit") title: str = Field(description="Title of the subreddit") description: str = Field(description="Full subreddit description") public_description: str = Field(description="Short public description") subscribers: int = Field(description="Number of subscribers") created_utc: float = Field(description="UTC timestamp when subreddit was created") over18: bool = Field(description="Whether the subreddit is NSFW") url: str = Field(description="URL of the subreddit")
- src/reddit_mcp/tools/__init__.py:17-24 (registration)The 'tools' list collects all tool functions, including get_subreddit, for registration in the MCP server.tools = [ get_submission, get_subreddit, get_comments_by_submission, get_comment_by_id, search_posts, search_subreddits, ]
- src/reddit_mcp/server.py:10-14 (registration)Loop that registers each tool from the 'tools' list using FastMCP's tool decorator.for tool in tools: logger.info(f"Registering tool: {tool.__name__}") mcp.tool()(tool)