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
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | The username of the Reddit user to get info for |
Implementation Reference
- src/index.ts:150-176 (handler)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- ")}` },
- src/index.ts:147-149 (schema)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- ")}` }, })
- src/utils/formatters.ts:186-208 (helper)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), } }
- src/types.ts:70-82 (schema)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 }