Skip to main content
Glama

get_comment_by_id

Retrieve detailed information and replies for a specific Reddit comment using its unique ID, enabling focused analysis or response generation.

Instructions

Retrieve a specific comment by ID.

Args:
    comment_id: ID of the comment to retrieve

Returns:
    Comment details with any replies

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
comment_idYes

Implementation Reference

  • The handler function that retrieves a specific Reddit comment by its ID using the RedditClient and converts it to a CommentResult model.
    @validate_call(validate_return=True)
    def get_comment_by_id(comment_id: str) -> CommentResult:
        """
        Retrieve a specific comment by ID.
    
        Args:
            comment_id: ID of the comment to retrieve
    
        Returns:
            Comment details with any replies
        """
        client = RedditClient.get_instance()
        return comment_to_model(client.reddit.comment(comment_id))
  • Pydantic BaseModel defining the output schema for the comment data, including nested replies.
    class CommentResult(BaseModel):
        """Reddit comment details"""
    
        id: str = Field(description="Unique identifier of the comment")
        body: str = Field(description="Text content of the comment")
        author: str | None = Field(description="Username of the author, or None if deleted")
        created_utc: str = Field(description="UTC timestamp when comment was created")
        is_submitter: bool = Field(
            description="Whether the comment author is the submission author"
        )
        score: int = Field(description="Number of upvotes minus downvotes")
        replies: List["CommentResult"] = Field(
            description="List of reply comments", default_factory=list
        )
    
    
    CommentResult.model_rebuild()  # Required for self-referential models
  • Registers the get_comment_by_id function in the tools list for MCP tool discovery.
    tools = [
        get_submission,
        get_subreddit,
        get_comments_by_submission,
        get_comment_by_id,
        search_posts,
        search_subreddits,
    ]
  • Recursive helper function to convert PRAW comment objects (including replies) to the CommentResult Pydantic model.
    def comment_to_model(comment) -> CommentResult:
        """Convert PRAW comment object to CommentResult model."""
        # Skip MoreComments objects
        if isinstance(comment, MoreComments):
            return None
    
        return CommentResult(
            id=comment.id,
            body=comment.body,
            author=None if comment.author is None else comment.author.name,
            created_utc=format_utc_timestamp(comment.created_utc),
            is_submitter=comment.is_submitter,
            score=comment.score,
            replies=[
                result
                for reply in comment.replies
                if (result := comment_to_model(reply)) is not None
            ],
        )

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It mentions input and output (comment details with replies) but lacks info on behavior for missing IDs, authentication needs, rate limits, or any side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Very concise: three lines covering purpose, args, and returns without any extraneous text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a simple single-parameter tool. Describes what it returns (with replies). Could benefit from clarifying that comment_id is required and mentioning error handling, but overall complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description adds meaningful detail by stating comment_id is 'ID of the comment to retrieve', which clarifies purpose beyond the schema's 'Comment Id' title.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it retrieves a specific comment by ID. It distinguishes from siblings like get_comments_by_submission which retrieves multiple comments for a submission.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives (e.g., get_comments_by_submission) or any context about prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools

Related Tools