RedNote MCP

repository·main·Indexed 22 days ago

https://github.com/ifuryst/rednote-mcp

A Model Context Protocol (MCP) server that enables AI agents to interact with Xiaohongshu (RedNote). It provides capabilities for keyword-based note searching, retrieving full note content and comments via URLs, and managing authentication through session cookie persistence using Playwright.

Tokens
4.3K
Snippets
23
Records
27
Agent score
75%

What's inside rednote-mcp

  1. RedNote MCP Features and Capabilities

    main

    RedNote MCP provides the following capabilities for interacting with Xiaohongshu (RedNote):

    • Session Management: Automatic login and cookie management.
    • Search: Search through notes using specific keywords.
    • Content Retrieval: View note content using direct URLs.
    • CLI Tools: Access various command-line utilities for interaction.

    Note: Accessing comment sections via URLs is a planned feature.

  2. Debug RedNote MCP using MCP Inspector

    main

    Developers can use the MCP Inspector to verify the server's behavior and inspect requests/responses through an interactive interface.

    npx @modelcontextprotocol/inspector npx rednote-mcp --stdio
  3. Set up your RedNote account and cookies

    main

    RedNote MCP requires an active login session to interact with Xiaohongshu. The init command automates the login process using a browser.

    Initialization Process

    Run the following command:

    rednote-mcp init

    (If running from source, use npm run dev -- init)

    1. A browser will open automatically to the Xiaohongshu login page.
    2. Perform your standard login.
    3. Upon successful login, your session information is automatically saved to ~/.mcp/rednote/cookies.json.

    Note: Keep this cookie file secure as it contains your login credentials. If your session expires, simply run the init command again.

  4. Build RedNote MCP from source

    main

    If you prefer to build the project manually, follow these steps:

    1. Clone the repository:
    git clone https://github.com/ifuryst/rednote-mcp.git
    cd rednote-mcp
    1. Install dependencies:
    npm install
    1. (Optional) Install globally for CLI access:
    npm install -g .
    1. Or run the initialization directly from the source directory:
    npm run dev -- init
    git clone https://github.com/ifuryst/rednote-mcp.git
    cd rednote-mcp
    npm install
    npm run dev -- init
  5. Initialize login and manage cookies

    main

    Before using the service, you must perform an initial login to authenticate. This process opens a browser window where you manually complete the Xiaohongshu (RedNote) login. Once successful, the session cookies are automatically saved to ~/.mcp/rednote/cookies.json for persistent authentication.

    # If installed globally
    rednote-mcp init
    
    # If running from source
    npm run dev -- init
  6. Configure RedNote MCP in Cursor

    main

    To use RedNote MCP as an MCP server within the Cursor editor, add the server configuration to your settings.json file. You can use either the global command or npx.

    Important: You must include the --stdio flag to enable communication with Cursor.

    Configuration via Global Command

    {
      "mcpServers": {
        "RedNote MCP": {
          "command": "rednote-mcp",
          "args": [
            "--stdio"
          ]
        }
      }
    }

    Configuration via npx

    {
      "mcpServers": {
        "RedNote MCP": {
          "command": "npx",
          "args": [
            "rednote-mcp",
            "--stdio"
          ]
        }
      }
    }
    {
      "mcpServers": {
        "RedNote MCP": {
          "command": "rednote-mcp",
          "args": ["--stdio"]
        }
      }
    }
  7. Install RedNote MCP via NPM

    main

    The quickest way to install RedNote MCP is via a global NPM installation. You must also ensure that playwright is installed on your system to handle browser automation.

    Prerequisites

    Install Playwright browsers:

    npx playwright install

    Installation Steps

    1. Install the package globally:
    npm install -g rednote-mcp
    1. Initialize your account to save login cookies:
    rednote-mcp init
    npm install -g rednote-mcp
    rednote-mcp init
  8. Install RedNote MCP from source

    main

    If you prefer to run from source, clone the repository, install dependencies, and you can either install it globally or run it using npm run dev.

    # Clone the project
    git clone https://github.com/ifuryst/rednote-mcp.git
    cd rednote-mcp
    
    # Install dependencies
    npm install
    
    # Option 1: Global install (recommended for CLI usage)
    npm install -g .
    
    # Option 2: Run directly (e.g., for initialization)
    npm run dev -- init
  9. Run RedNote MCP in stdio mode

    main

    To use RedNote as an MCP server (e.g., for integration with Claude Desktop or other MCP clients), run the executable with the --stdio flag. This enables the Model Context Protocol over standard input/output.

    rednote-mcp --stdio
  10. Debug RedNote MCP with MCP Inspector

    main

    If you need to inspect requests and responses or debug the server behavior, use the Model Context Protocol (MCP) Inspector.

    Run the following command to start the Inspector with RedNote MCP:

    npx @modelcontextprotocol/inspector npx rednote-mcp --stdio
  11. Configure the AuthManager cookie path

    main

    When instantiating AuthManager, you can provide a custom file path for storing session cookies. If no path is provided, the manager automatically creates the directory structure ~/.mcp/rednote/ and saves cookies to cookies.json within that directory.

    // Use a custom path for cookie storage
    const auth = new AuthManager('/path/to/your/custom_cookies.json');