Skip to main content
Glama

get_user_info

Retrieve Reddit user profile information including karma, account age, and post history by providing a username.

Instructions

Get information about a Reddit user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username of the Reddit user to get info for

Implementation Reference

  • Handler function that executes the get_user_info tool: fetches Reddit user data using the client, formats it with formatUserInfo, and returns formatted markdown string.
    execute: async (args) => { const client = getRedditClient() if (!client) { throw new Error("Reddit client not initialized") } const user = await client.getUser(args.username) const formattedUser = formatUserInfo(user) return `# User Information: u/${formattedUser.username} ## Profile Overview - Username: u/${formattedUser.username} - Karma: - Comment Karma: ${formattedUser.karma.commentKarma.toLocaleString()} - Post Karma: ${formattedUser.karma.postKarma.toLocaleString()} - Total Karma: ${formattedUser.karma.totalKarma.toLocaleString()} - Account Status: ${formattedUser.accountStatus.join(", ")} - Account Created: ${formattedUser.accountCreated} - Profile URL: ${formattedUser.profileUrl} ## Activity Analysis - ${formattedUser.activityAnalysis.replace(/\n - /g, "\n- ")} ## Recommendations - ${formattedUser.recommendations.replace(/\n {2}- /g, "\n- ")}` },
  • Zod input schema defining the 'username' parameter for the get_user_info tool.
    parameters: z.object({ username: z.string().describe("The Reddit username (without u/ prefix)"), }),
  • src/index.ts:144-177 (registration)
    Registration of the get_user_info tool with FastMCP server.addTool call.
    server.addTool({ name: "get_user_info", description: "Get detailed information about a Reddit user including karma, account status, and activity analysis", parameters: z.object({ username: z.string().describe("The Reddit username (without u/ prefix)"), }), execute: async (args) => { const client = getRedditClient() if (!client) { throw new Error("Reddit client not initialized") } const user = await client.getUser(args.username) const formattedUser = formatUserInfo(user) return `# User Information: u/${formattedUser.username} ## Profile Overview - Username: u/${formattedUser.username} - Karma: - Comment Karma: ${formattedUser.karma.commentKarma.toLocaleString()} - Post Karma: ${formattedUser.karma.postKarma.toLocaleString()} - Total Karma: ${formattedUser.karma.totalKarma.toLocaleString()} - Account Status: ${formattedUser.accountStatus.join(", ")} - Account Created: ${formattedUser.accountCreated} - Profile URL: ${formattedUser.profileUrl} ## Activity Analysis - ${formattedUser.activityAnalysis.replace(/\n - /g, "\n- ")} ## Recommendations - ${formattedUser.recommendations.replace(/\n {2}- /g, "\n- ")}` }, })
  • Helper function formatUserInfo that structures and analyzes Reddit user data, used in the get_user_info handler.
    export function formatUserInfo(user: RedditUser): FormattedUserInfo { const status: string[] = [] if (user.isMod) status.push("Moderator") if (user.isGold) status.push("Reddit Gold Member") if (user.isEmployee) status.push("Reddit Employee") const accountAgeDays = (Date.now() / 1000 - user.createdUtc) / (24 * 3600) // age in days const karmaRatio = user.commentKarma / (user.linkKarma || 1) return { username: user.name, karma: { commentKarma: user.commentKarma, postKarma: user.linkKarma, totalKarma: user.totalKarma, }, accountStatus: status.length ? status : ["Regular User"], accountCreated: formatTimestamp(user.createdUtc), profileUrl: user.profileUrl, activityAnalysis: analyzeUserActivity(karmaRatio, user.isMod, accountAgeDays), recommendations: getUserRecommendations(karmaRatio, user.isMod, accountAgeDays), } }
  • TypeScript interface defining the formatted user info structure returned by formatUserInfo.
    export interface FormattedUserInfo { username: string karma: { commentKarma: number postKarma: number totalKarma: number } accountStatus: string[] accountCreated: string profileUrl: string activityAnalysis: string recommendations: string }

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