Skip to main content
Glama

get_user_comments

Retrieve a Reddit user's comment history to analyze their activity and contributions across the platform.

Instructions

Obtenir l'historique des commentaires d'un utilisateur

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesLe nom d'utilisateur Reddit
sortNoMéthode de tri (new, top, hot)new
limitNoNombre de commentaires à récupérer

Implementation Reference

  • Main tool handler: fetches user comments from Reddit client, formats them into a structured text response with details like post, score, date, link, and truncated content.
    export async function getUserComments(params: { username: string; sort?: string; limit?: number }) {
      const { username, sort = "new", limit = 25 } = params;
      const client = getRedditClient();
    
      if (!client) {
        throw new McpError(
          ErrorCode.InternalError,
          "Reddit client not initialized"
        );
      }
    
      try {
        console.log(`[Tool] Getting comments for u/${username}`);
        const comments = await client.getUserComments(username, sort, limit);
    
        if (comments.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: `# Commentaires de u/${username}\n\nAucun commentaire trouvé pour cet utilisateur.`,
              },
            ],
          };
        }
    
        const commentsText = comments.map((comment, index) => {
          const postedDate = new Date(comment.createdUtc * 1000).toLocaleString('fr-FR');
          const scoreText = comment.score >= 0 ? `+${comment.score}` : `${comment.score}`;
          const controversialText = comment.controversiality > 0 ? ' (Controversé)' : '';
          return `
    ### ${index + 1}. Commentaire dans r/${comment.subreddit}
    - **Post**: ${comment.submissionTitle}
    - **Score**: ${scoreText}${controversialText}
    - **Posté**: ${postedDate}
    - **Lien**: ${comment.permalink}
    
    **Contenu**: ${comment.body.substring(0, 300)}${comment.body.length > 300 ? '...' : ''}
          `;
        }).join('\n');
    
        return {
          content: [
            {
              type: "text",
              text: `# Commentaires récents de u/${username}
    
    **Tri**: ${sort}
    **Nombre de commentaires**: ${comments.length}
    
    ${commentsText}`,
            },
          ],
        };
      } catch (error) {
        console.error(`[Error] Error getting user comments: ${error}`);
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to fetch user comments: ${error}`
        );
      }
    }
  • Input schema definition for the get_user_comments tool, specifying parameters: username (required), sort (enum: new/top/hot, default new), limit (default 25).
    {
      name: "get_user_comments",
      description: "Obtenir l'historique des commentaires d'un utilisateur",
      inputSchema: {
        type: "object",
        properties: {
          username: {
            type: "string",
            description: "Le nom d'utilisateur Reddit",
          },
          sort: {
            type: "string",
            description: "Méthode de tri (new, top, hot)",
            enum: ["new", "top", "hot"],
            default: "new",
          },
          limit: {
            type: "integer",
            description: "Nombre de commentaires à récupérer",
            default: 25,
          },
        },
        required: ["username"],
      },
    },
  • src/index.ts:508-511 (registration)
    Tool call dispatching: handles CallToolRequest for get_user_comments by invoking tools.getUserComments with typed parameters.
    case "get_user_comments":
      return await tools.getUserComments(
        toolParams as { username: string; sort?: string; limit?: number }
      );
  • RedditClient helper method: authenticates and fetches user's comments via Reddit API endpoint /user/{username}/comments.json, maps response to RedditComment objects.
    async getUserComments(username: string, sort: string = "new", limit: number = 25): Promise<RedditComment[]> {
      await this.authenticate();
      try {
        const response = await this.api.get(`/user/${username}/comments.json`, {
          params: {
            sort,
            limit,
          },
        });
    
        return response.data.data.children.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: comment.link_title || "Unknown Post",
            createdUtc: comment.created_utc,
            edited: !!comment.edited,
            isSubmitter: comment.is_submitter,
            permalink: `https://reddit.com${comment.permalink}`,
          };
        });
      } catch (error) {
        console.error(`[Error] Failed to get user comments for ${username}:`, error);
        throw new Error(`Failed to get user comments for ${username}`);
      }
    }
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. It states it retrieves comment history but doesn't mention whether this is a read-only operation, if there are rate limits, authentication requirements, pagination behavior, or what format the returned data takes. For a tool with 3 parameters and no output schema, this leaves significant behavioral gaps.

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 sentence in French that directly states the tool's purpose. There's no unnecessary verbiage or structural issues - it's appropriately concise and front-loaded with the essential information.

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 has 3 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns, how results are structured, or important behavioral aspects like whether this is a safe read operation. For a data retrieval tool in this context, more completeness is needed.

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 schema description coverage is 100%, so all parameters are documented in the schema itself. The description doesn't add any additional meaning about the parameters beyond what's already in the schema descriptions. The baseline score of 3 is appropriate when the schema does the heavy lifting.

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 'Obtenir l'historique des commentaires d'un utilisateur' clearly states the purpose: retrieving a user's comment history. It specifies the resource (user comments) and verb (obtain/retrieve), but doesn't explicitly differentiate from sibling tools like get_user_activity or get_user_posts, which might also retrieve user-related data.

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. It doesn't mention when to choose this over get_user_activity (which might include comments) or get_comments_by_submission, nor does it specify any prerequisites or exclusions for usage.

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