get_user_profile
Retrieve detailed Reddit user profile information, including karma, account age, gold status, moderator status, and profile link, by providing the username without the 'u/' prefix.
Instructions
π€ Get Reddit user profile information π― What it does: Fetches detailed profile info for any Reddit user π Required: username (Reddit username without u/ prefix) π‘ Examples: β’ Get profile: {"username": "spez"} β’ Check user: {"username": "AwkwardTension4482"} β’ View profile: {"username": "gallowboob"} π Output: User info with karma, account age, gold status, moderator status, and profile link
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | Reddit username to get profile information |
Implementation Reference
- src/index.ts:538-556 (handler)MCP tool handler for get_user_profile: extracts username from params, calls redditAPI.getUserProfile, handles errors, formats user data with formatUserProfile, and returns standardized MCP success response.createToolHandler(async (params: z.infer<typeof SimpleUserProfileSchema>) => { const { username } = params; const result = await redditAPI.getUserProfile(username); if (!result.success) { return createErrorResponse("Error getting user profile", result.error); } const data = result.data; if (!data || !data.data) { return createErrorResponse("User profile not found"); } const user = data.data; const userInfo = formatUserProfile(user); return createSuccessResponse(userInfo); })
- src/index.ts:527-557 (registration)Registers the get_user_profile tool with the MCP server, providing name, description, input schema (SimpleUserProfileSchema), and handler function.server.tool( "get_user_profile", "π€ Get Reddit user profile information\n" + "π― What it does: Fetches detailed profile info for any Reddit user\n" + "π Required: username (Reddit username without u/ prefix)\n" + "π‘ Examples:\n" + " β’ Get profile: {\"username\": \"spez\"}\n" + " β’ Check user: {\"username\": \"AwkwardTension4482\"}\n" + " β’ View profile: {\"username\": \"gallowboob\"}\n" + "π Output: User info with karma, account age, gold status, moderator status, and profile link", SimpleUserProfileSchema.shape, createToolHandler(async (params: z.infer<typeof SimpleUserProfileSchema>) => { const { username } = params; const result = await redditAPI.getUserProfile(username); if (!result.success) { return createErrorResponse("Error getting user profile", result.error); } const data = result.data; if (!data || !data.data) { return createErrorResponse("User profile not found"); } const user = data.data; const userInfo = formatUserProfile(user); return createSuccessResponse(userInfo); }) );
- src/types/index.ts:108-110 (schema)Zod schema for input validation of get_user_profile tool: requires 'username' string parameter.export const SimpleUserProfileSchema = z.object({ username: z.string().describe("Reddit username to get profile information") });
- src/services/reddit-api.ts:377-381 (helper)Helper method in RedditAPIService that makes the actual API request to fetch user profile data from Reddit's /user/{username}/about.json endpoint.async getUserProfile(username: string): Promise<ApiCallResult> { return this.makeRequest<{ data: RedditUser }>( `/user/${username}/about.json`, ); }
- src/index.ts:198-217 (helper)Helper function to format RedditUser data into a human-readable markdown string with emojis, used in the tool handler.function formatUserProfile(user: RedditUser): string { const name = user.name || 'Unknown'; const linkKarma = user.link_karma || 0; const commentKarma = user.comment_karma || 0; const createdDate = user.created_utc ? new Date(user.created_utc * 1000).toLocaleDateString() : 'Unknown'; const isGold = user.is_gold || false; const isMod = user.is_mod || false; const hasVerifiedEmail = user.has_verified_email || false; let result = `π€ **u/${name}**\n`; result += `π Link Karma: ${linkKarma.toLocaleString()}\n`; result += `π¬ Comment Karma: ${commentKarma.toLocaleString()}\n`; result += `π Created: ${createdDate}\n`; result += `π₯ Gold: ${isGold ? 'Yes' : 'No'}\n`; result += `π‘οΈ Moderator: ${isMod ? 'Yes' : 'No'}\n`; result += `β Verified Email: ${hasVerifiedEmail ? 'Yes' : 'No'}\n`; result += `π Profile: https://reddit.com/user/${name}\n`; return result; }