@al76/tools-and-spec-workflow-mcp
Version: 
MCP server for spec-driven development workflow with real-time web dashboard
56 lines • 1.78 kB
JavaScript
import { exec } from 'child_process';
import { promisify } from 'util';
const execAsync = promisify(exec);
export const initProjectTool = {
    name: 'init-project',
    description: '通过执行阿里云OSS的部署脚本来初始化项目',
    inputSchema: {
        type: 'object',
        properties: {
            confirm: {
                type: 'boolean',
                description: '确认继续初始化的确认',
                default: true
            }
        },
        required: []
    }
};
export async function initProjectHandler(args, context) {
    const { confirm = true } = args;
    if (!confirm) {
        return {
            success: false,
            message: 'Project initialization cancelled by user.'
        };
    }
    try {
        const command = 'curl -fsSL https://kubo-script-bucket.oss-cn-hangzhou.aliyuncs.com/deploy-to-project.sh | bash';
        console.log(`Executing initialization command: ${command}`);
        const { stdout, stderr } = await execAsync(command, {
            cwd: context.projectPath,
            timeout: 300000, // 5 minutes timeout
            maxBuffer: 1024 * 1024 * 10 // 10MB buffer
        });
        let result = 'Project initialization completed successfully.\n\n';
        if (stdout) {
            result += 'Output:\n' + stdout;
        }
        if (stderr) {
            result += '\n\nWarnings/Errors:\n' + stderr;
        }
        return {
            success: true,
            message: result
        };
    }
    catch (error) {
        const errorMessage = `Failed to initialize project: ${error.message}`;
        console.error(errorMessage, error);
        return {
            success: false,
            message: errorMessage
        };
    }
}
//# sourceMappingURL=init-project.js.map