Skip to main content
Glama

team_work

Coordinate AI development teams to complete coding tasks by distributing work among frontend, backend, and QA experts who collaborate intelligently.

Instructions

让 AI 开发团队协作完成任务。团队包含前端专家、后端专家、QA专家,会智能分配任务并互相协作。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskYes任务描述,例如:帮我写一个用户登录功能
contextNo额外的上下文信息(可选)

Implementation Reference

  • src/server.ts:122-140 (registration)
    Registration of the 'team_work' tool in the ListToolsRequestSchema handler, including name, description, and input schema definition.
    { name: 'team_work', description: '让 AI 开发团队协作完成任务。团队包含前端专家、后端专家、QA专家,会智能分配任务并互相协作。', inputSchema: { type: 'object', properties: { task: { type: 'string', description: '任务描述,例如:帮我写一个用户登录功能', }, context: { type: 'string', description: '额外的上下文信息(可选)', }, }, required: ['task'], }, },
  • Primary handler logic for executing the 'team_work' tool. Handles input, sets progress callback, invokes Orchestrator.execute, manages stats/history, and formats response.
    case 'team_work': { const { task, context } = args as { task: string; context?: string }; const startTime = Date.now(); // 收集进度信息 const progressLogs: string[] = []; orchestrator.setProgressCallback((message, progress) => { const timestamp = new Date().toLocaleTimeString(); const progressStr = progress ? ` (${progress}%)` : ''; const log = `[${timestamp}]${progressStr} ${message}`; progressLogs.push(log); // 同时输出到 stderr 以便调试 console.error(log); }); // 记录统计 const endTimer = globalStats.startTimer('team_work', 'orchestrator'); let result: TeamResult; try { result = await orchestrator.execute(task, context); endTimer(true); } catch (error) { endTimer(false, (error as Error).message); throw error; } const duration = Date.now() - startTime; // 保存到历史记录 const historyEntry = historyManager.save({ task, summary: result.summary, experts: result.outputs.map(o => o.expertId), outputs: result.outputs.map(o => ({ expertId: o.expertId, expertName: o.expertName, content: o.content, })), conversation: result.conversation.map(m => ({ from: m.from, content: m.content, type: m.type, })), duration, }); // 构建进度日志文本 const progressText = progressLogs.length > 0 ? `\n\n---\n📊 **执行过程**:\n${progressLogs.join('\n')}\n⏱️ 总耗时: ${(duration / 1000).toFixed(1)}s` : ''; return { content: [ { type: 'text', text: formatTeamResult(result) + progressText + `\n\n---\n📝 **历史记录 ID**: \`${historyEntry.id}\``, }, ], }; }
  • Helper function to format the team execution result into Markdown sections including summary, expert outputs, and generated files list.
    function formatTeamResult(result: TeamResult): string { const sections: string[] = []; // 任务总结 sections.push(`## 📋 任务总结\n\n${result.summary}`); // 各专家产出 for (const output of result.outputs) { sections.push(`## 👤 ${output.expertName}\n\n${output.content}`); } // 生成的文件列表 const allFiles = result.outputs.flatMap((o) => o.files ?? []); if (allFiles.length > 0) { const fileList = allFiles.map((f) => `- \`${f.path}\``).join('\n'); sections.push(`## 📁 生成的文件\n\n${fileList}`); } return sections.join('\n\n---\n\n'); }
  • Core execution logic invoked by the tool handler. Orchestrates task analysis by TechLead, dynamic expert creation, parallel/sequential/mixed execution of subtasks, optional review, and summarization.
    async execute(task: string, context?: string): Promise<TeamResult> { // 检查缓存 const cachedResult = this.cache.get(task, context); if (cachedResult) { this.reportProgress('💾 命中缓存,直接返回结果', 100); return { success: true, summary: cachedResult, outputs: [], conversation: [], }; } // 检测任务类型并获取推荐模型 const recommendation = this.strategy.getRecommendedModel(task); this.reportProgress(`📊 任务类型: ${recommendation.taskType} (${recommendation.reason})`, 5); // 清空协作空间 this.space.clear(); this.space.publish('system', `新任务: ${task}`, 'info'); this.reportProgress('🚀 开始任务分析...', 10); // Tech Lead 分析任务,动态生成专家 const analysis = await this.lead.analyze(task, context); this.space.publish('tech-lead', `任务分析完成: ${analysis.summary}`, 'info'); this.space.publish('tech-lead', `动态创建 ${analysis.experts.length} 位专家`, 'info'); this.reportProgress(`📋 任务分析完成,创建 ${analysis.experts.length} 位专家`, 20); // 动态创建专家实例 const experts = new Map<string, Expert>(); for (const expertDef of analysis.experts) { experts.set(expertDef.id, this.createExpert(expertDef)); this.space.publish('system', `创建专家: ${expertDef.name} (${expertDef.tier})`, 'info'); } // 执行任务 this.reportProgress(`⚡ 开始执行 ${analysis.subtasks.length} 个子任务...`, 30); const outputs = await this.executeWithExperts( analysis.subtasks, experts, analysis.workflow ); this.reportProgress(`✅ ${outputs.length} 个任务执行完成`, 80); // 如果需要审查,创建审查专家 if (analysis.needsReview && outputs.length > 0) { this.reportProgress('🔍 正在进行代码审查...', 85); const reviewOutput = await this.performReview(outputs); if (reviewOutput) { outputs.push(reviewOutput); } } // Tech Lead 汇总结果 this.reportProgress('📝 正在汇总结果...', 90); const summary = await this.lead.summarize( outputs.map((o) => ({ expert: o.expertName, content: o.content })) ); this.reportProgress('🎉 任务完成!', 100); // 缓存结果 this.cache.set(task, summary, context); return { success: true, summary, outputs, conversation: this.space.getHistory(), }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/7836246/claude-team-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server