rednote_get_user_notes
Retrieve user notes from Xiaohongshu (Little Red Book) by specifying a user ID, with options for pagination and result limits to streamline data extraction.
Instructions
获取用户笔记
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cursor | No | 分页游标 | |
| limit | No | 数量限制 | |
| user_id | Yes | 用户ID |
Implementation Reference
- src/tools/content.ts:39-76 (handler)The tool handler function that validates parameters, calls the RedNoteApi.getUserNotes, and returns formatted response or error.async getUserNotes(params: any) { try { validateNotEmpty(params.user_id, 'user_id'); validateString(params.user_id, 'user_id'); if (params.limit) { validateNumber(params.limit, 'limit', 1, 100); } logger.info('Executing get user notes tool', { userId: params.user_id, limit: params.limit, cursor: params.cursor }); const result = await this.api.getUserNotes( params.user_id, params.limit || 20, params.cursor ); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { logger.error('Error in getUserNotes tool:', error); return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}` }], isError: true }; } }
- src/types/mcp.ts:82-106 (schema)Input schema definition for the rednote_get_user_notes tool in TOOL_DEFINITIONS.rednote_get_user_notes: { name: 'rednote_get_user_notes', description: '获取用户笔记', inputSchema: { type: 'object', properties: { user_id: { type: 'string', description: '用户ID' }, limit: { type: 'number', description: '数量限制', default: 20, minimum: 1, maximum: 100 }, cursor: { type: 'string', description: '分页游标' } }, required: ['user_id'] } },
- src/server.ts:64-65 (registration)Registration in the switch statement dispatching tool calls to the appropriate handler.case 'rednote_get_user_notes': return await this.contentTools.getUserNotes(params);
- src/api/rednote.ts:65-80 (helper)Helper function in RedNoteApi class that implements the actual API logic (mocked) for getting user notes.async getUserNotes(userId: string, limit: number = 20, cursor?: string): Promise<SearchResult> { logger.info('Getting user notes', { userId, limit, cursor }); try { const mockResult: SearchResult = { notes: this.generateMockNotes(limit), hasMore: true, nextCursor: cursor ? cursor + '_next' : 'user_cursor_' + Date.now() }; return mockResult; } catch (error) { logger.error('Error getting user notes:', error); throw new Error(`Failed to get user notes for ${userId}: ${error}`); } }