Skip to main content
Glama
ethancod1ng

RedNote MCP Server

by ethancod1ng

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
NameRequiredDescriptionDefault
user_idYes用户ID或用户名

Implementation Reference

  • 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);
  • 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();
    }
  • 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}`);
      }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ethancod1ng/rednote-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server