Content
# Yapi Auto MCP Server
A Model Context Protocol (MCP) server for YApi, allowing you to directly manipulate YApi interface documents in AI programming tools like Cursor.
## Project Introduction
Yapi Auto MCP Server is a server based on [Model Context Protocol](https://modelcontextprotocol.io/), designed specifically for the YApi interface management platform. It allows you to directly:
- 🔍 **Search and view** interface documents in YApi projects
- ✏️ **Create and update** interface definitions
- 📋 **Manage project and category** structures
- 🔗 **Seamlessly integrate** AI programming workflows
- 🛠 **Support multiple YApi Project configurations**
Through the MCP protocol, AI assistants can understand your YApi interface structure, providing more accurate suggestions and code generation during the programming process.
## Main Features
### 🔍 Interface Query and Search
- **yapi_search_apis**: Search for interfaces by name, path, tags, etc.
- **yapi_get_api_desc**: Get detailed information about a specific interface (request/response structure, parameters, etc.)
- **yapi_list_projects**: List all accessible projects
- **yapi_get_categories**: Get the interface categories and interface list under the project
### ✏️ Interface Management
- **yapi_save_api**: Create a new interface or update an existing interface
- Supports complete interface definitions (path, method, parameters, request body, response, etc.)
- Supports JSON Schema and form data formats
- Automatically handles interface status and category management
### 🎯 Intelligent Features
- **Multi-project support**: Manage multiple YApi projects simultaneously
- **Caching mechanism**: Improve query response speed
- **Detailed logs**: Facilitate debugging and monitoring
- **Flexible configuration**: Supports environment variables and command-line arguments
## Quick Start
### Recommended Method: Use npx (No Installation Required)
1. **Get YApi Token**: Log in to your YApi platform and get the Token in the project settings
2. **Configure Cursor**: Add an MCP server in Cursor settings:
```json
{
"mcpServers": {
"yapi-auto-mcp": {
"command": "npx",
"args": [
"-y",
"yapi-auto-mcp",
"--stdio",
"--yapi-base-url=https://your-yapi-domain.com",
"--yapi-token=projectId:your_token_here"
]
}
}
}
```
3. **Start using**: Restart Cursor, and you can directly operate YApi in the conversation!
## Installation and Configuration
### Method 1: Use npx Directly (Recommended)
No local installation is required, run directly through npx:
```json
{
"mcpServers": {
"yapi-auto-mcp": {
"command": "npx",
"args": [
"-y",
"yapi-auto-mcp",
"--stdio",
"--yapi-base-url=https://yapi.example.com",
"--yapi-token=projectId:token1,projectId2:token2",
"--yapi-cache-ttl=10",
"--yapi-log-level=info"
]
}
}
}
```
### Method 2: Use Environment Variables
Define environment variables in the MCP configuration:
```json
{
"mcpServers": {
"yapi-auto-mcp": {
"command": "npx",
"args": [
"-y",
"yapi-auto-mcp",
"--stdio"
],
"env": {
"YAPI_BASE_URL": "https://yapi.example.com",
"YAPI_TOKEN": "projectId:token1,projectId2:token2",
"YAPI_CACHE_TTL": "10",
"YAPI_LOG_LEVEL": "info"
}
}
}
}
```
### Method 3: Local Development Mode
Suitable for scenarios where you need to modify code or debug:
1. **Clone and install**:
```bash
git clone <repository-url>
cd yapi-mcp
pnpm install
```
2. **Configure environment variables** (create a `.env` file in the project root directory):
```env
# YApi Basic Configuration
YAPI_BASE_URL=https://your-yapi-domain.com
YAPI_TOKEN=projectId:your_token_here,projectId2:your_token2_here
# Server Configuration
PORT=3388
# Optional Configuration
YAPI_CACHE_TTL=10
YAPI_LOG_LEVEL=info
```
3. **Start the service**:
**SSE Mode** (HTTP Service):
```bash
pnpm run dev
```
Then configure in Cursor:
```json
{
"mcpServers": {
"yapi-mcp": {
"url": "http://localhost:3388/sse"
}
}
}
```
**Stdio Mode**:
```bash
pnpm run build
node dist/cli.js --stdio
```
## Usage Guide
### Get YApi Token
1. Log in to your YApi platform
2. Go to the project settings page
3. Generate or view the Token in the Token configuration
<img src="./images/token.png" alt="Token 获取示例">
Token format description:
- Single project: `projectId:token`
- Multiple projects: `projectId1:token1,projectId2:token2`
### Usage Example
After the configuration is complete, you can use it like this in Cursor:
<img src="./images/demo1.png" alt="使用示例">
**Common operation examples**:
1. **Search interface**:
> "Find the interface related to user login"
2. **View interface details**:
> "Show the details of the user registration interface"
3. **Create a new interface**:
> "Create an interface to get the user list, the path is /api/users, using the GET method"
4. **Update interface**:
> "Update the user login interface and add a verification code parameter"
## Advanced Configuration
### Detailed Command Line Parameters
| Parameter | Description | Example | Default |
| ------------------- | --------------------------------- | --------------------------------------------- | ------- |
| `--yapi-base-url` | YApi server base URL | `--yapi-base-url=https://yapi.example.com` | - |
| `--yapi-token` | YApi project Token (supports multiple projects) | `--yapi-token=1026:token1,1027:token2` | - |
| `--yapi-cache-ttl` | Cache validity period (minutes) | `--yapi-cache-ttl=10` | 10 |
| `--yapi-log-level` | Log level | `--yapi-log-level=info` | info |
| `--port` | HTTP service port (SSE mode) | `--port=3388` | 3388 |
| `--stdio` | Enable stdio mode (required for MCP) | `--stdio` | - |
### Environment Variable Description
Create a `.env` file for configuration:
```env
# Required Configuration
YAPI_BASE_URL=https://your-yapi-domain.com
YAPI_TOKEN=projectId:your_token_here
# Optional Configuration
PORT=3388 # HTTP service port
YAPI_CACHE_TTL=10 # Cache validity period (minutes)
YAPI_LOG_LEVEL=info # Log level: debug, info, warn, error, none
```
### Log Level Description
- **debug**: Output all logs, including detailed debugging information
- **info**: Output information, warning, and error logs (default)
- **warn**: Output only warning and error logs
- **error**: Output only error logs
- **none**: Do not output any logs
### Configuration Method Selection Suggestions
| Use Case | Recommended Method | Advantages |
| -------- | ------------------ | -------- |
| Daily Use | npx + Command Line Parameters | No installation required, simple configuration |
| Team Sharing | npx + Environment Variables | Unified configuration, easy to manage |
| Development and Debugging | Local Installation + SSE Mode | Easy to debug and modify code |
| Enterprise Deployment | Local Installation + stdio Mode | Better performance, more stable |
Connection Info
You Might Also Like
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
servers
Model Context Protocol Servers
Time
A Model Context Protocol server for time and timezone conversions.
Filesystem
Node.js MCP Server for filesystem operations with dynamic access control.
Sequential Thinking
A structured MCP server for dynamic problem-solving and reflective thinking.
git
A Model Context Protocol server for Git automation and interaction.