rednote_get_user_info
Retrieve user profiles and information from Xiaohongshu (Little Red Book) by providing a user ID or username.
Instructions
获取用户信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes | 用户ID或用户名 |
Implementation Reference
- src/tools/user.ts:12-37 (handler)The handler function for the 'rednote_get_user_info' tool. Validates input parameters, calls the RedNote API to fetch user information, formats the response as MCP content, and handles errors.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/server.ts:70-71 (registration)Registers the 'rednote_get_user_info' tool by mapping it to this.userTools.getUserInfo in the MCP server request handler switch statement.case 'rednote_get_user_info': return await this.userTools.getUserInfo(params);
- src/types/mcp.ts:68-81 (schema)Defines the tool schema including name, description, and input schema requiring 'user_id' parameter.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:32-36 (registration)Instantiates the UserTools class instance used for handling user-related tools including getUserInfo.this.userTools = new UserTools(); this.analysisTools = new AnalysisTools(); this.setupHandlers(); }
- src/api/rednote.ts:53-63 (helper)Core API method called by the tool handler to retrieve (mock) user information from RedNote.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}`); } }