rednote_search_notes
Search Xiaohongshu (Little Red Book) notes by keyword to find relevant content, videos, or all types with customizable sorting and result limits.
Instructions
搜索小红书笔记
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keyword | Yes | 搜索关键词 | |
| type | No | 内容类型 | all |
| sort | No | 排序方式 | relevant |
| limit | No | 返回数量限制 |
Implementation Reference
- src/tools/search.ts:12-43 (handler)The primary handler for the rednote_search_notes MCP tool. It processes parameters, logs the action, calls the RedNoteApi to search notes, and formats the response.async searchNotes(params: any) { try { validateSearchParams(params); const searchParams = { keyword: params.keyword, type: params.type || 'all', sort: params.sort || 'relevant', limit: params.limit || 20 }; logger.info('Executing search notes tool', { params: searchParams }); const result = await this.api.searchNotes(searchParams); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { logger.error('Error in searchNotes tool:', error); return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}` }], isError: true }; } }
- src/types/mcp.ts:16-48 (schema)Input schema defining parameters (keyword required, type/sort/limit optional) and validation rules for the tool.rednote_search_notes: { name: 'rednote_search_notes', description: '搜索小红书笔记', inputSchema: { type: 'object', properties: { keyword: { type: 'string', description: '搜索关键词' }, type: { type: 'string', enum: ['note', 'video', 'all'], description: '内容类型', default: 'all' }, sort: { type: 'string', enum: ['latest', 'popular', 'relevant'], description: '排序方式', default: 'relevant' }, limit: { type: 'number', description: '返回数量限制', default: 20, minimum: 1, maximum: 100 } }, required: ['keyword'] } },
- src/server.ts:57-59 (registration)Tool registration in the MCP server's CallToolRequest handler switch statement, routing calls to the SearchTools.searchNotes method.switch (name) { case 'rednote_search_notes': return await this.searchTools.searchNotes(params);
- src/utils/validators.ts:33-48 (helper)Helper function specifically for validating search notes parameters against the schema rules.export function validateSearchParams(params: any): void { validateNotEmpty(params.keyword, 'keyword'); validateString(params.keyword, 'keyword'); if (params.type) { validateEnum(params.type, 'type', ['note', 'video', 'all']); } if (params.sort) { validateEnum(params.sort, 'sort', ['latest', 'popular', 'relevant']); } if (params.limit) { validateNumber(params.limit, 'limit', 1, 100); } }
- src/api/rednote.ts:23-39 (helper)API layer implementation of searchNotes (currently using mock data generation). Called by the tool handler.async searchNotes(params: SearchParams): Promise<SearchResult> { logger.info('Searching notes', { params }); try { const mockResult: SearchResult = { notes: this.generateMockNotes(params.limit || 20), hasMore: true, nextCursor: 'mock_cursor_' + Date.now(), total: 1000 }; return mockResult; } catch (error) { logger.error('Error searching notes:', error); throw new Error(`Failed to search notes: ${error}`); } }