import {
  exports_external
} from "../../chunk-c6ge431q.js";
import {
  __require
} from "../../chunk-9wyra8hs.js";

// src/commands/tool/spec.ts
var ToolCommandInputSchema = exports_external.object({
  toolName: exports_external.string().optional(),
  showSchema: exports_external.boolean().default(false),
  data: exports_external.string().optional(),
  dataFile: exports_external.string().optional(),
  output: exports_external.enum(["json", "pretty", "raw"]).default("pretty")
});
var ToolOptionsSchema = exports_external.object({
  schema: exports_external.boolean().default(false),
  data: exports_external.string().optional(),
  dataFile: exports_external.string().optional(),
  output: exports_external.enum(["json", "pretty", "raw"]).default("pretty")
});

// src/commands/tool/command.ts
var command = {
  name: "tool",
  arguments: "[toolName]",
  description: "Invoke MCP tools directly",
  options: [
    { flags: "-s, --schema", description: "Show tool arguments and schema" },
    { flags: "-d, --data <json>", description: "JSON data (like curl -d)" },
    { flags: "-f, --data-file <path>", description: "Read JSON from file (like curl -d @file)" },
    { flags: "-o, --output <format>", description: "Output format: json, pretty, raw", defaultValue: "pretty" }
  ],
  action: async (toolName, options) => {
    try {
      const parsedOptions = ToolOptionsSchema.parse(options);
      const { ToolCommandHandler } = await import("../../chunk-rj2gqxxb.js");
      const handler = new ToolCommandHandler;
      const result = await handler.execute({
        toolName,
        showSchema: parsedOptions.schema,
        data: parsedOptions.data,
        dataFile: parsedOptions.dataFile,
        output: parsedOptions.output
      });
      if (!result.success) {
        const errorOutput = {
          success: false,
          error: result.error,
          ...result.data && { data: result.data }
        };
        console.error(JSON.stringify(errorOutput, null, 2));
        process.exit(1);
      }
      if (parsedOptions.output === "json") {
        console.log(JSON.stringify(result.data));
      } else if (parsedOptions.output === "raw") {
        console.log(result.data);
      } else {
        console.log(JSON.stringify(result.data, null, 2));
      }
      process.exit(0);
    } catch (error) {
      if (error?.code !== undefined && error?.message) {
        console.error(`Error: ${error.message}`);
      } else if (error instanceof Error) {
        console.error(`Error: ${error.message}`);
      } else {
        console.error("Unexpected error:", error);
      }
      process.exit(1);
    }
  }
};
export {
  command
};

//# debugId=B230A8FCE346B17A64756E2164756E21
