Content
# Xiaohongshu MCP Service
[](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 features such as searching notes, retrieving content, viewing comments, and posting comments.
## Features
- [x] Uses JS reverse engineering to extract x-s and x-t, directly requests HTTP interfaces without the need for bulky playwright
- [x] Search notes
- [x] Retrieve note content
- [x] Get note comments
- [x] Post comments

## Quick Start
### Method 1: Using uvx (Recommended)
#### 1. Environment Requirements
- Python 3.12+
- uv (Installation method: `pip install uv`)
#### 2. Obtain Xiaohongshu Cookie
[Open the web version of Xiaohongshu](https://www.xiaohongshu.com/explore)
After logging in, obtain the cookie and configure it in the XHS_COOKIE environment variable for 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 the 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. Obtain Xiaohongshu Cookie
[Open the web version of Xiaohongshu](https://www.xiaohongshu.com/explore)
After logging in, obtain the cookie and configure it in the XHS_COOKIE environment variable for 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 recommended notes from the homepage
- `search_notes(keywords)` - Search notes based on keywords
- `get_note_content(url)` - Retrieve 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 Example
### Using in Claude Desktop
1. Open the settings in Claude Desktop
2. Find the MCP server configuration
3. Add the above JSON configuration
4. Restart Claude Desktop
5. You can now use Xiaohongshu-related features in your conversations
### Frequently Asked Questions
**Q: How do I obtain 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 say the cookie is invalid?**
A: Xiaohongshu's cookies have a validity period and need to be updated regularly. Simply log in to the web version again to obtain a new cookie.
**Q: The uvx command cannot be found?**
A: Please install uv first: `pip install uv`, and then ensure that the PATH environment variable includes the installation path of uv.
## Disclaimer
This project is for educational and communication purposes only and is prohibited for other uses. Any use for commercial profit is not allowed, and the risk is borne by the user.
Connection Info
You Might Also Like

Continue
Continue is an open-source project for seamless server management.

repomix
Repomix packages your codebase into AI-friendly formats for seamless integration.

Mastra
Mastra is a TypeScript framework for building AI agents and assistants.
open-multi-agent-canvas
Open Multi-Agent Canvas is an open-source chat interface for managing...
mcp-gsuite
MCP server for integrating Gmail and Calendar with multiple account support.
laravel
A Laravel SDK for building MCP servers with enterprise features and integrations.