Content
# Xiaohongshu MCP Server
[](https://smithery.ai/server/@jobsonlook/xhs-mcp)
[](https://badge.fury.io/py/jobson-xhs-mcp)
An MCP (Model Context Protocol) server for the Xiaohongshu API, supporting functions such as searching notes, getting content, viewing comments, and posting comments.
## Features
- [x] Use js to reverse engineer x-s, x-t, and directly request the http interface, without the need for cumbersome playwright
- [x] Search notes
- [x] Get note content
- [x] Get note comments
- [x] Post comments

## Quick Start
### Method 1: Use uvx (Recommended)
#### 1. Environment Requirements
- Python 3.12+
- uv (Installation: `pip install uv`)
#### 2. Get Xiaohongshu Cookie
[Open web Xiaohongshu](https://www.xiaohongshu.com/explore)
After logging in, get the cookie and configure it into the XHS_COOKIE environment variable in the next step.

#### 3. Configure MCP Server
Add the following configuration to your MCP client configuration file:
```json
{
"mcpServers": {
"xhs-mcp": {
"command": "uvx",
"args": [
"--from",
"jobson-xhs-mcp",
"xhs-mcp"
],
"env": {
"XHS_COOKIE": "your Xiaohongshu cookie"
}
}
}
}
```
#### 4. Test Run
```bash
# Set environment variable
export XHS_COOKIE="your Xiaohongshu cookie"
# Run test directly
uvx --from jobson-xhs-mcp xhs-mcp --help
```
### Method 2: Install from Source
#### 1. Environment Requirements
- node
- python 3.12
- uv (pip install uv)
#### 2. Clone and Install
```sh
git clone git@github.com:jobsonlook/xhs-mcp.git
cd xhs-mcp
uv sync
```
#### 3. Get Xiaohongshu Cookie
[Open web Xiaohongshu](https://www.xiaohongshu.com/explore)
After logging in, get the cookie and configure it into the XHS_COOKIE environment variable in the next step.

#### 4. Configure MCP Server
```json
{
"mcpServers": {
"xhs-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/to/xhs-mcp",
"run",
"xhs_mcp/__main__.py"
],
"env": {
"XHS_COOKIE": "your Xiaohongshu cookie"
}
}
}
}
```
## Available Tools
This MCP server provides the following tools:
- `check_cookie()` - Check if the cookie is invalid
- `home_feed()` - Get the recommended notes on the homepage
- `search_notes(keywords)` - Search notes by keywords
- `get_note_content(url)` - Get note content (requires a complete URL with xsec_token)
- `get_note_comments(url)` - Get note comments (requires a complete URL with xsec_token)
- `post_comment(comment, note_id)` - Post a comment to the specified note
## Usage Examples
### Use in Claude Desktop
1. Open Claude Desktop settings
2. Find the MCP server configuration
3. Add the above JSON configuration
4. Restart Claude Desktop
5. Now you can use Xiaohongshu related functions in the conversation
### Common Issues
**Q: How to get the Cookie?**
A: Log in to the web version of Xiaohongshu in your browser, open the developer tools, find any request in the Network tab, and copy the value of the Cookie header.
**Q: Why does it prompt that the cookie is invalid?**
A: Xiaohongshu's cookie has an expiration date and needs to be updated regularly. Log in to the web version again to get a new cookie.
**Q: uvx command not found?**
A: Please install uv first: `pip install uv`, and then make sure that the PATH environment variable contains the uv installation path.
## Disclaimer
This project is only for learning and communication purposes, and it is forbidden to use it for other purposes. Any commercial profit-making purposes must not be used, otherwise you will be responsible for the risks.
Connection Info
You Might Also Like
awesome-mcp-servers
A collection of MCP servers.
git
A Model Context Protocol server for Git automation and interaction.
Appwrite
Build like a team of hundreds
TrendRadar
TrendRadar: Your hotspot assistant for real news in just 30 seconds.
oh-my-opencode
Background agents · Curated agents like oracle, librarians, frontend...
chatbox
User-friendly Desktop Client App for AI Models/LLMs (GPT, Claude, Gemini, Ollama...)