suggest_workflow
Recommends optimal workflows for given tasks by analyzing requirements and suggesting efficient processes to complete objectives.
Instructions
根据任务自动推荐合适的工作流
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task | Yes | 任务描述 |
Implementation Reference
- src/server.ts:922-965 (handler)Handler implementation for the 'suggest_workflow' tool. Extracts the task from arguments, uses workflowManager.matchWorkflow to find matching workflow, and formats a response with recommendation or fallback list.case 'suggest_workflow': { const { task } = args as { task: string }; const matched = workflowManager.matchWorkflow(task); if (matched) { const stepsDesc = matched.steps .filter(s => s.type === 'expert') .map((s, i) => `${i + 1}. **${s.name}** - ${s.expert?.role.slice(0, 50)}...`) .join('\n'); return { content: [{ type: 'text', text: `# 💡 推荐工作流 ## ${matched.name} (\`${matched.id}\`) ${matched.description} ### 执行步骤 ${stepsDesc} ### 触发原因 任务包含关键词: ${matched.triggers.filter(t => task.toLowerCase().includes(t.toLowerCase())).join(', ')} --- > 使用 \`run_workflow\` 执行此工作流: > \`{ "workflow": "${matched.id}", "task": "${task.slice(0, 50)}..." }\`` }], }; } else { return { content: [{ type: 'text', text: `# 💡 工作流推荐 未找到匹配的预定义工作流。 **建议**: 使用 \`team_work\` 让 Tech Lead 动态分析任务并创建专家团队。 **可用工作流**: - \`code-generation\` - 代码生成(写、创建、实现) - \`bug-fix\` - Bug 修复(修复、错误、fix) - \`refactoring\` - 代码重构(重构、优化) - \`code-review\` - 代码审查(审查、review) - \`documentation\` - 文档生成(文档、doc)` }], }; } }
- src/server.ts:388-401 (registration)Registration of the 'suggest_workflow' tool in the MCP server's ListToolsRequestSchema handler, including name, description, and input schema.{ name: 'suggest_workflow', description: '根据任务自动推荐合适的工作流', inputSchema: { type: 'object', properties: { task: { type: 'string', description: '任务描述', }, }, required: ['task'], }, },
- src/server.ts:391-400 (schema)Input schema definition for suggest_workflow: requires a 'task' string describing the task to analyze.inputSchema: { type: 'object', properties: { task: { type: 'string', description: '任务描述', }, }, required: ['task'], },
- Core helper function matchWorkflow that implements the workflow suggestion logic by checking task keywords against triggers in custom and predefined workflows.matchWorkflow(task: string): WorkflowDefinition | undefined { const taskLower = task.toLowerCase(); // 先检查自定义工作流 for (const workflow of this.customWorkflows.values()) { if (workflow.triggers.some(t => taskLower.includes(t.toLowerCase()))) { return workflow; } } // 再检查预定义模板 for (const workflow of this.templates.values()) { if (workflow.triggers.some(t => taskLower.includes(t.toLowerCase()))) { return workflow; } } return undefined; }