Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 54 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,18 @@ Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

### PR 流程

**1. 创建功能分支:**
**⚠️ 重要规范:**
- **永远不要直接在 `main` 分支上提交代码**
- **版本号必须使用 `npm version` 命令更新,禁止手动修改 `package.json`**

**1. 创建功能分支(必须):**
```bash
# 从 main 分支创建新分支
git checkout main
git pull origin main
git checkout -b feature/your-feature-name
# 或

# 或 bug 修复分支
git checkout -b fix/your-bug-fix
```

Expand All @@ -429,13 +437,21 @@ git checkout -b fix/your-bug-fix
npm run build # 确保构建成功
npm test # 确保测试通过

# 提交代码
# 提交代码(在功能分支上提交)
git add .
git commit -m "feat: 你的功能描述"

# ⚠️ 不要在 main 分支提交!如果误提交到 main,需要重置:
# git checkout main
# git reset --hard HEAD~1 # 回退到上一个提交
# git checkout -b feature/your-feature-name
# git cherry-pick <commit-hash> # 将提交移到新分支
```

**3. 更新版本号(如需要):**
```bash
# ⚠️ 必须使用 npm version 命令,禁止手动修改 package.json

# Patch 版本(bug 修复)
npm version patch

Expand All @@ -444,11 +460,16 @@ npm version minor

# Major 版本(破坏性变更)
npm version major

# 预发布版本(可选)
npm version prerelease --preid beta
```

**4. 推送并创建 PR:**
```bash
# 推送分支和标签(如果有版本更新)
git push origin feature/your-feature-name
git push origin v1.x.x # 如果有版本标签
```

然后访问 GitHub 创建 Pull Request,或在命令行使用:
Expand All @@ -457,12 +478,13 @@ gh pr create --title "feat: 功能标题" --body "PR 描述"
```

**5. PR 检查清单:**
- ✅ 从 `main` 分支创建的功能分支(非 main 分支直接提交)
- ✅ CI 测试通过(GitHub Actions)
- ✅ 代码通过所有测试
- ✅ 新功能有对应的测试
- ✅ 提交信息符合规范
- ✅ PR 描述清晰说明了变更内容
- ✅ 版本号已正确更新(如需要)
- ✅ 版本号已使用 `npm version` 正确更新(如需要)

**6. 解决冲突(如有):**
```bash
Expand All @@ -476,13 +498,38 @@ git commit -m "chore: merge main and resolve conflicts"
git push origin feature/your-feature-name
```

**7. 常见错误修复:**

如果误提交到 `main` 分支:
```bash
# 1. 保存当前提交的哈希值
git log --oneline -1
# 记录 commit hash,例如:abc1234

# 2. 回退 main 分支
git checkout main
git reset --hard HEAD~1 # 回退最近一个提交
# 或回退到远程版本:git reset --hard origin/main

# 3. 创建功能分支并恢复提交
git checkout -b feature/your-feature-name
git cherry-pick abc1234 # 使用刚才记录的 hash

# 4. 推送功能分支
git push origin feature/your-feature-name
```

### 发布流程

项目采用**自动化发布**流程:

**1. 版本管理:**
- 修改 `package.json` 中的版本号
- 或使用 `npm version` 命令
**1. 版本管理(⚠️ 重要):**
- **必须使用 `npm version` 命令更新版本号**
- **禁止手动修改 `package.json` 中的 version 字段**
- `npm version` 会自动:
- 更新 `package.json` 中的版本号
- 创建版本提交(如 `1.2.0`)
- 创建 Git 标签(如 `v1.2.0`)

**2. 发布触发:**
- 当 PR 合并到 `main` 分支时
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@maplezzk/mcps",
"version": "1.1.6",
"version": "1.2.0",
"description": "A CLI to manage and use MCP servers",
"publishConfig": {
"access": "public"
Expand Down
60 changes: 44 additions & 16 deletions src/commands/call.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Command } from 'commander';
import chalk from 'chalk';
import { readFileSync } from 'fs';
import { configManager } from '../core/config.js';
import { DaemonClient } from '../core/daemon-client.js';

Expand All @@ -22,34 +23,61 @@ function printResult(result: any) {
export const registerCallCommand = (program: Command) => {
program.command('call <server> <tool> [args...]')
.description('Call a tool on a server. Arguments format: key=value')
.option('-r, --raw', 'Treat all values as raw strings (no JSON parsing)')
.option('-j, --json <file>', 'Load parameters from a JSON file')
.addHelpText('after', `
Examples:
$ mcps call my-server echo message="Hello World"
$ mcps call my-server add a=10 b=20
$ mcps call my-server config debug=true
$ mcps call my-server createUser user='{"name":"Alice","age":30}'

# Use --raw to treat all values as strings
$ mcps call my-server createUser --raw id="123" name="Alice"

# Use --json to load parameters from a file
$ mcps call my-server createUser --json params.json

Notes:
- Arguments are parsed as key=value pairs.
- Values are automatically parsed as JSON if possible (numbers, booleans, objects).
- If JSON parsing fails, the value is treated as a string.
- By default, values are automatically parsed as JSON if possible (numbers, booleans, objects).
- Use --raw to disable JSON parsing and treat all values as strings.
- Use --json to load parameters from a JSON file (overrides command line args).
- For strings with spaces, wrap the value in quotes (e.g., msg="hello world").
`)
.action(async (serverName, toolName, args) => {
const params: Record<string, any> = {};
if (args) {
args.forEach((arg: string) => {
const eqIndex = arg.indexOf('=');
if (eqIndex > 0) {
const key = arg.slice(0, eqIndex);
const valStr = arg.slice(eqIndex + 1);
try {
params[key] = JSON.parse(valStr);
} catch {
params[key] = valStr;
}
.action(async (serverName, toolName, args, options) => {
let params: Record<string, any> = {};

// Load from JSON file if specified
if (options.json) {
try {
const jsonContent = readFileSync(options.json, 'utf-8');
params = JSON.parse(jsonContent);
} catch (error: any) {
console.error(chalk.red(`Failed to load JSON file: ${error.message}`));
process.exit(1);
}
} else if (args) {
// Parse command line arguments
args.forEach((arg: string) => {
const eqIndex = arg.indexOf('=');
if (eqIndex > 0) {
const key = arg.slice(0, eqIndex);
const valStr = arg.slice(eqIndex + 1);

if (options.raw) {
// --raw mode: treat all values as strings
params[key] = valStr;
} else {
// Default mode: try JSON parsing
try {
params[key] = JSON.parse(valStr);
} catch {
params[key] = valStr;
}
});
}
}
});
}

// Check if server exists in config first
Expand Down
Loading