Skip to main content
Glama

get_submission

Retrieve detailed information about a specific Reddit submission by providing its unique ID. Enables quick access to content for browsing or analysis.

Instructions

Retrieve a specific submission by ID.

Args:
    submission_id: ID of the submission to retrieve

Returns:
    Detailed information about the submission

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
submission_idYes

Implementation Reference

  • The main handler function that implements the 'get_submission' tool logic: fetches a Reddit submission by ID using RedditClient and returns formatted data as SubmissionResult.
    @validate_call(validate_return=True)
    def get_submission(submission_id: str) -> SubmissionResult:
        """
        Retrieve a specific submission by ID.
    
        Args:
            submission_id: ID of the submission to retrieve
    
        Returns:
            Detailed information about the submission
        """
        client = RedditClient.get_instance()
        submission = client.reddit.submission(submission_id)
    
        return SubmissionResult(
            title=submission.title,
            url=submission.url,
            author=None if submission.author is None else submission.author.name,
            subreddit=submission.subreddit.display_name,
            score=submission.score,
            num_comments=submission.num_comments,
            selftext=submission.selftext,
            created_utc=format_utc_timestamp(submission.created_utc),
        )
  • Pydantic BaseModel defining the output schema for the get_submission tool.
    class SubmissionResult(BaseModel):
        """Reddit submission details"""
    
        title: str = Field(description="Title of the submission")
        url: str = Field(description="URL of the submission")
        author: str | None = Field(description="Username of the author, or None if deleted")
        subreddit: str = Field(description="Name of the subreddit")
        score: int = Field(description="Number of upvotes minus downvotes")
        num_comments: int = Field(description="Number of comments on the submission")
        selftext: str = Field(description="Text content of the submission")
        created_utc: str = Field(description="UTC timestamp when submission was created")
  • Imports get_submission and includes it in the __all__ and 'tools' list, which is used for registering tools to the MCP server.
    from .get_submission import get_submission
    from .get_subreddit import get_subreddit
    from .get_comments import get_comments_by_submission, get_comment_by_id
    from .search_posts import search_posts
    from .search_subreddits import search_subreddits
    
    __all__ = [
        "get_submission",
        "get_subreddit",
        "get_comments_by_submission",
        "get_comment_by_id",
        "search_posts",
        "search_subreddits",
    ]
    
    # Registry of all available tools
    tools = [
        get_submission,
        get_subreddit,
        get_comments_by_submission,
        get_comment_by_id,
        search_posts,
        search_subreddits,
    ]
  • The MCP server setup function that imports the 'tools' list and registers each tool (including get_submission) to the FastMCP instance.
    from mcp.server.fastmcp import FastMCP
    from .tools import tools
    import logging
    
    
    def serve():
        logger = logging.getLogger("mcp")
    
        mcp = FastMCP("Reddit")
    
        for tool in tools:
            logger.info(f"Registering tool: {tool.__name__}")
            mcp.tool()(tool)
    
        logger.info("Starting MCP server...")
        mcp.run(transport="stdio")
Install Server

Other Tools

Related 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/GridfireAI/reddit-mcp'

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