# 发布说明
## 问题分析
你遇到的错误 `ERR_INVALID_URL` 是因为 `package.json` 中配置了无效的 URL:
- `"url": "your-private-repo-url"` - 占位符,不是真实 URL
- `"registry": "your-private-npm-registry-url"` - 占位符,不是真实 registry
## 解决方案
### 方案1: 本地使用(推荐,无需发布)
如果只在本地使用,**不需要发布到 npm**。直接使用编译好的二进制文件:
```bash
# 在 Claude Desktop 配置中使用绝对路径
{
"mcpServers": {
"yapi-mcp-server": {
"command": "/Users/makeblock/Desktop/plugin/yapi-mcp-server/bin/yapi-mcp-server",
"env": {
"YAPI_BASE_URL": "https://yapi.makeblock.com",
"YAPI_TOKEN": "your-token"
}
}
}
}
```
### 方案2: 发布到私有 npm 仓库
如果要发布到私有 npm 仓库,需要:
1. **配置真实的私有 npm 仓库地址**
修改 `package.json`:
```json
{
"name": "@neigri/yapi-mcp-server",
"publishConfig": {
"registry": "https://npm.makeblock.com" // 你的私有 npm 地址
}
}
```
2. **登录私有 npm**
```bash
npm login --registry=https://npm.makeblock.com
```
3. **发布**
```bash
npm publish
```
### 方案3: 发布到 GitHub Packages
如果使用 GitHub,可以发布到 GitHub Packages:
1. **创建 GitHub 仓库**
2. **配置 package.json**
```json
{
"name": "@neigri/yapi-mcp-server",
"repository": {
"type": "git",
"url": "git+https://github.com/makeblock/yapi-mcp-server.git"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com"
}
}
```
3. **配置 npm 认证**
创建 `~/.npmrc`:
```
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
@neigri:registry=https://npm.pkg.github.com
```
4. **发布**
```bash
npm publish
```
### 方案4: 使用 tarball 分发
打包为 tarball,通过其他方式分发:
```bash
# 打包
npm pack
# 这会生成 yapi-mcp-server-1.0.0.tgz
# 可以通过邮件、内网等方式分发
# 安装
npm install -g ./yapi-mcp-server-1.0.0.tgz
```
## 推荐方案
对于企业内部使用,建议:
1. **如果有私有 npm 仓库**: 使用方案2
2. **如果使用 GitHub 企业版**: 使用方案3
3. **如果都没有**: 使用方案1(本地路径)
## 当前配置
已将 `package.json` 设置为 `"private": true`,这样可以防止意外发布到公共 npm。
如果要发布,需要:
1. 移除 `"private": true`
2. 配置正确的 registry URL
3. 登录对应的 npm registry
## 使用示例
### 本地使用(最简单)
```json
{
"mcpServers": {
"yapi-mcp-server": {
"command": "/Users/makeblock/Desktop/plugin/yapi-mcp-server/bin/yapi-mcp-server",
"env": {
"YAPI_BASE_URL": "https://yapi.makeblock.com",
"YAPI_TOKEN": "your-yapi-token-here"
}
}
}
}
```
### 使用 npx(需要先发布)
```json
{
"mcpServers": {
"yapi-mcp-server": {
"command": "npx",
"args": ["-y", "@neigri/yapi-mcp-server@latest"],
"env": {
"YAPI_BASE_URL": "https://yapi.makeblock.com",
"YAPI_TOKEN": "your-token"
}
}
}
}
```