get_user_info
Retrieve Reddit user profile information including account details, karma, and activity history by providing a username.
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)The core handler function that fetches user information from the Reddit API endpoint `/user/{username}/about` and maps the response data to a RedditUser object using the mapUser helper.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 entry in the MCP server's listTools handler, defining the tool's 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/reddit-client.ts:42-50 (schema)TypeScript interface defining the structure of the Reddit user information returned by the handler.export interface RedditUser { name: string; id: string; created_utc: number; comment_karma: number; link_karma: number; is_verified: boolean; has_verified_email: boolean; }
- src/reddit-client.ts:245-255 (helper)Helper function that maps raw Reddit API user data to the structured 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, }; }