Skip to content

Commit 4ae68ef

Browse files
committed
fix(mcp): let mcp commands handle auth after arg validation and dry-run check
1 parent 647d819 commit 4ae68ef

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

packages/cli/src/commands/mcp/call.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from "bailian-cli-core";
99
import { failIfMissing } from "../../output/prompt.ts";
1010
import { emitResult } from "../../output/output.ts";
11+
import { ensureApiKey } from "../../utils/ensure-key.ts";
1112

1213
function parseArgFlags(raw: string[]): Record<string, unknown> {
1314
const out: Record<string, unknown> = {};
@@ -106,6 +107,7 @@ export default defineCommand({
106107
return;
107108
}
108109

110+
await ensureApiKey(config);
109111
const client = new McpClient(config, url);
110112
await client.initialize();
111113
const result = await client.callTool(toolName, toolArgs);

packages/cli/src/commands/mcp/tools.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from "bailian-cli-core";
99
import { failIfMissing } from "../../output/prompt.ts";
1010
import { emitResult } from "../../output/output.ts";
11+
import { ensureApiKey } from "../../utils/ensure-key.ts";
1112

1213
export default defineCommand({
1314
name: "mcp tools",
@@ -40,6 +41,7 @@ export default defineCommand({
4041
return;
4142
}
4243

44+
await ensureApiKey(config);
4345
const client = new McpClient(config, url);
4446
await client.initialize();
4547
const tools = await client.listTools();

packages/cli/src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ const NO_AUTH_SETUP = [
6060
["app", "list"],
6161
["console", "call"],
6262
["usage", "free"],
63+
["mcp", "list"],
64+
["mcp", "tools"],
65+
["mcp", "call"],
6366
];
6467

6568
async function main() {

packages/core/lib/remote-telemetry/tracker.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,9 +1129,7 @@ module.exports = (function (e) {
11291129
method: "POST",
11301130
keepalive: true,
11311131
body: JSON.stringify({ gokey: encodeURIComponent(e), gmkey: "EXP" }),
1132-
}).catch(function (e) {
1133-
console.warn("send fail", e);
1134-
})
1132+
}).catch(function () {})
11351133
);
11361134
})
11371135
.catch(function (t) {

0 commit comments

Comments
 (0)