Skip to main content
Glama

get_comments_by_submission

Retrieve comments from a Reddit submission by providing its ID, enabling analysis of discussion threads and user interactions.

Instructions

Accéder aux commentaires d'une soumission

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
submission_idYesL'ID de la soumission
limitNoNombre de commentaires à récupérer

Implementation Reference

  • The main tool handler function that fetches comments for a submission using the Reddit client, formats them, and returns formatted content blocks.
    export async function getCommentsBySubmission(params: {
      submission_id: string;
      limit?: number;
    }) {
      const { submission_id, limit = 20 } = params;
      const client = getRedditClient();
    
      if (!client) {
        throw new McpError(
          ErrorCode.InternalError,
          "Reddit client not initialized"
        );
      }
    
      try {
        console.log(`[Tool] Getting comments for submission ${submission_id}`);
        const comments = await client.getCommentsBySubmission(submission_id, limit);
        const formattedComments = comments.map(formatCommentInfo);
    
        const commentSummaries = formattedComments
          .map(
            (comment, index) => `
    ### ${index + 1}. u/${comment.author}
    - Score: ${comment.stats.score}
    - Posté: ${comment.metadata.posted}
    - Contenu: ${comment.content.substring(0, 200)}${comment.content.length > 200 ? "..." : ""}
        `
          )
          .join("\n");
    
        return {
          content: [
            {
              type: "text",
              text: `
    # Commentaires pour la soumission ${submission_id}
    
    ${commentSummaries}
              `,
            },
          ],
        };
      } catch (error) {
        console.error(`[Error] Error getting comments by submission: ${error}`);
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to fetch comments: ${error}`
        );
      }
  • Input schema definition for the get_comments_by_submission tool, specifying submission_id as required and limit as optional.
    inputSchema: {
      type: "object",
      properties: {
        submission_id: {
          type: "string",
          description: "L'ID de la soumission",
        },
        limit: {
          type: "integer",
          description: "Nombre de commentaires à récupérer",
          default: 20,
        },
      },
      required: ["submission_id"],
    },
  • src/index.ts:478-481 (registration)
    Tool dispatch/registration in the switch statement for handling CallToolRequest.
    case "get_comments_by_submission":
      return await tools.getCommentsBySubmission(
        toolParams as { submission_id: string; limit?: number }
      );
  • src/index.ts:245-262 (registration)
    Tool registration in the ListTools response, including name, description, and schema.
      name: "get_comments_by_submission",
      description: "Accéder aux commentaires d'une soumission",
      inputSchema: {
        type: "object",
        properties: {
          submission_id: {
            type: "string",
            description: "L'ID de la soumission",
          },
          limit: {
            type: "integer",
            description: "Nombre de commentaires à récupérer",
            default: 20,
          },
        },
        required: ["submission_id"],
      },
    },
  • Underlying RedditClient method that performs the API call to fetch comments by submission ID.
    async getCommentsBySubmission(submissionId: string, limit: number = 20): Promise<RedditComment[]> {
      await this.authenticate();
      try {
        const response = await this.api.get(`/comments/${submissionId}.json`, {
          params: { limit }
        });
    
        if (!response.data || response.data.length < 2) {
          throw new Error(`Submission with ID ${submissionId} not found or has no comments`);
        }
    
        const comments = response.data[1].data.children;
        return comments.map((child: any) => {
          const comment = child.data;
          return {
            id: comment.id,
            author: comment.author,
            body: comment.body,
            score: comment.score,
            controversiality: comment.controversiality,
            subreddit: comment.subreddit,
            submissionTitle: response.data[0].data.children[0].data.title,
            createdUtc: comment.created_utc,
            edited: !!comment.edited,
            isSubmitter: comment.is_submitter,
            permalink: comment.permalink,
          };
        });
      } catch (error) {
        console.error(`[Error] Failed to get comments for submission ${submissionId}:`, error);
        throw new Error(`Failed to get comments for submission ${submissionId}`);
      }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Accéder aux' implies a read operation, it doesn't specify whether this requires authentication, has rate limits, returns paginated results, or what format the comments come in. For a tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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 a single, efficient French phrase that communicates the core purpose without any wasted words. It's appropriately sized for a simple retrieval tool and gets straight to the point with no unnecessary elaboration.

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?

For a tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (comment objects, just text, metadata?), whether results are paginated, or any error conditions. Given the lack of structured information elsewhere, the description should provide more context about the operation's behavior and results.

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 description doesn't add any parameter information beyond what's already in the schema, which has 100% coverage. The schema fully documents both parameters (submission_id and limit with default), so the baseline score of 3 is appropriate since the schema does all the parameter documentation work.

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 verb ('Accéder aux' - access) and resource ('commentaires d'une soumission' - comments of a submission), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_comment' or 'get_user_comments', which could retrieve similar data through different mechanisms.

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?

The description provides no guidance on when to use this tool versus alternatives like 'get_comment' or 'get_user_comments'. There's no mention of prerequisites, context requirements, or comparison with sibling tools that might retrieve similar data through different parameters or scopes.

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