Skip to main content
Glama

get_comment

Retrieve a specific Reddit comment using its unique ID to access detailed discussion content and context.

Instructions

Accéder à un commentaire spécifique

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
comment_idYesL'ID du commentaire à récupérer

Implementation Reference

  • Main handler function for the 'get_comment' tool. It takes comment_id parameter, fetches the comment using RedditClient.getComment, formats it, and returns MCP-formatted content.
    export async function getComment(params: { comment_id: string }) {
      const { comment_id } = params;
      const client = getRedditClient();
    
      if (!client) {
        throw new McpError(
          ErrorCode.InternalError,
          "Reddit client not initialized"
        );
      }
    
      try {
        console.log(`[Tool] Getting comment ${comment_id}`);
        const comment = await client.getComment(comment_id);
        const formattedComment = formatCommentInfo(comment);
    
        return {
          content: [
            {
              type: "text",
              text: `
    # Commentaire Reddit
    
    ## Détails du commentaire
    - Auteur: u/${formattedComment.author}
    - Score: ${formattedComment.stats.score}
    - Controverse: ${formattedComment.stats.controversiality}
    
    ## Contenu
    ${formattedComment.content}
    
    ## Contexte
    - Subreddit: r/${formattedComment.context.subreddit}
    - Thread: ${formattedComment.context.thread}
    
    ## Métadonnées
    - Posté: ${formattedComment.metadata.posted}
    - Drapeaux: ${formattedComment.metadata.flags.length ? formattedComment.metadata.flags.join(", ") : "Aucun"}
    
    ## Lien
    ${formattedComment.link}
    
    ## Analyse du commentaire
    ${formattedComment.commentAnalysis}
              `,
            },
          ],
        };
      } catch (error) {
        console.error(`[Error] Error getting comment: ${error}`);
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to fetch comment: ${error}`
        );
      }
    }
  • src/index.ts:231-242 (registration)
    Registration of the 'get_comment' tool in the MCP server's tool list, including name, description, and input schema.
    name: "get_comment",
    description: "Accéder à un commentaire spécifique",
    inputSchema: {
      type: "object",
      properties: {
        comment_id: {
          type: "string",
          description: "L'ID du commentaire à récupérer",
        },
      },
      required: ["comment_id"],
    },
  • Dispatch handler in the main tool call switch statement that routes 'get_comment' calls to tools.getComment.
    case "get_comment":
      return await tools.getComment(
        toolParams as { comment_id: string }
      );
  • RedditClient method that performs the actual API call to fetch a specific comment by ID from Reddit's API.
    async getComment(commentId: string): Promise<RedditComment> {
      await this.authenticate();
      try {
        const response = await this.api.get(`/api/info.json?id=t1_${commentId}`);
        
        if (!response.data.data.children.length) {
          throw new Error(`Comment with ID ${commentId} not found`);
        }
    
        const comment = response.data.data.children[0].data;
        return {
          id: comment.id,
          author: comment.author,
          body: comment.body,
          score: comment.score,
          controversiality: comment.controversiality,
          subreddit: comment.subreddit,
          submissionTitle: comment.link_title || "",
          createdUtc: comment.created_utc,
          edited: !!comment.edited,
          isSubmitter: comment.is_submitter,
          permalink: comment.permalink,
        };
      } catch (error) {
        console.error(`[Error] Failed to get comment with ID ${commentId}:`, error);
        throw new Error(`Failed to get comment with ID ${commentId}`);
      }
    }
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. It states 'access' but doesn't disclose behavioral traits such as whether this is a read-only operation, requires authentication, has rate limits, or what the return format might be. The description is minimal and lacks necessary context for safe and effective use.

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

Conciseness4/5

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

The description is a single, efficient sentence in French, front-loaded with the core action. It's appropriately sized for a simple tool, with no wasted words, though it could be slightly more informative without losing conciseness.

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

Completeness2/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 (1 parameter, no output schema, no annotations), the description is incomplete. It doesn't explain what 'access' means operationally, the expected return value, or how it fits among sibling tools. For a basic retrieval tool, more context is needed to ensure proper use.

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

Parameters3/5

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

The input schema has 100% description coverage, with 'comment_id' clearly documented as 'L'ID du commentaire à récupérer' (The ID of the comment to retrieve). The description adds no additional meaning beyond the schema, as it doesn't elaborate on parameter usage or constraints. Baseline 3 is appropriate since the schema does the heavy lifting.

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

Purpose3/5

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

The description 'Accéder à un commentaire spécifique' (Access a specific comment) states a clear verb ('access') and resource ('comment'), but it's vague about what 'access' entails—it could mean retrieve, view, or fetch. It doesn't differentiate from siblings like 'get_user_comments' or 'get_comments_by_submission', which are related but not identical.

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 is provided on when to use this tool versus alternatives. For example, it doesn't specify that this is for a single comment by ID, unlike 'get_user_comments' for multiple comments by user or 'get_comments_by_submission' for comments on a submission. The description implies usage for a specific comment but offers no explicit context or exclusions.

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

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

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