中文文档 | English
A YAPI interface documentation query tool built with FastMCP, enabling AI assistants to access interface documentation from YAPI platforms.
- Get project basic information
- Get project list
- Get project member list
- Get interface documentation (request parameters and response structure)
- Get interface list for a project
- Get interface list by category
- Search interfaces by keyword
- Create interface
- Update interface
- Import Swagger/OpenAPI data
- Import Postman data
- Import JSON data
- Run automation tests
- Get test reports
- LDAP login authentication support
- Automatic login state management
- Integration with AI assistants via MCP protocol
git clone https://github.com/yourusername/yapi-mcp.git
cd yapi-mcp
pip install -e .Or using uv:
git clone https://github.com/yourusername/yapi-mcp.git
cd yapi-mcp
uv pip install -e .Configure YAPI connection through environment variables:
export YAPI_BASE_URL="https://your-yapi-server.com"
export YAPI_EMAIL="your-email@example.com"
export YAPI_PASSWORD="your-password"| Environment Variable | Description |
|---|---|
YAPI_BASE_URL |
YAPI server address |
YAPI_EMAIL |
Login email |
YAPI_PASSWORD |
Login password |
uv run yapi-mcppython -m yapi_mcpyapi-mcp{
"mcpServers": {
"yapi": {
"command": "uv",
"args": [
"--directory",
"/path/to/yapi-mcp",
"run",
"yapi-mcp"
],
"env": {
"YAPI_BASE_URL": "https://your-yapi-server.com",
"YAPI_EMAIL": "your-email@example.com",
"YAPI_PASSWORD": "your-password"
}
}
}
}{
"mcpServers": {
"yapi": {
"command": "uvx",
"args": [
"yapi-mcp"
],
"env": {
"YAPI_BASE_URL": "https://your-yapi-server.com",
"YAPI_EMAIL": "your-email@example.com",
"YAPI_PASSWORD": "your-password"
}
}
}
}Claude Desktop Configuration
Add to Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"yapi": {
"command": "python",
"args": ["-m", "yapi_mcp"],
"env": {
"YAPI_BASE_URL": "https://your-yapi-server.com",
"YAPI_EMAIL": "your-email@example.com",
"YAPI_PASSWORD": "your-password"
}
}
}
}{
"mcp": {
"servers": {
"yapi": {
"command": "uv",
"args": [
"--directory",
"/path/to/yapi-mcp",
"run",
"yapi-mcp"
],
"env": {
"YAPI_BASE_URL": "https://your-yapi-server.com",
"YAPI_EMAIL": "your-email@example.com",
"YAPI_PASSWORD": "your-password"
}
}
}
}
}Get basic information of a YAPI project.
Parameters:
project_id(int): Project ID
Returns: Project basic information dictionary
Get all projects accessible by the current user.
Returns: Project list
Get the member list of a specified project.
Parameters:
project_id(int): Project ID
Returns: Member list
Get YAPI interface documentation information.
Parameters:
url(string): YAPI interface URL, e.g.,https://yapi.example.com/project/123/interface/api/456
Returns:
title: Interface namerequest: Request parameter structureresponse: Response data structure
Get the interface list of a project, optionally filtered by category ID.
Parameters:
project_id(int): Project IDcat_id(int, optional): Category ID, retrieves all interfaces if not provided
Returns: Interface list
Get all interfaces under a specific category.
Parameters:
cat_id(int): Category ID
Returns: Interface list
Search for interfaces containing a keyword in a project.
Parameters:
project_id(int): Project IDkeyword(string): Search keyword
Returns: Matched interface list
Create a new interface in YAPI.
Parameters:
title(string): Interface titlecatid(int): Category IDpath(string): Interface pathmethod(string, optional): Request method (GET, POST, PUT, DELETE, etc.), default: "GET"desc(string, optional): Interface description, default: ""status(string, optional): Interface status (undone, done), default: "undone"req_query(array, optional): Request query parameters list, default: []req_headers(array, optional): Request headers list, default: [{"name": "Content-Type"}]req_body_form(array, optional): Form parameters list, default: []req_params(array, optional): Path parameters list, default: []req_body_other(string, optional): Request body JSON Schema string, default: ""res_body(string, optional): Response body JSON Schema string, default: ""res_body_type(string, optional): Response body type (json, raw, xml), default: "json"switch_notice(bool, optional): Enable notification, default: Falsemessage(string, optional): Interface notification message, default: ""
Returns: Create result, includes interface ID
Update an existing YAPI interface.
Parameters:
interface_id(int): Interface IDtitle(string): Interface titlecatid(int): Category IDpath(string): Interface pathmethod(string, optional): Request method (GET, POST, PUT, DELETE, etc.), default: "GET"desc(string, optional): Interface description, default: ""status(string, optional): Interface status (undone, done), default: "undone"req_query(array, optional): Request query parameters list, default: []req_headers(array, optional): Request headers list, default: [{"name": "Content-Type"}]req_body_form(array, optional): Form parameters list, default: []req_params(array, optional): Path parameters list, default: []req_body_other(string, optional): Request body JSON Schema string, default: ""res_body(string, optional): Response body JSON Schema string, default: ""res_body_type(string, optional): Response body type (json, raw, xml), default: "json"switch_notice(bool, optional): Enable notification, default: Falsemessage(string, optional): Interface notification message, default: ""
Returns: Update result
Import Swagger/OpenAPI data to YAPI from URL or JSON.
Parameters:
url(string, optional): URL of Swagger datajson(string, optional): Swagger JSON stringproject_id(int, optional): Target project IDmerge(string, optional): Merge strategy, options:normal,good,merge(default:normal)
Returns: Import result
Import Postman data to YAPI from URL or JSON.
Parameters:
url(string, optional): URL of Postman datajson(string, optional): Postman JSON stringproject_id(int, optional): Target project IDmerge(string, optional): Merge strategy, options:normal,good,merge(default:normal)
Returns: Import result
Import JSON data to YAPI.
Parameters:
json(string): JSON data stringproject_id(int): Target project IDmerge(string, optional): Merge strategy, options:normal,good,merge(default:normal)
Returns: Import result
Run automation tests and return test reports.
Parameters:
col_id(int): Test collection IDproject_id(int): Project IDtoken(string): Project tokenmode(string, optional): Report mode, options:html,json(default:html)email(bool, optional): Whether to send email notification (default:False)
Returns: Test report
With AI assistants, you can perform the following operations:
# Get interface documentation
Please get the documentation for interface https://yapi.example.com/project/123/interface/api/456
# Get project list
Please get all projects I have access to
# Get project members
Please get the member list for project 123
# Search interfaces
Please search for interfaces containing "user" keyword in project 123
# Import data
Please import this Swagger document to project 123: https://example.com/swagger.json
# Run tests
Please run automation tests for project 123, test collection ID is 456
yapi-mcp/
├── src/
│ └── yapi_mcp/
│ ├── __init__.py # Package entry, exports main modules
│ ├── __main__.py # CLI entry point
│ ├── server.py # MCP server and tool definitions
│ ├── client.py # YAPI client class
│ └── config.py # Configuration management
├── tests/
│ ├── __init__.py
│ └── test_config.py # Configuration tests
├── pyproject.toml # Project configuration
├── .gitignore # Git ignore file
└── README.md # This document
- Security: Do not hardcode credentials or commit them to version control systems
- Environment Variables: Use environment variables to configure sensitive information in production or shared environments
- LDAP Login: Currently only supports LDAP login. Modify the
login()method if other login methods are needed
- Check if email and password are correct
- Confirm the YAPI server address is correct (do not end with
/) - Confirm the server supports LDAP login
- Verify environment variables are set correctly
- Check environment variable names:
YAPI_BASE_URL,YAPI_EMAIL,YAPI_PASSWORD
MIT