Content
# RedNote MCP
[English](https://github.com/iFurySt/RedNote-MCP/blob/main/docs/README.en.md) | 简体中文
An implementation of the Model Context Protocol for accessing content on Xiaohongshu.
## Quick Start
### Global Installation via NPM
```bash
# Global installation
npm install -g rednote-mcp
# Initialize login
rednote-mcp init
```
### Installation from Source
```bash
# Clone the project
git clone https://github.com/ifuryst/rednote-mcp.git
cd rednote-mcp
# Install dependencies
npm install
# Global installation (optional, for convenient command line usage)
npm install -g .
# Initialize login
npm run dev -- init
```
## Features
- Authentication management (supports Cookie persistence)
- Keyword search for notes
- Access note content via URL
- Access comment content via URL
- Command line initialization tool
## Usage Instructions
### 1. Initialize Login
You need to perform login initialization the first time you use it:
```bash
rednote-mcp init
# Or if installed from source:
npm run dev -- init
```
After executing this command:
1. A browser window will automatically open
2. It will redirect to the Xiaohongshu login page
3. Please complete the login operation manually
4. Upon successful login, the Cookie will be automatically saved to the `cookies.json` file
### 2. Configure MCP Server in Cursor
Add the following configuration in the `settings.json` of Cursor:
```json
{
"mcpServers": {
"RedNote MCP": {
"command": "rednote-mcp",
"args": ["--stdio"]
}
}
}
```
Or use the npx method:
```json
{
"mcpServers": {
"RedNote MCP": {
"command": "npx",
"args": ["rednote-mcp", "--stdio"]
}
}
}
```
Configuration Explanation:
- `command`: Can be the `rednote-mcp` command after global installation, or use `npx` to run directly
- `args`: Must include the `--stdio` parameter to support communication with Cursor
## Development Guide
### Environment Requirements
- Node.js >= 16
- npm >= 7
### Development Process
```bash
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run dev
# Run tests
npm test
```
### Debugging with MCP Inspector
MCP Inspector is a tool for debugging the MCP server, helping developers inspect and validate the behavior of the MCP server. Start it with the following command:
```bash
npx @modelcontextprotocol/inspector npx rednote-mcp --stdio
```
This command will:
1. Start the MCP Inspector tool
2. Run the rednote-mcp service through the Inspector
3. Provide an interactive interface to inspect requests and responses
4. Assist in debugging and validating the implementation of the MCP protocol
## Configuration
Create a `.env` file in the root directory of the project and configure the following variables:
```
# Cookie storage path
COOKIE_STORAGE_PATH=./cookies.json
# MCP server configuration
PORT=3000
HOST=localhost
```
## Project Structure
```
rednote-mcp/
├── src/ # Source code directory
│ ├── auth/ # Authentication related
│ │ ├── authManager.ts
│ │ └── cookieManager.ts
│ ├── cli.ts # Command line interface
│ └── index.ts # Main entry point
├── docs/ # Documentation directory
│ └── README.en.md # English documentation
├── tests/ # Test directory
├── .env # Environment configuration
├── package.json # Project configuration
└── tsconfig.json # TypeScript configuration
```
## Notes
1. You must execute the `init` command for login the first time you use it
2. The Cookie file contains sensitive information, please do not disclose it
3. It is recommended to update the Cookie regularly to avoid expiration
4. Ensure that the Node.js environment is correctly installed
## Contribution Guidelines
1. Fork this repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## License
MIT License - See the [LICENSE](LICENSE) file for details.