From a3e5fb2c724d378ad6ad0cee43c043a37e1efa11 Mon Sep 17 00:00:00 2001 From: zhangzikuan Date: Mon, 2 Feb 2026 20:32:47 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20call=20=E5=91=BD=E4=BB=A4=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20--raw=20=E5=92=8C=20--json=20=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增功能: - 添加 --raw 选项,禁用自动 JSON 解析,所有值作为字符串处理 - 添加 --json 选项,支持从 JSON 文件加载参数 - 更新帮助文档和示例 使用示例: mcps call server tool --raw id="123" name="Alice" mcps call server tool --json params.json Co-Authored-By: Claude Sonnet 4.5 --- src/commands/call.ts | 60 ++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/src/commands/call.ts b/src/commands/call.ts index eb216e7..fe226c3 100644 --- a/src/commands/call.ts +++ b/src/commands/call.ts @@ -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'; @@ -22,6 +23,8 @@ function printResult(result: any) { export const registerCallCommand = (program: Command) => { program.command('call [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 ', 'Load parameters from a JSON file') .addHelpText('after', ` Examples: $ mcps call my-server echo message="Hello World" @@ -29,27 +32,52 @@ Examples: $ 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 = {}; - 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 = {}; + + // 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 From 9ccc5fc68c92bdc8aeaedcf4de2903c31b764ed5 Mon Sep 17 00:00:00 2001 From: zhangzikuan Date: Mon, 2 Feb 2026 20:34:35 +0800 Subject: [PATCH 2/3] 1.2.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 764e9bf..925493c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@maplezzk/mcps", - "version": "1.1.6", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@maplezzk/mcps", - "version": "1.1.6", + "version": "1.2.0", "license": "ISC", "dependencies": { "@modelcontextprotocol/sdk": "^1.25.3", diff --git a/package.json b/package.json index ecb1e3b..c85e79f 100644 --- a/package.json +++ b/package.json @@ -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" From d148b54b4fb39806498bac7b905d3f4f8d35b149 Mon Sep 17 00:00:00 2001 From: zhangzikuan Date: Mon, 2 Feb 2026 20:35:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?docs:=20=E5=AE=8C=E5=96=84=E5=BC=80?= =?UTF-8?q?=E5=8F=91=E6=B5=81=E7=A8=8B=E6=96=87=E6=A1=A3=EF=BC=8C=E5=BC=BA?= =?UTF-8?q?=E8=B0=83=E5=88=86=E6=94=AF=E5=92=8C=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 强调必须在 feature 分支开发,禁止直接在 main 分支提交 - 强调必须使用 npm version 命令更新版本号 - 添加常见错误修复指南(误提交到 main 的处理方法) - 完善 PR 流程检查清单 Co-Authored-By: Claude Sonnet 4.5 --- README.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index dcfc374..545d4be 100644 --- a/README.md +++ b/README.md @@ -409,10 +409,18 @@ Co-Authored-By: Claude Sonnet 4.5 ### 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 ``` @@ -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 # 将提交移到新分支 ``` **3. 更新版本号(如需要):** ```bash +# ⚠️ 必须使用 npm version 命令,禁止手动修改 package.json + # Patch 版本(bug 修复) npm version patch @@ -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,或在命令行使用: @@ -457,12 +478,13 @@ gh pr create --title "feat: 功能标题" --body "PR 描述" ``` **5. PR 检查清单:** +- ✅ 从 `main` 分支创建的功能分支(非 main 分支直接提交) - ✅ CI 测试通过(GitHub Actions) - ✅ 代码通过所有测试 - ✅ 新功能有对应的测试 - ✅ 提交信息符合规范 - ✅ PR 描述清晰说明了变更内容 -- ✅ 版本号已正确更新(如需要) +- ✅ 版本号已使用 `npm version` 正确更新(如需要) **6. 解决冲突(如有):** ```bash @@ -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` 分支时