"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.listServers = listServers;
exports.listTools = listTools;
const client_1 = require("../client");
const format_1 = require("../format");
const SERVER_COLUMNS = [
    { key: 'id', label: 'ID', width: 12, format: (v) => v?.slice(0, 12) || '' },
    { key: 'name', label: 'Name', width: 28 },
    { key: 'transport_type', label: 'Transport', width: 10 },
    { key: 'status', label: 'Status', width: 10 },
];
async function listServers(opts) {
    const data = await (0, client_1.apiFetch)('/mcp/servers');
    const servers = data.servers || data;
    (0, format_1.output)(data, Array.isArray(servers) ? servers : [], SERVER_COLUMNS, opts);
}
async function listTools(serverId, opts) {
    const data = await (0, client_1.apiFetch)(`/mcp/servers/${serverId}/tools`);
    const tools = data.tools || [];
    if (opts.json) {
        console.log(JSON.stringify(data, null, 2));
        return;
    }
    if (opts.quiet) {
        tools.forEach((t) => console.log(t.name));
        return;
    }
    (0, format_1.output)(data, tools, [
        { key: 'name', label: 'Tool', width: 30 },
        { key: 'description', label: 'Description', width: 50 },
    ], {});
}
