fix(mcp): let mcp commands handle auth after arg validation and dry-run check

This commit is contained in:
若麒
2026-06-05 15:52:47 +08:00
parent 647d819c9d
commit 4ae68ef61e
4 changed files with 8 additions and 3 deletions
+2
View File
@@ -8,6 +8,7 @@ import {
} from "bailian-cli-core";
import { failIfMissing } from "../../output/prompt.ts";
import { emitResult } from "../../output/output.ts";
import { ensureApiKey } from "../../utils/ensure-key.ts";
function parseArgFlags(raw: string[]): Record<string, unknown> {
const out: Record<string, unknown> = {};
@@ -106,6 +107,7 @@ export default defineCommand({
return;
}
await ensureApiKey(config);
const client = new McpClient(config, url);
await client.initialize();
const result = await client.callTool(toolName, toolArgs);
+2
View File
@@ -8,6 +8,7 @@ import {
} from "bailian-cli-core";
import { failIfMissing } from "../../output/prompt.ts";
import { emitResult } from "../../output/output.ts";
import { ensureApiKey } from "../../utils/ensure-key.ts";
export default defineCommand({
name: "mcp tools",
@@ -40,6 +41,7 @@ export default defineCommand({
return;
}
await ensureApiKey(config);
const client = new McpClient(config, url);
await client.initialize();
const tools = await client.listTools();
+3
View File
@@ -60,6 +60,9 @@ const NO_AUTH_SETUP = [
["app", "list"],
["console", "call"],
["usage", "free"],
["mcp", "list"],
["mcp", "tools"],
["mcp", "call"],
];
async function main() {
@@ -1129,9 +1129,7 @@ module.exports = (function (e) {
method: "POST",
keepalive: true,
body: JSON.stringify({ gokey: encodeURIComponent(e), gmkey: "EXP" }),
}).catch(function (e) {
console.warn("send fail", e);
})
}).catch(function () {})
);
})
.catch(function (t) {