Skip to main content
Glama
发布指南.md3.68 kB
# YApi MCP Server 发布指南 ## 发布到私有npm仓库 ### 1. 准备工作 #### 1.1 配置私有npm仓库 创建 `.npmrc` 文件: ```bash # 全局配置 registry=https://your-private-npm-registry.com # 或者使用scope配置(推荐) @neigri:registry=https://your-private-npm-registry.com //your-private-npm-registry.com/:_authToken=your-token-here ``` #### 1.2 更新package.json 修改 `package.json` 中的以下字段: ```json { "name": "@neigri/yapi-mcp-server", "repository": { "type": "git", "url": "git+https://your-private-repo-url.git" }, "publishConfig": { "registry": "https://your-private-npm-registry.com" } } ``` ### 2. 构建和发布 #### 方式1: 使用npm脚本(推荐) ```bash # 安装npm依赖(会自动触发构建) npm install # 发布 npm publish ``` #### 方式2: 手动构建 ```bash # 使用Makefile构建 make build # 或者直接使用Go go build -o bin/yapi-mcp-server . # 发布 npm publish ``` #### 方式3: 构建多平台版本 如果需要支持多平台,可以构建多个二进制文件: ```bash # 使用Makefile make build-all # 然后修改package.json的bin字段,根据平台选择不同的二进制文件 # 或者使用npm的os和cpu字段来指定 ``` ### 3. 使用私有包 #### 3.1 配置npm使用私有仓库 ```bash # 配置scope指向私有仓库 npm config set @neigri:registry https://your-private-npm-registry.com npm config set //your-private-npm-registry.com/:_authToken your-token ``` #### 3.2 在Claude Desktop中使用 ```json { "mcpServers": { "yapi-mcp-server": { "command": "npx", "args": [ "-y", "@neigri/yapi-mcp-server@latest" ], "env": { "YAPI_BASE_URL": "http://your-yapi-instance.com", "YAPI_TOKEN": "your-token" } } } } ``` ### 4. 版本管理 ```bash # 更新版本号 npm version patch # 1.0.0 -> 1.0.1 npm version minor # 1.0.0 -> 1.1.0 npm version major # 1.0.0 -> 2.0.0 # 发布新版本 npm publish ``` ### 5. 常见问题 #### 5.1 构建失败 确保已安装Go 1.21或更高版本: ```bash go version ``` #### 5.2 npm发布失败 检查: - `.npmrc` 配置是否正确 - 是否有发布权限 - 包名是否已存在 #### 5.3 npx无法找到包 确保: - npm配置正确指向私有仓库 - 包已成功发布 - 使用正确的scope和包名 ## 发布到GitHub Releases ### 1. 构建多平台二进制文件 ```bash make build-all ``` ### 2. 创建GitHub Release 1. 在GitHub上创建新的Release 2. 上传所有平台的二进制文件 3. 添加Release说明 ### 3. 使用GitHub Releases 用户可以直接下载对应平台的二进制文件使用。 ## 持续集成(CI/CD) ### GitHub Actions示例 创建 `.github/workflows/release.yml`: ```yaml name: Release on: push: tags: - 'v*' jobs: build: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] goarch: [amd64, arm64] exclude: - os: windows-latest goarch: arm64 steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v4 with: go-version: '1.21' - name: Build env: GOOS: ${{ matrix.os == 'ubuntu-latest' && 'linux' || matrix.os == 'macos-latest' && 'darwin' || 'windows' }} GOARCH: ${{ matrix.goarch }} run: | go build -o bin/yapi-mcp-server . - name: Upload artifacts uses: actions/upload-artifact@v3 with: name: yapi-mcp-server-${{ matrix.os }}-${{ matrix.goarch }} path: bin/yapi-mcp-server ```

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/KO-Good-code/yapi-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server