Model Context Protocol server for YApi 1.12.0 API management platform
Project description
YApi MCP Server
基于 YApi 1.12.0 接口管理平台的 Model Context Protocol (MCP) 服务器。
使开发者能够在支持 MCP 的 IDE 和编辑器(Claude Code、Cursor 等)中直接搜索、查看、创建和更新 YApi 接口定义,无需离开开发环境。
功能特性
- 🔍 搜索接口: 通过标题、路径或描述查找 API 端点
- 📖 查看定义: 获取完整的接口规范,包括请求/响应结构
- ➕ 创建接口: 向 YApi 项目添加新的 API 定义
- ✏️ 更新接口: 修改现有接口配置
- 🔐 Cookie 认证: 基于会话的安全认证
- ⚡ 异步性能: 基于 httpx 实现高效的并发操作
环境要求
- Python 3.11 或更高版本
- YApi 1.12.0 实例(可通过 HTTP/HTTPS 访问)
- 有效的 YApi 认证 cookies
配置
1. 获取 YApi Cookies
- 在浏览器中登录 YApi 实例
- 打开开发者工具(F12)
- 导航到 Application → Cookies(Chrome) 或 Storage → Cookies(Firefox)
- 复制以下 cookie 值:
_yapi_token(必需)_yapi_uid(必需)ZYBIPSCAS(可选,仅某些自定义部署需要)
2. 配置 MCP
{
"mcpServers": {
"yapi": {
"command": "uvx",
"args": ["--from", "/path/to/yapi-mcp", "yapi-mcp"],
"env": {
"YAPI_SERVER_URL": "https://your-yapi-instance.com",
"YAPI_TOKEN": "your_token",
"YAPI_UID": "your_uid"
}
}
}
}
注意: 如果你的 YApi 部署需要额外的 CAS 认证,添加
"YAPI_CAS": "your_cas_value"到env中。
开发
运行测试
# 安装开发依赖
pip install -e ".[dev]"
# 运行所有测试
pytest
# 运行并显示覆盖率
pytest --cov=src --cov-report=term-missing
# 运行特定测试文件
pytest tests/test_config.py
代码质量
# 格式化代码
ruff format
# 代码检查
ruff check
# 自动修复检查问题
ruff check --fix
项目结构
yapi-mcp/
├── src/
│ ├── server.py # MCP 服务器入口点
│ ├── config.py # 配置模型
│ ├── yapi/
│ │ ├── client.py # YApi API 客户端
│ │ ├── models.py # Pydantic 数据模型
│ │ └── errors.py # 错误映射
│ └── tools/ # MCP 工具(在 server.py 中注册)
├── tests/ # 测试套件
├── specs/ # 设计文档
├── pyproject.toml # 项目配置
├── .env.example # 环境变量模板
└── README.md # 本文件
贡献
欢迎贡献! 我们非常感谢各种形式的贡献,包括但不限于:
- 🐛 报告 Bug
- ✨ 建议新功能
- 📝 改进文档
- 💻 提交代码
在开始贡献之前,请阅读我们的贡献指南。
快速开始
- Fork 本仓库
- 创建功能分支 (
git checkout -b feature/amazing-feature) - 提交更改 (
git commit -m 'feat: 添加惊人的功能') - 推送到分支 (
git push origin feature/amazing-feature) - 创建 Pull Request
代码质量要求
- ✅ 所有测试通过:
pytest - ✅ 代码已格式化:
ruff format - ✅ 无检查错误:
ruff check - ✅ 新功能包含测试
详细信息请参阅 CONTRIBUTING.md。
许可证
本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。
相关项目
- YApi - API 管理平台
- fastmcp - Python MCP 框架
- Model Context Protocol - MCP 规范
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yapi_mcp-0.1.5.tar.gz.
File metadata
- Download URL: yapi_mcp-0.1.5.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fabbcbf24493938c2b6a6b03162b3e9cfdd533ec9a5eb1a530be524145b773c
|
|
| MD5 |
5c0387da4be84f49c1c8f137f2775cbf
|
|
| BLAKE2b-256 |
be032a88fdc2da7d0a33f9bacd983242302ce0e621626790cd1c99a7273fb1b7
|
File details
Details for the file yapi_mcp-0.1.5-py3-none-any.whl.
File metadata
- Download URL: yapi_mcp-0.1.5-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05e0bdf92dfd74a00a2f256cc6e797b142387f5a3ad5fbea7e32331f199521ce
|
|
| MD5 |
a221bf8fff55589cad907b9360a4e0e8
|
|
| BLAKE2b-256 |
dd1aa8698cad389b6bf813f385bd214aa5509a58a8d0e2914c18e32f7f2a64a9
|