mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
fix(mcp): let mcp commands handle auth after arg validation and dry-run check
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user