About yapi-server
yapi-server is an MCP server published by git+kevinLiJ in the Developer Tools category: yApi MCP Server. It has been installed 0 times through Conduid.
Install
npx yapi-mcp-serverclaude mcp add yapi-mcp-server-gitkevin -- npx -y yapi-mcp-servernpx -y yapi-mcp-serverThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about yapi-server
Powered by Claude · Grounded in docs
Security checks
- ·README presentNot checked yet.
- ·License declaredNot checked yet.
- ·Tests presentNot checked yet.
- ·Dependencies pinnedNot checked yet.
- ·No dynamic code executionNot checked yet.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
README
yapi-mcp-server
简介
yapi-mcp-server 是 Model Context Protocol (MCP) 的服务端实现。支持通过 MCP 协议获取 YApi 接口详情。
快速开始
全局
node环境需>=18
配置 mcp.json
在项目根目录下新建或编辑 mcp.json 文件,内容如下:
{
"mcpServers": {
"yapi-mcp-server": {
"command": "npx",
"args": [
"-y",
"yapi-mcp-server",
"--yapiToken=你的YApiToken",
"--yapiHost=https://yapi.xxx.net"
]
}
}
}
你的YApiToken替换为实际的 YApi Token(token 获取路径:yapi 项目->设置->token 配置->工具标识)https://yapi.xxx.net替换为你的 YApi 服务域名
MCP Server 功能
- 工具名:
yapi_get_apis_detail - 功能:批量获取 YApi 接口的详细信息。
- 参数:
apiIds:YApi 接口 ID 组成的数组。例如,接口地址为/project/1/interface/api/66,则 ID 为66。支持同时传入多个 ID。
- 返回值:对应接口的详细信息对象数组,结构与 YApi 返回一致。
实践
mcp配置成功之后,直接对cursor说:
生成接口代码
@api/index.ts
@https://yapi.XXX.net/project/13533/interface/api/1554281
@https://yapi.XXX.net/project/13533/interface/api/1554288
@https://yapi.XXX.net/project/13533/interface/api/1554334
cursor就会调用yapi-mcp-server获取接口的信息,并根据项目代码规范,生成对应的接口代码,比如:
// 删除组织:https://yapi.XXX.net/project/13533/interface/api/1554334
export function deleteOrg(data: { id: number }) {
return axios({
url: "/goapi/admin/org/delete",
method: "post",
data,
headers: {
"Content-Type": "application/json",
},
});
}
ai 可以给 接口函数起名字,爽歪歪!
制定规范,使生成的接口代码更符合规范
在 .cursorrules 文件中,编写接口代码的规范,比如:
// .cursorrules
接口代码规范:
- apiName 驼峰且动词前置,保持简洁
- 使用 axiosInstance
- 注释需包含接口名和 yapi 文档链接
- headers 有需要再加
import { axiosInstance as axios } from '@/api/axiosToken'
// {{$value.title}}:{{$value.yapiDocUrl}}
export function {{$value.apiName}}(data) {
return axios({
url: '{{$value.path}}',
method: '{{$value.method}}',
data,
// headers: { ... } // 如有自定义 header 再补充
})
}
参考链接
README mirrored from the source repository 4 months ago. The original is authoritative.