Skip to main content
Glama
Hawstein

MCP Server Reddit

by Hawstein

get_subreddit_info

Retrieve details about any Reddit community, including description, subscriber count, and rules, to understand its purpose and content.

Instructions

Get information about a subreddit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subreddit_nameYesName of the subreddit (e.g. 'Python', 'news')

Implementation Reference

  • The handler function in the RedditServer class that fetches and returns subreddit information using the redditwarp client.
    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 model defining the structure of the subreddit information output.
    class SubredditInfo(BaseModel):
        name: str
        subscriber_count: int
        description: str | None
  • Tool registration in list_tools(), 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"]
        }
    ),
  • Dispatch logic in call_tool() that handles 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)

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

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