import { Command } from 'commander'; import type { ApiClient } from '../api-client.js'; export interface LogsCommandDeps { client: ApiClient; log: (...args: unknown[]) => void; } export function createLogsCommand(deps: LogsCommandDeps): Command { const { client, log } = deps; return new Command('logs') .description('Get logs from an MCP server instance') .argument('', 'Instance ID') .option('-t, --tail ', 'Number of lines to show') .action(async (id: string, opts: { tail?: string }) => { let url = `/api/v1/instances/${id}/logs`; if (opts.tail) { url += `?tail=${opts.tail}`; } const logs = await client.get<{ stdout: string; stderr: string }>(url); if (logs.stdout) { log(logs.stdout); } if (logs.stderr) { process.stderr.write(logs.stderr); } }); }