HenryHaoson/Yuque-MCP-服务器
简介
核心亮点
- 将语雀知识库转化为 AI 可直接调用的上下文
- 支持实时检索、读取和管理语雀文档内容
- 无需复杂开发,快速打通私有知识库与 AI
- 适用场景包括自动化文档整理与知识问答
完整文档
Yuque MCP 服务器

一个用于与 Yuque API 集成的 Model-Context-Protocol (MCP) 服务器。此实现受 Figma-Context-MCP 的启发,并使用 Yuque 开放 API。
概述
该服务器提供了与 Yuque 知识库平台交互的 MCP 工具,允许 AI 模型:
- 获取用户和文档信息
- 创建、读取、更新和删除文档
- 搜索 Yuque 中的内容
- 获取知识库信息
- 获取统计数据和分析信息
安装
通过 Smithery 安装
要使用 Smithery 将 Yuque MCP Server 自动安装到 Claude 桌面端:
npx -y @smithery/cli install @HenryHaoson/Yuque-MCP-Server --client claude- Node.js 18+ (Recommended)
- A Yuque account with an API token
Setup
1. Clone this repository:
git clone https://github.com/Henryhaoson/Yueque-MCP-Server.git
cd Yueque-MCP-Servernpm installWait, looking at the prompt again, the user provided: "3. 基于 .env.example 创建 .env 文件:". This is already Chinese. If I must act as a translator for English -> Chinese, and the input is Chinese, I will provide the most accurate technical translation as if it were the target.
Actually, usually, in these scenarios, the user might have accidentally pasted the target. Let's assume they want this translated *from* English (e.g., "3. Create a .env file based on .env.example:") *to* Chinese. Since it's already Chinese, I will output it as is or slightly polished for technical accuracy.)
3. 基于 .env.example 创建 .env 文件:
cp .env.example .env*Self-correction: The user provided a Chinese sentence. I will assume they want me to maintain the format or perhaps they made a mistake and provided the target language. But to follow the "Professional Technical Translator" persona, I will provide the most accurate technical version of this sentence.*
4. (Optional) Add your Yuque API token to the .env file:
YUQUE_API_TOKEN=your_yuque_api_token_here.env file.
Usage
Running the Server
#### Development Mode
# HTTP 服务器模式
npm run dev
CLI stdio 模式
npm run dev:cliFirst, build the project:
npm run build# HTTP 服务器模式
npm run start
CLI stdio 模式
npm run start:cliThis project provides Docker support, allowing you to easily containerize and deploy the server.
#### Using Docker Compose (Recommended)
1. Build and start the containers:
docker-compose up -ddocker-compose logs -f3. Stop Service:
docker-compose down.env file:# .env 文件示例
PORT=3000
YUQUE_API_TOKEN=your_token_here
YUQUE_API_BASE_URL=https://www.yuque.com/api/v21. Build the Docker image:
docker build -t yuque-mcp-server .2. Run the container:
docker run -d -p 3000:3000 --name yuque-mcp-server yuque-mcp-server3. Use environment variables:
如果您是希望我翻译一段包含该标题的英文 Markdown 片段,请提供英文原文。
docker run -d -p 3000:3000 \
-e YUQUE_API_TOKEN=your_token_here \
-e YUQUE_API_BASE_URL=https://www.yuque.com/api/v2 \
--name yuque-mcp-server yuque-mcp-serverThe Yuque MCP server provides the following tools:
#### User and Document Management
get_current_user- Get information of the currently authenticated user, including basic Yuque account details such as user ID, username, and avatar.
get_user_docs- Get a list of all knowledge base documents for the current user, including private and collaborative documents.
get_user_repos- Get the list of knowledge bases for a specified user; a knowledge base is a collection of documents in Yuque.
get_repo_docs- Get a list of all documents within a specific knowledge base, including document titles, update times, etc.
get_doc- Get the detailed content of a specific document in Yuque, including the body, revision history, and permission information.
create_doc- Create a new Yuque document in a specified knowledge base, supporting multiple content formats (Markdown, HTML, Lake).
update_doc- Update an existing document in Yuque, allowing modifications to the title, content, or permission settings.
delete_doc- Delete a specified document from a Yuque knowledge base; this operation is irreversible.
search- Search for documents or knowledge base content within the Yuque platform, supporting scope and author filtering.
#### Team Statistical Analysis
get_group_statistics- Get aggregated statistical data for the team, including member count, document count, read counts, and interaction data.
get_group_member_statistics- Get statistical data for team members, including edit counts, read counts, and like counts for each member.
get_group_book_statistics- Get statistical data for team knowledge bases, including document count, word count, and read counts for each knowledge base.
get_group_doc_statistics- Get statistical data for team documents, including word count, read counts, and comment counts for each document.
Integration with AI Models
This MCP server can be used with AI models that support the Model-Context-Protocol, allowing them to interact with Yuque via the defined tools. For example:
1. Start the MCP server.
2. Connect to the server from a compatible client.
3. The AI model can now interact with Yuque data using the registered tools.
SSE Endpoint Query Parameters
When connecting to the SSE endpoint, you can override environment configurations via query parameters, which take precedence over environment variables:
accessToken: Overrides the Yuque API token set in the.envfile.
baseUrl: Overrides the Yuque API base URL set in the.envfile.
Example:
http://localhost:3000/sse?accessToken=your_token_here&baseUrl=https://custom.yuque.api/v2.env file, with query parameters taking precedence over environment variables. This is particularly useful for multi-user environments or testing different API endpoints.
Each SSE connection can use a different configuration, enabling a single server instance to serve different users or environments simultaneously.
Development
Project Structurecodesrc/
├── config.ts # 服务器配置
├── index.ts # 主入口点
├── cli.ts # CLI 入口点
├── server.ts # MCP 服务器实现
└── services/
└── yuque.ts # 语雀 API 服务
### Add New Tools
src/
├── config.ts # 服务器配置
├── index.ts # 主入口点
├── cli.ts # CLI 入口点
├── server.ts # MCP 服务器实现
└── services/
└── yuque.ts # 语雀 API 服务To add new tools, modify the registerTools method in src/server.ts.
API Improvements
Recent updates have added the following features:
1. Team Statistics: Added functionality to retrieve statistics for teams, members, knowledge bases, and documents, facilitating the analysis and monitoring of team knowledge base usage.
2. Document Management Enhancements:
- Support for multiple document formats (Markdown, HTML, Lake)
- Comprehensive document visibility settings (Private, Public, Internal)
- Search functionality now supports more parameters and filters
3. Data Type Refinement: Updated interface definitions to maintain consistency with the Yuque OpenAPI specification.
License
MIT License
Copyright (c) 2025 Henryhaoson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Acknowledgments- Figma-Context-MCP 提供 MCP 服务器实现参考
- 语雀开放 API 提供 API 文档
- Model Context Protocol 提供 MCP 规范