get_user_info
Retrieve profile data for a Reddit user, including account details, activity statistics, and posting history.
Instructions
Get information about a Reddit user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | Reddit username (without u/ prefix) |
Implementation Reference
- src/reddit-client.ts:155-158 (handler)Core handler function that makes the Reddit API request to fetch user information and maps the response to a RedditUser object.async getUserInfo(username: string): Promise<RedditUser> { const data = await this.makeRequest(`/user/${username}/about`); return this.mapUser(data.data); }
- src/index.ts:57-59 (schema)Zod schema for validating the input parameters (username) of the get_user_info tool.const GetUserInfoSchema = z.object({ username: z.string().min(1, "Username is required"), });
- src/index.ts:164-177 (registration)Tool registration in the listTools response, defining name, description, and input schema.{ name: 'get_user_info', description: 'Get information about a Reddit user', inputSchema: { type: 'object', properties: { username: { type: 'string', description: 'Reddit username (without u/ prefix)', }, }, required: ['username'], }, },
- src/index.ts:348-359 (handler)MCP CallToolRequest handler case that parses arguments, calls the RedditClient method, and formats the response.case 'get_user_info': { const args = GetUserInfoSchema.parse(request.params.arguments); const user = await redditClient.getUserInfo(args.username); return { content: [ { type: 'text', text: JSON.stringify(user, null, 2), }, ], }; }
- src/reddit-client.ts:245-255 (helper)Helper function to map raw Reddit API user data to the standardized RedditUser interface.private mapUser(data: any): RedditUser { return { name: data.name, id: data.id, created_utc: data.created_utc, comment_karma: data.comment_karma, link_karma: data.link_karma, is_verified: data.is_verified, has_verified_email: data.has_verified_email, }; }