Skip to main content
Glama
jordanburke

reddit-mcp-server

get_user_comments

Retrieve Reddit comments from a specific user with options to sort by new, hot, top, or controversial and filter by time period.

Instructions

Get comments made by a specific user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of comments to return
sortNoSort order: new, hot, top, controversialnew
time_filterNoTime filter for top/controversial: hour, day, week, month, year, allall
usernameYesThe username to get comments for

Implementation Reference

  • src/index.ts:226-275 (registration)
    Tool registration for 'get_user_comments' including name, description, input schema, and the full handler implementation.
    server.addTool({
      name: "get_user_comments",
      description: "Get recent comments by a Reddit user with sorting and filtering options",
      parameters: z.object({
        username: z.string().describe("The Reddit username (without u/ prefix)"),
        sort: z.enum(["new", "hot", "top"]).default("new").describe("Sort order for comments"),
        time_filter: z
          .enum(["hour", "day", "week", "month", "year", "all"])
          .default("all")
          .describe("Time filter for top comments"),
        limit: z.number().min(1).max(100).default(10).describe("Number of comments to retrieve"),
      }),
      execute: async (args) => {
        const client = getRedditClient()
        if (!client) {
          throw new Error("Reddit client not initialized")
        }
    
        const comments = await client.getUserComments(args.username, {
          sort: args.sort,
          timeFilter: args.time_filter,
          limit: args.limit,
        })
    
        if (comments.length === 0) {
          return `No comments found for u/${args.username} with the specified filters.`
        }
    
        const commentSummaries = comments
          .map((comment, index) => {
            const truncatedBody = comment.body.length > 300 ? comment.body.substring(0, 300) + "..." : comment.body
    
            const flags = [...(comment.edited ? ["*(edited)*"] : []), ...(comment.isSubmitter ? ["**OP**"] : [])]
    
            return `### ${index + 1}. Comment ${flags.join(" ")}
    In r/${comment.subreddit} on "${comment.submissionTitle}"
    
    > ${truncatedBody}
    
    - Score: ${comment.score.toLocaleString()}
    - Posted: ${new Date(comment.createdUtc * 1000).toLocaleString()}
    - Link: https://reddit.com${comment.permalink}`
          })
          .join("\n\n")
    
        return `# Comments by u/${args.username} (${args.sort} - ${args.time_filter})
    
    ${commentSummaries}`
      },
    })
  • Zod schema defining input parameters for the get_user_comments tool.
    parameters: z.object({
      username: z.string().describe("The Reddit username (without u/ prefix)"),
      sort: z.enum(["new", "hot", "top"]).default("new").describe("Sort order for comments"),
      time_filter: z
        .enum(["hour", "day", "week", "month", "year", "all"])
        .default("all")
        .describe("Time filter for top comments"),
      limit: z.number().min(1).max(100).default(10).describe("Number of comments to retrieve"),
    }),
  • The execute handler function that implements the core logic: fetches comments via RedditClient, formats them, and returns a markdown summary.
      execute: async (args) => {
        const client = getRedditClient()
        if (!client) {
          throw new Error("Reddit client not initialized")
        }
    
        const comments = await client.getUserComments(args.username, {
          sort: args.sort,
          timeFilter: args.time_filter,
          limit: args.limit,
        })
    
        if (comments.length === 0) {
          return `No comments found for u/${args.username} with the specified filters.`
        }
    
        const commentSummaries = comments
          .map((comment, index) => {
            const truncatedBody = comment.body.length > 300 ? comment.body.substring(0, 300) + "..." : comment.body
    
            const flags = [...(comment.edited ? ["*(edited)*"] : []), ...(comment.isSubmitter ? ["**OP**"] : [])]
    
            return `### ${index + 1}. Comment ${flags.join(" ")}
    In r/${comment.subreddit} on "${comment.submissionTitle}"
    
    > ${truncatedBody}
    
    - Score: ${comment.score.toLocaleString()}
    - Posted: ${new Date(comment.createdUtc * 1000).toLocaleString()}
    - Link: https://reddit.com${comment.permalink}`
          })
          .join("\n\n")
    
        return `# Comments by u/${args.username} (${args.sort} - ${args.time_filter})
    
    ${commentSummaries}`
      },
  • Supporting method in RedditClient class that performs the actual API call to fetch user comments from Reddit.
    async getUserComments(
      username: string,
      options: {
        sort?: string
        timeFilter?: string
        limit?: number
      } = {},
    ): Promise<RedditComment[]> {
      await this.authenticate()
      try {
        const { sort = "new", timeFilter = "all", limit = 25 } = options
        const params = new URLSearchParams({
          sort,
          t: timeFilter,
          limit: limit.toString(),
        })
    
        const response = await this.makeRequest(`/user/${username}/comments.json?${params}`)
        if (!response.ok) {
          throw new Error(`HTTP ${response.status}`)
        }
    
        const json = (await response.json()) as { data: { children: any[] } }
    
        return json.data.children
          .filter((child: any) => child.kind === "t1")
          .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 || "",
              createdUtc: comment.created_utc,
              edited: !!comment.edited,
              isSubmitter: comment.is_submitter,
              permalink: comment.permalink,
            }
          })
      } catch {
        throw new Error(`Failed to get comments for user ${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 the action ('Get') but doesn't cover critical traits like whether this is a read-only operation, potential rate limits, authentication needs, or what the return format looks like (e.g., list of comments with metadata). This leaves significant gaps for an agent to understand 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 a single, efficient sentence that directly states the tool's purpose without any fluff or redundancy. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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 complexity of a tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain the return values, error conditions, or behavioral nuances, leaving the agent with insufficient context to use the tool effectively beyond basic parameter input.

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, clearly documenting all 4 parameters (username, limit, sort, time_filter) with defaults, enums, and constraints. The description adds no additional meaning beyond the schema, so it meets the baseline of 3 for adequate coverage without extra value.

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 ('Get') and resource ('comments made by a specific user'), making the purpose unambiguous. However, it doesn't differentiate from sibling tools like 'get_post_comments' or 'get_user_posts', which also retrieve comments or user content, so it misses full sibling distinction.

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_user_posts' or 'get_post_comments'. It lacks context on prerequisites, such as needing a valid username, and doesn't mention any exclusions or specific use cases.

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

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