rednote_get_user_info
Retrieve user information from Xiaohongshu (Little Red Book) by providing a user ID or username using this tool, enabling access to profile details and insights.
Instructions
获取用户信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes | 用户ID或用户名 |
Implementation Reference
- src/types/mcp.ts:68-81 (schema)Input schema definition for the 'rednote_get_user_info' tool.rednote_get_user_info: { name: 'rednote_get_user_info', description: '获取用户信息', inputSchema: { type: 'object', properties: { user_id: { type: 'string', description: '用户ID或用户名' } }, required: ['user_id'] } },
- src/server.ts:70-71 (registration)Registration/dispatch of the tool handler in the server's CallToolRequest handler switch statement.case 'rednote_get_user_info': return await this.userTools.getUserInfo(params);
- src/tools/user.ts:12-37 (handler)Main handler function for executing the 'rednote_get_user_info' tool logic, including validation and API call.async getUserInfo(params: any) { try { validateNotEmpty(params.user_id, 'user_id'); validateString(params.user_id, 'user_id'); logger.info('Executing get user info tool', { userId: params.user_id }); const result = await this.api.getUserInfo(params.user_id); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { logger.error('Error in getUserInfo tool:', error); return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}` }], isError: true }; } }
- src/api/rednote.ts:53-63 (helper)Helper API method that provides the core user info retrieval logic (mocked).async getUserInfo(userId: string): Promise<RedNoteUser> { logger.info('Getting user info', { userId }); try { const mockUser = this.generateMockUser(userId); return mockUser; } catch (error) { logger.error('Error getting user info:', error); throw new Error(`Failed to get user info for ${userId}: ${error}`); } }
- src/api/rednote.ts:146-160 (helper)Private helper function that generates mock user data used by the API method.private generateMockUser(id: string): RedNoteUser { const usernames = ['小红薯', '美食达人', '旅行者', '时尚博主', '生活家']; return { id, username: 'user_' + Math.random().toString(36).substring(7), nickname: usernames[Math.floor(Math.random() * usernames.length)] + Math.floor(Math.random() * 1000), avatar: 'https://example.com/avatar.jpg', description: '分享生活中的美好时光 ✨', followerCount: Math.floor(Math.random() * 10000), followingCount: Math.floor(Math.random() * 1000), noteCount: Math.floor(Math.random() * 500), likeCount: Math.floor(Math.random() * 50000), verified: Math.random() > 0.8 }; }