YAPI MCP Server
A Model Context Protocol (MCP) server for interacting with a YAPI instance, enabling LLMs to list, search, and retrieve detailed API documentation from YAPI projects.
README
YAPI MCP Server
A Model Context Protocol (MCP) server for interacting with a YAPI instance. This server enables LLMs to retrieve API documentation details from your YAPI projects.
This release uses the MCP 2026-07-28 protocol over stdio. Legacy MCP initialization is intentionally not supported.
Features
- List Interfaces: Get all interface categories and basic interface info within a project
- List Project Interfaces: Page through a flat project interface list without loading the whole project
- List Category Interfaces: Page through interfaces for a category ID from a YAPI
/cat_<id>URL - Get Interface Details: Retrieve detailed information for a specific interface by its ID
- Get Interface Details Batch: Retrieve up to 10 interface details with bounded concurrency and per-ID errors
- Search Interfaces: Search for interfaces by keyword in titles or paths
- Runtime Response Validation: Reject malformed YAPI envelopes and tool payloads without exposing response values or request URLs
Tools
Every tool advertises an MCP output schema. Successful text content is the JSON serialization of the same validated structured result.
yapi_list_interfaces
Lists all interface categories and the interfaces within them for a specific YAPI project.
Input:
project_id(optional): Numeric project ID. Not required ifYAPI_PROJECT_IDis set.limit(optional, default100): Maximum interfaces to return; allowed range is1to500.
Returns: A structured object containing categories, including category_id, with simplified interface objects (id, category_id, title, path, method, status), return counts, and truncation metadata.
yapi_list_category_interfaces
Lists one page of interfaces for a category ID without loading every interface in the project.
Input:
category_id(positive integer, required): The numeric ID from a YAPI/cat_<id>URL.page(optional, default1): One-based page number.limit(optional, default100): Page size; allowed range is1to500.
Returns: Interface summaries plus returned, total, and total_pages pagination metadata.
yapi_list_project_interfaces
Lists exactly one server-paginated page of interfaces for a project.
Input:
project_id(optional): Numeric project ID. Not required ifYAPI_PROJECT_IDis set.page(optional, default1): One-based page number.limit(optional, default100): Page size; allowed range is1to500.
Returns: A flat interface page with project_id, page, limit, returned, total, and total_pages metadata.
yapi_get_interface_details
Gets detailed information for a specific YAPI interface by its ID.
Input:
project_id(optional): Numeric project ID. Not required ifYAPI_PROJECT_IDis set.interface_id(number, required): The ID of the specific YAPI interface.
Returns: A structured object whose interface field contains the full interface specification (request/response parameters, headers, body schemas, etc.).
yapi_get_interface_details_batch
Gets details for a bounded set of known interface IDs while preserving input order. Requests run with a fixed concurrency limit of 3, and one failed ID does not discard successful entries.
Input:
project_id(optional): Numeric project ID. Not required ifYAPI_PROJECT_IDis set.interface_ids(array, required): Between 1 and 10 unique positive integer interface IDs.
Returns: A structured object with ordered per-ID results, requested, succeeded, and failed counts. Each result contains either success: true with interface, or success: false with a credential-safe error.
yapi_search_interfaces
Searches for interfaces by keyword in their titles or paths using bounded server-paginated scanning.
Input:
project_id(optional): Numeric project ID. Not required ifYAPI_PROJECT_IDis set.keyword(string, required): The keyword to search for.limit(optional, default100): Maximum matches to return; allowed range is1to500.max_scan_pages(optional, default10): Maximum YAPI pages to scan; allowed range is1to100.
Returns: Matching interfaces (including category_id when supplied by YAPI) plus pages_scanned, interfaces_scanned, project pagination totals, and truncation metadata. total is the number of matches found in the scanned pages. truncated_reason is match_limit, max_scan_pages, or null after a complete scan.
Prerequisites
- A running YAPI instance
- Access to the project token(s) for the YAPI projects you want to interact with (found in YAPI project "Settings" -> "Tokens")
- Node.js 22+ installed
Environment Variables
| Variable | Required | Description |
|---|---|---|
YAPI_URL |
Yes | Base URL of your YAPI instance (e.g., http://yapi.example.com) |
YAPI_PROJECT_TOKEN |
Yes | Project credential. It is read only from the process environment and never accepted as tool input |
YAPI_PROJECT_ID |
No | Default numeric project ID. Tool calls may override it with project_id |
YAPI_REQUEST_TIMEOUT_MS |
No | HTTP timeout in milliseconds (100-300000, default 10000) |
Installation & Configuration
Build from Source
git clone <this-repo>
cd yapi-mcp-server
npm install
npm run build
Local Development (npm link)
For local development, use npm link to create a global symlink:
cd yapi-mcp-server
npm link
This makes mcp-server-yapi command available globally, avoiding hardcoded paths.
Claude Desktop
Add to your claude_desktop_config.json:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %AppData%\Claude\claude_desktop_config.json
{
"mcpServers": {
"yapi": {
"command": "mcp-server-yapi",
"env": {
"YAPI_URL": "<your-yapi-url>",
"YAPI_PROJECT_TOKEN": "<your-project-token>"
}
}
}
}
Claude Code (CLI)
Use the claude mcp command to add the server:
# Add to user config (available in all projects)
claude mcp add-json yapi -s user '{
"type": "stdio",
"command": "mcp-server-yapi",
"env": {
"YAPI_URL": "<your-yapi-url>",
"YAPI_PROJECT_TOKEN": "<your-project-token>"
}
}'
# Or add to project config (only for current project)
claude mcp add-json yapi -s project '{
"type": "stdio",
"command": "mcp-server-yapi",
"env": {
"YAPI_URL": "<your-yapi-url>",
"YAPI_PROJECT_TOKEN": "<your-project-token>"
}
}'
# Verify the configuration
claude mcp list
claude mcp get yapi
Cursor IDE
Add to your Cursor MCP settings:
macOS: ~/.cursor/mcp.json
Windows: %USERPROFILE%\.cursor\mcp.json
{
"mcpServers": {
"yapi": {
"command": "mcp-server-yapi",
"env": {
"YAPI_URL": "<your-yapi-url>",
"YAPI_PROJECT_TOKEN": "<your-project-token>"
}
}
}
}
Using npx (Recommended for distribution)
Version 0.8.0 requires an MCP 2026-07-28 client:
{
"mcpServers": {
"yapi": {
"command": "npx",
"args": ["-y", "@zjlgdx/yapi-mcp-server@0.8.0"],
"env": {
"YAPI_URL": "<your-yapi-url>",
"YAPI_PROJECT_TOKEN": "<your-project-token>"
}
}
}
}
Usage Examples
Once configured, you can ask Claude to:
- "List all APIs in my YAPI project"
- "List interfaces from YAPI category URL .../cat_114557"
- "Get details for interface ID 12345"
- "Search for APIs related to 'user' in my project"
- "Show me all POST endpoints"
Troubleshooting
Server not starting
- Ensure Node.js 22+ is installed
- Verify the path to
dist/index.jsis correct - Check that
YAPI_URLis set and accessible
Authentication errors
- Verify your
YAPI_PROJECT_TOKENis correct - Check token permissions in YAPI project settings
Network errors
- Ensure your YAPI instance is accessible from your machine
- Check firewall settings if using internal network
Development
# Install dependencies
npm install
# Build
npm run build
# Build and run the MCP 2026-07-28 stdio smoke tests
npm test
# Watch mode
npm run watch
# Run directly (requires env vars)
YAPI_URL=http://yapi.example.com YAPI_PROJECT_TOKEN=xxx npm start
The server is read-only: all exposed tools use YAPI GET endpoints and are advertised with MCP read-only annotations. Diagnostic output is written only to stderr; stdout is reserved for MCP messages.
Publishing
The npm package is @zjlgdx/yapi-mcp-server. The unscoped mcp-server-yapi package belongs to an unrelated publisher and must never be used as this repository's release target.
After the one-time bootstrap below, publishing is performed only by .github/workflows/publish.yml when a stable GitHub Release is published. The release tag must be v<package.json version>, point to a commit on main, and pass the same build, test, audit, and package-content gates used by CI. The workflow uses npm Trusted Publishing through GitHub OIDC; do not add an NPM_TOKEN secret or use manual publishing as a fallback.
Because npm requires a package to exist before Trusted Publishing can be configured, the owner of the npm zjlgdx user or organization scope must perform a one-time bootstrap with an npm account protected by 2FA:
- Confirm that the authenticated npm account owns the
@zjlgdxscope. - From a temporary clean copy of an exact, verified
maincommit, set a disposable prerelease version such as0.0.0-bootstrap.0without committing it, then runnpm publish --access public --tag bootstrap. Do not manually publish a stable release version. - Immediately configure Trusted Publishing on the new package with these exact values:
- Publisher: GitHub Actions
- Organization or user:
zjlgdx - Repository:
yapi-mcp-server - Workflow filename:
publish.yml - Environment:
npm - Allowed action:
npm publish
- Set package publishing access to require 2FA and disallow traditional tokens.
The bootstrap prerelease is the only manual publish. Every stable version must use the release workflow. The GitHub npm environment must allow only tags matching v*. Enable required reviewers when a reviewer distinct from the releaser is available. Trusted Publishing requires a public GitHub-hosted runner and automatically generates npm provenance for this public package.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。