"use strict";
/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.startCommand = void 0;
const core_1 = require("@stricli/core");
const core_2 = require("@stricli/core");
const z = __importStar(require("zod"));
const config_js_1 = require("../../../lib/config.js");
const console_logger_js_1 = require("../../console-logger.js");
const scopes_js_1 = require("../../scopes.js");
exports.startCommand = (0, core_1.buildCommand)({
    loader: async () => {
        const { main } = await import("./impl.js");
        return main;
    },
    parameters: {
        flags: {
            transport: {
                kind: "enum",
                brief: "The transport to use for communicating with the server",
                default: "stdio",
                values: ["stdio", "sse"],
            },
            port: {
                kind: "parsed",
                brief: "The port to use when the SSE transport is enabled",
                default: "2718",
                parse: (val) => z.coerce.number().int().gte(0).lt(65536).parse(val),
            },
            tool: {
                kind: "parsed",
                brief: "Specify tools to mount on the server",
                optional: true,
                variadic: true,
                parse: (value) => {
                    return z.string().parse(value);
                },
            },
            ...(scopes_js_1.mcpScopes.length
                ? {
                    scope: {
                        kind: "enum",
                        brief: "Mount tools/resources that match given scope (repeatable flag)",
                        values: scopes_js_1.mcpScopes,
                        variadic: true,
                        optional: true,
                    },
                }
                : {}),
            "api-key": {
                kind: "parsed",
                brief: "Sets the apiKey auth field for the API",
                optional: true,
                parse: (value) => {
                    return z.string().parse(value);
                },
            },
            "api-secret": {
                kind: "parsed",
                brief: "Sets the apiSecret auth field for the API",
                optional: true,
                parse: (value) => {
                    return z.string().parse(value);
                },
            },
            "cloud-name": {
                kind: "parsed",
                brief: "Allows setting the cloudName parameter for all supported operations",
                optional: true,
                parse: (value) => {
                    return z.string().parse(value);
                },
            },
            "server-url": {
                kind: "parsed",
                brief: "Overrides the default server URL used by the SDK",
                optional: true,
                parse: (value) => new URL(value).toString(),
            },
            "server-index": {
                kind: "parsed",
                brief: "Selects a predefined server used by the SDK",
                optional: true,
                parse: core_2.numberParser,
            },
            region: {
                kind: "enum",
                brief: "Sets the region variable for url substitution",
                optional: true,
                values: Object.values(config_js_1.ServerRegion),
            },
            "api-host": {
                kind: "parsed",
                brief: "Sets the host variable for url substitution",
                optional: true,
                parse: (value) => value,
            },
            "log-level": {
                kind: "enum",
                brief: "The log level to use for the server",
                default: "info",
                values: console_logger_js_1.consoleLoggerLevels,
            },
            env: {
                kind: "parsed",
                brief: "Environment variables made available to the server",
                optional: true,
                variadic: true,
                parse: (val) => {
                    const sepIdx = val.indexOf("=");
                    if (sepIdx === -1) {
                        throw new Error("Invalid environment variable format");
                    }
                    const key = val.slice(0, sepIdx);
                    const value = val.slice(sepIdx + 1);
                    return [
                        z.string().nonempty({
                            message: "Environment variable key must be a non-empty string",
                        }).parse(key),
                        z.string().nonempty({
                            message: "Environment variable value must be a non-empty string",
                        }).parse(value),
                    ];
                },
            },
        },
    },
    docs: {
        brief: "Run the Model Context Protocol server",
    },
});
//# sourceMappingURL=command.js.map