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
            ],
        )
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves comment details with replies, which implies a read-only operation, but doesn't cover aspects like error handling (e.g., what happens if the ID is invalid), authentication needs, rate limits, or data format. This leaves significant gaps in understanding the tool's behavior.

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?

The description is well-structured and front-loaded with the core purpose, followed by clear sections for arguments and returns. Every sentence adds value without redundancy, making it efficient and easy to parse for an AI agent.

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

Completeness3/5

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

Given the tool's low complexity (one parameter, no output schema, no annotations), the description is minimally adequate but lacks depth. It covers the basic operation and parameter semantics but omits behavioral details like error cases or output structure, which could hinder an agent's ability to use it correctly in edge scenarios.

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?

The description adds meaningful context for the single parameter by explaining that 'comment_id' is the 'ID of the comment to retrieve', which clarifies its purpose beyond the schema's basic type information. With 0% schema description coverage and only one parameter, this compensation is adequate, though it could benefit from details like ID format or examples.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('Retrieve') and resource ('a specific comment by ID'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'get_comments_by_submission', which might retrieve multiple comments, leaving some ambiguity about when to choose this tool over others.

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

Usage Guidelines3/5

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

The description implies usage by specifying 'a specific comment by ID', suggesting it's for retrieving a single, known comment. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'get_comments_by_submission' or mention any prerequisites or exclusions, leaving the agent to infer context from the parameter name alone.

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

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