java-xiaohongshu
Java 实现的小红书 Model Context Protocol (MCP) 工具服务 为 AI Agent / MCP Client 提供标准化接口,实现: 登录、发图文、发视频、搜索、评论、推荐内容、用户主页 等核心功能
claude mcp add --transport stdio bzlrj-java-xiaohongshu-mcp docker run -i -v pw-browsers:/ms-playwright java-xhs-mcp:latest \ --env PLAYWRIGHT_BROWSERS_PATH="/ms-playwright"
How to use
This MCP server provides a Java-based Xiaohongshu automation service built on Spring Boot, Playwright Java, and the MCP protocol. It exposes standard MCP operations such as login, posting image-text content, video content, searching posts, fetching a home/recommendation feed, retrieving post details with interactions and comments, automated commenting, and accessing user profile data. The service can be integrated with AI agents and MCP clients for automated workflows, content publishing, and data collection. You can run it directly as a CLI Java app or deploy it via Docker for containerized usage. After starting, the MCP endpoint is exposed at /mcp and can be consumed by MCP clients using the standard MCP contract defined in the repository.
How to install
Prerequisites:
- Java 21 (or a compatible JDK)
- Maven for building the JAR (optional if using the prebuilt Docker image)
- Docker (for containerized deployment as shown in the README)
- Access to a web browser automation driver (Playwright) as required by the project
Option A – Build from source and run locally (CLI/JAR):
- Clone the repository
- Build the project
mvn clean package -DskipTests
- Run the CLI login tool (example)
java -cp target/app.jar -Dloader.main=com.lv.xhsmcp.login.LoginCli org.springframework.boot.loader.launch.PropertiesLauncher
Option B – Run via Docker (as described in the README):
- Build the Docker image
docker buildx build -t java-xhs-mcp:latest .
- Run the container (maps Playwright browsers and uses the image from the README)
docker run --rm -e PLAYWRIGHT_BROWSERS_PATH=/ms-playwright -v pw-browsers:/ms-playwright java-xhs-mcp:latest /bin/bash
- Access the MCP endpoint at http://127.0.0.1:8081/mcp
Notes:
- The project relies on valid login cookies and, for posting content, a valid xsec_token.
- The Docker deployment follows the guidance in the README and uses a named volume for Playwright browsers.
Additional notes
Tips and common considerations:
- Ensure you have valid Xiaohongshu cookies for login and the necessary xsec_token for posting actions.
- When running via Docker, you may need to adjust the port mapping if you customize the server port; the README uses 8081 by default.
- The Playwright browsers path is mounted to /ms-playwright; make sure the volume pw-browsers is available on your host.
- For MCP integration, you can point your MCP client at http://localhost:8081/mcp as shown in the integration example in the README.
- This is MIT-licensed; review the LICENSE for terms and compliance.
Related MCP Servers
mcp-for-beginners
This open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
sonarqube
SonarQube MCP Server
wanaku
Wanaku MCP Router
WigAI
Bitwig Controller Extension that provides an MCP Server for AI Agent control
SchemaCrawler-AI
Free database schema discovery and comprehension tool
vertx
A Vert.x MCP Server built on top of MCP Java SDK