// cli/commands/serve.ts — planu serve [--port 3100] (SPEC-124)
import { parseArgs } from 'node:util';
import { green, cyan } from '../colors.js';
export const serveCommand = {
    name: 'serve',
    description: 'Start the MCP server via HTTP transport',
    usage: 'planu serve [--port 3100]',
    async run(args) {
        const { values } = parseArgs({
            args,
            options: {
                port: { type: 'string', short: 'p' },
            },
            strict: false,
            allowPositionals: true,
        });
        const port = values.port ?? '3100';
        // Re-invoke main server with --transport http flags
        const { selectTransport } = await import('../../transports/transport-factory.js');
        const { McpServer } = await import('@modelcontextprotocol/sdk/server/mcp.js');
        const { PLANU_VERSION } = await import('../../config/version.js');
        const { withToolTracking } = await import('../../tools/tool-registry.js');
        const { registerResources } = await import('../../resources/registry.js');
        const { registerSpecTools } = await import('../../tools/register-spec-tools.js');
        const { registerPlatformTools } = await import('../../tools/register-platform-tools.js');
        process.stdout.write(`${green('Starting Planu MCP server')} on port ${cyan(port)}...\n`);
        const server = withToolTracking(new McpServer({ name: 'planu', version: PLANU_VERSION }));
        registerResources(server);
        registerSpecTools(server);
        registerPlatformTools(server);
        await selectTransport(server, ['--transport', 'http', '--port', port], () => server);
    },
};
//# sourceMappingURL=serve.js.map