A Model-Context-Protocol (MCP) server for integrating with Yuque's API. This implementation is inspired by Figma-Context-MCP and uses the Yuque Open API.
This server provides MCP tools for interacting with Yuque's knowledge base platform, allowing AI models to:
- Get user and document information
- Create, read, update, and delete documents
- Search content in Yuque
- Get repository information
- Get statistics and analytical data
- Node.js 18+ (recommended)
- Yuque account with API token
-
Clone this repository:
git clone https://github.com/Henryhaoson/Yueque-MCP-Server.git cd Yueque-MCP-Server
-
Install dependencies:
npm install
-
Create a
.env
file based on the.env.example
:cp .env.example .env
-
(Optional) Add your Yuque API token in the
.env
file:YUQUE_API_TOKEN=your_yuque_api_token_here
You can also choose to provide the token via query parameters when connecting to the server instead of setting it in the .env file.
# HTTP server mode
npm run dev
# CLI stdio mode
npm run dev:cli
First, build the project:
npm run build
Then run in either HTTP or CLI mode:
# HTTP server mode
npm run start
# CLI stdio mode
npm run start:cli
This project provides Docker support, making it easy to containerize and deploy the server.
-
Build and start the container:
docker-compose up -d
-
View logs:
docker-compose logs -f
-
Stop the service:
docker-compose down
You can set configuration options via environment variables or in the .env
file:
# .env file example
PORT=3000
YUQUE_API_TOKEN=your_token_here
YUQUE_API_BASE_URL=https://www.yuque.com/api/v2
-
Build the Docker image:
docker build -t yuque-mcp-server .
-
Run the container:
docker run -d -p 3000:3000 --name yuque-mcp-server yuque-mcp-server
-
Using environment variables:
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-server
The Yuque MCP Server provides the following tools:
get_current_user
- Get information about the currently authenticated userget_user_docs
- Get all documents for the current user, including private and collaborative documentsget_user_repos
- Get the repositories of a specified userget_repo_docs
- Get all documents in a specific repositoryget_doc
- Get the detailed content of a specific document in Yuquecreate_doc
- Create a new document in a specified repositoryupdate_doc
- Update an existing document in Yuquedelete_doc
- Delete a specified document from a Yuque repositorysearch
- Search for documents or repositories in the Yuque platform
get_group_statistics
- Get summary statistics for a teamget_group_member_statistics
- Get statistics for team membersget_group_book_statistics
- Get statistics for team repositoriesget_group_doc_statistics
- Get statistics for team documents
This MCP server can be used with AI models that support the Model-Context-Protocol, allowing them to interact with Yuque through defined tools. For example:
- Start the MCP server
- Connect to the server from a compatible client
- The AI model can now use the registered tools to interact with Yuque data
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 .env filebaseUrl
: Overrides the Yuque API base URL set in the .env file
Example:
http://localhost:3000/sse?accessToken=your_token_here&baseUrl=https://custom.yuque.api/v2
This allows you to dynamically configure the service without modifying the .env file, and query parameters take precedence over environment variables. This is especially useful for multi-user environments or testing different API endpoints.
Each SSE connection can use different configurations, allowing a single server instance to serve different users or environments simultaneously.
src/
├── config.ts # Server configuration
├── index.ts # Main entry point
├── cli.ts # CLI entry point
├── server.ts # MCP server implementation
└── services/
└── yuque.ts # Yuque API service
To add a new tool, modify the registerTools
method in src/server.ts
.
Recent updates have added the following features:
-
Team Statistics: Added functionality to get statistics for teams, members, repositories, and documents to facilitate analysis and monitoring of team knowledge base usage.
-
Document Management Enhancements:
- Support for multiple document formats (Markdown, HTML, Lake)
- Comprehensive document publicity settings (private, public, enterprise-internal public)
- Search functionality with more parameters and filtering conditions
-
Data Type Refinement: Updated interface definitions to remain consistent with the Yuque OpenAPI specification.
ISC
- Figma-Context-MCP for the MCP server implementation
- Yuque Open API for API documentation
- Model Context Protocol for the MCP specification